Dashboard page: fit the page, five shares, build-time histograms

- Built is the miss count, as sccache counts timeouts, cache errors and
  forced recaches inside it. The bar under the headline has five shares
  that add up to every compiler call and always to 100%; what happened
  inside the built share is one line under the bar.
- The time saved shows its 90% range in small print under the figure.
- Speed gains "How long builds take, by language": one fixed-height
  histogram per language on a shared log scale of build time, with the
  mean, median and p90 marked.
- The api crate's Range helpers replace the page's own copies.
- Drawing is built only for the browser, so the tests (and the rest of
  the crate) build anywhere without eframe's native backends.
- Tables are drawn row by row; egui's Grid lost its rows when a cell
  held more than a plain widget. Fold-away bodies are held to the width
  of the page, and the charts fit their data every frame.
- mise.toml takes trunk 0.22.2 as a release binary; building it from
  source took over half an hour.
This commit is contained in:
swaits committed 2026-11-28 12:10:01 -07:00
1 parent c589b7c868
commit dc876b5a5c
13 files changed
+549 -361

No files matched your search

+129 -10
View File
@@ -1,17 +1,30 @@
//! The sccache-dash dashboard page. `trunk` compiles this to WebAssembly and
//! the sccache-dash server serves it at http://127.0.0.1:8226.
pub mod app;
pub mod cards;
pub mod extras;
pub mod fmt;
pub mod net;
pub mod overtime;
pub mod problems;
pub mod raw;
pub mod speed;
pub mod style;
pub mod where_went;
// Drawing needs eframe, which is only built for the browser so far; the rest
// (and the tests) build anywhere.
#[cfg(target_arch = "wasm32")]
mod app;
#[cfg(target_arch = "wasm32")]
mod cards;
#[cfg(target_arch = "wasm32")]
mod extras;
#[cfg(target_arch = "wasm32")]
mod net;
#[cfg(target_arch = "wasm32")]
mod overtime;
#[cfg(target_arch = "wasm32")]
mod problems;
#[cfg(target_arch = "wasm32")]
mod raw;
#[cfg(target_arch = "wasm32")]
mod speed;
#[cfg(target_arch = "wasm32")]
mod style;
#[cfg(target_arch = "wasm32")]
mod where_went;
/// The canvas in `index.html` the page is drawn on.
pub const CANVAS_ID: &str = "the_canvas_id";
@@ -50,3 +63,109 @@ mod web {
});
}
}
#[cfg(test)]
mod tests {
use sccache_dash_api::{Range, View};
/// A view with something in every part of the page.
const SAMPLE: &str = r#"{
"range": "24h",
"generated_at": 1764300000,
"server": {
"status": "Running",
"version": "0.18.0",
"client_version": "0.18.0",
"cache_location": "Local disk: \"/home/me/.cache/sccache\"",
"cache_size": 10726353131,
"max_cache_size": 10737418240,
"error": null
},
"totals": {
"requests": 5610, "executed": 5610, "hits": 2815, "misses": 2795,
"not_cacheable": 0, "unsupported_compiler": 0, "not_compile": 0,
"timeouts": 3, "read_errors": 2, "write_errors": 1, "other_errors": 0,
"compile_fails": 12, "forced_recaches": 4, "cache_writes": 2795
},
"previous": {
"requests": 5000, "executed": 5000, "hits": 2000, "misses": 3000,
"not_cacheable": 0, "unsupported_compiler": 0, "not_compile": 0,
"timeouts": 0, "read_errors": 0, "write_errors": 0, "other_errors": 0,
"compile_fails": 9, "forced_recaches": 0, "cache_writes": 3000
},
"timing": { "avg_hit_read_ms": 0.72, "avg_cache_write_ms": 310.0, "avg_compile_ms": 8050.0 },
"time_saved": {
"seconds": 11100.0, "interval_90": [9700.0, 12600.0], "hits_left_out": 7,
"note": "Low on purpose."
},
"build_times": [
{ "language": "Rust", "compiles": 3256, "mean_ms": 7780.0, "median_ms": 7100.0,
"p90_ms": 21200.0,
"bins": [
{ "from_ms": 1000.0, "to_ms": 1778.28, "compiles": 120 },
{ "from_ms": 1778.28, "to_ms": 3162.28, "compiles": 980 }
] },
{ "language": "CUDA", "compiles": 0, "mean_ms": 0.0, "median_ms": 0.0,
"p90_ms": 0.0, "bins": [] }
],
"languages": [
{ "name": "Rust", "hits": 229, "misses": 3256, "errors": 0 },
{ "name": "C/C++", "hits": 2082, "misses": 0, "errors": 0 }
],
"not_cached": [["crate-type", 621], ["incremental", 105]],
"buckets": [
{ "start": 1764290000, "hits": 10, "misses": 5, "other": 1, "errors": 0, "saved_seconds": 60.0,
"languages": [["Rust", 10, 5]], "reset": false, "gap": false },
{ "start": 1764290600, "hits": 0, "misses": 0, "other": 0, "errors": 0, "saved_seconds": 0.0,
"languages": [], "reset": false, "gap": true },
{ "start": 1764291200, "hits": 4, "misses": 4, "other": 0, "errors": 0, "saved_seconds": 30.0,
"languages": [["C/C++", 4, 4]], "reset": true, "gap": false }
],
"problems": [
{ "severity": "Warning", "title": "Rust hit rate 8%", "detail": "Most Rust compiles miss." }
],
"extras": [ { "title": "Multi-level cache", "rows": [["Levels", "2"]] } ],
"raw": { "stats": { "compile_requests": 5610 }, "version": "0.18.0" },
"summary_markdown": "**Cache:** 50%"
}"#;
#[test]
fn a_view_deserialises() {
let view: View = serde_json::from_str(SAMPLE).expect("the sample is a View");
assert_eq!(view.range, Some(Range::Day));
assert_eq!(view.totals.hit_rate(), Some(2815.0 / 5610.0));
assert_eq!(view.server.version.as_deref(), Some("0.18.0"));
assert_eq!(view.time_saved.interval_90, Some((9700.0, 12600.0)));
assert_eq!(view.build_times[0].bins[1].compiles, 980);
assert_eq!(view.build_times[1].compiles, 0);
assert_eq!(view.not_cached[0], ("crate-type".to_owned(), 621));
assert_eq!(view.buckets[1].gap, true);
assert_eq!(view.extras[0].rows[0].1, "2");
}
#[test]
fn an_empty_view_deserialises() {
// Every field is present, as the server always sends them; several are empty.
let view: View = serde_json::from_str(
r#"{"range": null, "generated_at": 0, "server": {"status": "NotRunning"},
"totals": {
"requests": 0, "executed": 0, "hits": 0, "misses": 0, "not_cacheable": 0,
"unsupported_compiler": 0, "not_compile": 0, "timeouts": 0, "read_errors": 0,
"write_errors": 0, "other_errors": 0, "compile_fails": 0, "forced_recaches": 0,
"cache_writes": 0
},
"previous": null,
"timing": {
"avg_hit_read_ms": null, "avg_cache_write_ms": null, "avg_compile_ms": null
},
"time_saved": {"seconds": 0.0, "hits_left_out": 0, "note": ""},
"languages": [], "not_cached": [], "buckets": [], "problems": [], "extras": [],
"raw": null, "summary_markdown": ""}"#,
)
.expect("an empty view is still a View");
assert_eq!(view.totals.hit_rate(), None);
assert_eq!(view.time_saved.interval_90, None);
assert!(view.build_times.is_empty());
assert!(view.raw.is_null());
}
}