86 lines
3.8 KiB
Markdown
86 lines
3.8 KiB
Markdown
# sccache-dash
|
|
|
|
Is [sccache](https://github.com/mozilla/sccache) actually saving you time? sccache-dash answers
|
|
that with a dashboard in your browser.
|
|
|
|
It is one small Linux program. It runs in the background, reads sccache's counters every 10
|
|
seconds, keeps 30 days of history, and shows the result at <http://127.0.0.1:8226>. Only the
|
|
machine it runs on can open that page.
|
|
|
|
The page shows, for the last hour, 24 hours, 7 days or 30 days:
|
|
|
|
- how many compiles came from the cache, overall and per language
|
|
- roughly how much time that saved, with a 90% range
|
|
- what looks wrong: cache errors, timeouts, a language that rarely hits, a cache close to full
|
|
- where the other compiles went, and why some could not be cached
|
|
- how long a cache hit takes compared with a build, and how build times are spread
|
|
|
|
## What it looks like
|
|
|
|

|
|
|
|
<table>
|
|
<tr>
|
|
<td width="72%"><img src="docs/screenshots/desktop-light.png" alt="The dashboard on a wide screen, light"></td>
|
|
<td><img src="docs/screenshots/phone-dark.png" alt="The dashboard at phone width, dark"></td>
|
|
</tr>
|
|
</table>
|
|
|
|
## Install
|
|
|
|
```
|
|
just build # builds the page (trunk) and then the server
|
|
sccache-dash # serves http://127.0.0.1:8226 and opens it
|
|
sccache-dash install # the same, as a systemd user service that starts at login
|
|
sccache-dash uninstall
|
|
```
|
|
|
|
`sccache-dash [--port N] [--no-open]` serves. `install` writes
|
|
`~/.config/systemd/user/sccache-dash.service` with the absolute path of the binary and the `PATH`
|
|
of the shell that ran it, so that `sccache` is found; the service never opens a browser.
|
|
|
|
`SCCACHE_DASH_SCCACHE` names the sccache command when it is not simply `sccache` on `PATH`.
|
|
|
|
Until the page has been built (`crates/ui/dist`), the server serves a placeholder saying so; its
|
|
API answers either way.
|
|
|
|
## Routes
|
|
|
|
| Route | What it does |
|
|
| --- | --- |
|
|
| `GET /api/view?range=1h\|24h\|7d\|30d\|reset` | one `View`: totals, the period before, timing, time saved, languages, buckets, problems, a summary |
|
|
| `GET /api/export` | sccache's current stats exactly as `sccache --show-stats --stats-format json` prints them, as a download |
|
|
| `POST /api/zero` | runs `sccache --zero-stats`; the saved history is kept |
|
|
| `GET /` | the page |
|
|
|
|
`/api/zero` is refused unless the request's `Host` is localhost and, when it has an `Origin`,
|
|
that origin is this server, so a web page elsewhere cannot zero the stats.
|
|
|
|
## Where history lives
|
|
|
|
`$XDG_DATA_HOME/sccache-dash/history.db` (`~/.local/share/...` by default): one SQLite file. Its
|
|
`readings` table holds one row a minute at most, and only when sccache's counters changed; each
|
|
row is the difference since the row before it, so a range total is one indexed query. Per-language
|
|
counts and not-cacheable reasons sit in their own tables, and `build_obs` holds what the polls saw
|
|
of how long a build of each language takes. A stretch without rows is a gap. Rows older than 30
|
|
days are deleted at startup and once a day. Deleting the file loses the history and nothing else.
|
|
|
|
The five views (one per range) are made after every poll and kept in memory, so a request never
|
|
waits for the database.
|
|
|
|
A counter that goes down means sccache reset its counters (`--zero-stats`, or its server
|
|
restarted): the range counts start again from zero there and the chart marks the spot. The first
|
|
reading ever is a baseline and counts for nothing.
|
|
|
|
## Notes on sccache
|
|
|
|
When no sccache server is running, sccache-dash starts one (`sccache --start-server`); if that
|
|
fails it shows "not running" with the error and tries again a minute later.
|
|
|
|
While sccache-dash runs, sccache's server stays up: being asked for its stats every 10 seconds
|
|
keeps it from shutting itself down after 10 idle minutes.
|
|
|
|
## Licence
|
|
|
|
MIT or Apache-2.0, at your choice (`LICENSE-MIT`, `LICENSE-APACHE`).
|