Say what each not-cacheable reason means and what to change; explain a low Rust hit rate

Each reason now carries a plain name, meaning, action and a fixable flag (checked
against sccache 0.18.0), shown with its count in the reasons panel, fixable first.
The low-hit-rate problem names the fixable loss and the Rust hash-key inputs.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Sonnet 5.5 committed 2026-11-28 17:45:38 -07:00
1 parent 3ede855fbb
commit 0f4df265a5
8 files changed
+498 -52

No files matched your search

+22 -12
View File
@@ -530,12 +530,12 @@ fn table_height(fixed: f32, rows: usize) -> f32 {
/// How tall the row of "Where compiles went", "By language" and "Problems" is:
/// enough for the tallest of the three, and never less than the usual height.
fn triptych_height(view: &View) -> f32 {
fn triptych_height(ui: &egui::Ui, view: &View, panel_width: f32) -> f32 {
use theme::layout as l;
l::TRIPTYCH_HEIGHT
.max(l::WHERE_FIXED_HEIGHT)
.max(table_height(l::LANGUAGES_FIXED_HEIGHT, view.languages.len()))
.max(problems_height(view))
.max(problems_height(ui, view, panel_width))
}
/// How tall "Speed" is.
@@ -549,22 +549,30 @@ fn speed_height(view: &View) -> f32 {
table_height(l::SPEED_FIXED_HEIGHT, 0) + with_histograms as f32 * l::HISTOGRAM_HEIGHT
}
fn problems_height(view: &View) -> f32 {
/// How tall "Problems" is in a panel `panel_width` wide: each problem's title, and its detail
/// wrapped to the panel.
fn problems_height(ui: &egui::Ui, view: &View, panel_width: f32) -> f32 {
use theme::layout as l;
if view.problems.is_empty() {
88.0
} else {
table_height(l::PROBLEMS_FIXED_HEIGHT, 0) + view.problems.len() as f32 * l::PROBLEM_HEIGHT
return 88.0;
}
let inner = panel_width - 2.0 * (theme::space::PANEL_PADDING + 1.0);
let details: f32 = view
.problems
.iter()
.map(|problem| style::galley(ui, theme::small(ui, problem.detail.clone()), true, inner).size().y + 21.0)
.sum();
let gaps = (view.problems.len() - 1) as f32 * (theme::space::BETWEEN_PARTS + theme::space::LINE);
l::PROBLEMS_FIXED_HEIGHT + details + gaps
}
/// How tall the row of "Over time" is when "Speed" and "Why compiles were not
/// cacheable" are stacked beside it: the taller of the two sides.
fn charts_height(view: &View) -> f32 {
fn charts_height(ui: &egui::Ui, view: &View, side_width: f32) -> f32 {
use theme::layout as l;
let stacked = speed_height(view)
+ theme::space::PANEL_GAP
+ where_went::reasons_height(view.not_cached.len());
+ where_went::reasons_height(ui, view, side_width);
l::CHARTS_HEIGHT.max(stacked)
}
@@ -598,14 +606,15 @@ fn page(ui: &mut egui::Ui, view: &View, asked: Range, hidden_languages: &mut Vec
match columns {
3 => {
let [a, b, c] = row(ui, triptych_height(view), &[1, 1, 1]).try_into().expect("three panels");
let third = style::span_width(ui, 3, 1);
let [a, b, c] = row(ui, triptych_height(ui, view, third), &[1, 1, 1]).try_into().expect("three panels");
let (_, a) = style::panel(ui, a, "Where compiles went", |ui| where_went::section(ui, view));
let (_, b) = style::panel(ui, b, "By language", |ui| where_went::languages(ui, view));
let (_, c) = style::panel(ui, c, "Problems", |ui| problems::section(ui, view));
close_row(ui, &[a, b, c]);
// "Over time" over two columns; "Speed" and the reasons stacked in the third, together as tall.
let height = charts_height(view);
let height = charts_height(ui, view, third);
let [wide, side] = row(ui, height, &[2, 1]).try_into().expect("two panels");
let speed = speed_height(view);
let speed_rect = egui::Rect::from_min_max(side.min, egui::pos2(side.right(), side.top() + speed));
@@ -620,7 +629,8 @@ fn page(ui: &mut egui::Ui, view: &View, asked: Range, hidden_languages: &mut Vec
close_row(ui, &[wide, speed, reasons]);
}
2 => {
let reasons = where_went::reasons_height(view.not_cached.len());
let half = style::span_width(ui, 2, 1);
let reasons = where_went::reasons_height(ui, view, half);
let height = l::TRIPTYCH_HEIGHT.max(l::WHERE_FIXED_HEIGHT).max(reasons);
let [a, b] = row(ui, height, &[1, 1]).try_into().expect("two panels");
let (_, a) = style::panel(ui, a, "Where compiles went", |ui| where_went::section(ui, view));
@@ -628,7 +638,7 @@ fn page(ui: &mut egui::Ui, view: &View, asked: Range, hidden_languages: &mut Vec
close_row(ui, &[a, b]);
let height = l::TRIPTYCH_HEIGHT
.max(table_height(l::LANGUAGES_FIXED_HEIGHT, view.languages.len()))
.max(problems_height(view));
.max(problems_height(ui, view, half));
let [a, b] = row(ui, height, &[1, 1]).try_into().expect("two panels");
let (_, a) = style::panel(ui, a, "By language", |ui| where_went::languages(ui, view));
let (_, b) = style::panel(ui, b, "Problems", |ui| problems::section(ui, view));
+3 -2
View File
@@ -114,7 +114,7 @@ mod tests {
{ "name": "Rust", "hits": 229, "misses": 3256, "errors": 0 },
{ "name": "C/C++", "hits": 2082, "misses": 0, "errors": 0 }
],
"not_cached": [["crate-type", 621], ["incremental", 105]],
"not_cached": [{"reason": "crate-type", "count": 621, "name": "Programs and libraries that get linked", "meaning": "m", "action": "a", "fixable": false}, {"reason": "incremental", "count": 105, "name": "n", "meaning": "m", "action": "a", "fixable": true}],
"buckets": [
{ "start": 1764290000, "hits": 10, "misses": 5, "other": 1, "errors": 0, "saved_seconds": 60.0,
"languages": [["Rust", 10, 5]], "reset": false, "gap": false },
@@ -140,7 +140,8 @@ mod tests {
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.not_cached[0].reason.as_str(), view.not_cached[0].count), ("crate-type", 621));
assert!(view.not_cached[1].fixable);
assert_eq!(view.buckets[1].gap, true);
assert_eq!(view.extras[0].rows[0].1, "2");
}
+2 -4
View File
@@ -197,8 +197,8 @@ pub mod layout {
pub const CHARTS_HEIGHT: f32 = 516.0;
/// "Where compiles went": its bar, legend and the "of the built" line.
pub const WHERE_FIXED_HEIGHT: f32 = 244.0;
/// "Why compiles were not cacheable" needs this much beside its rows.
pub const REASONS_FIXED_HEIGHT: f32 = 90.0;
/// "Why compiles were not cacheable" needs this much beside its reasons: padding, title and the room under it.
pub const REASONS_FIXED_HEIGHT: f32 = 66.0;
/// From this panel width the "By language" table has room for its hit-rate bars.
pub const LANGUAGE_BARS_FROM: f32 = 380.0;
/// "By language" needs this much beside its rows.
@@ -207,8 +207,6 @@ pub mod layout {
pub const SPEED_FIXED_HEIGHT: f32 = 250.0;
/// "Problems" needs this much beside its problems.
pub const PROBLEMS_FIXED_HEIGHT: f32 = 60.0;
/// "Problems" needs this much per problem.
pub const PROBLEM_HEIGHT: f32 = 62.0;
/// "Speed" needs this much per language with a histogram.
pub const HISTOGRAM_HEIGHT: f32 = 85.0;
}
+99 -18
View File
@@ -2,7 +2,10 @@
//! shares; what happened inside the built share; and why some could not be
//! cached. How each language fared is its own panel ([`languages`]).
use eframe::egui::{self, Color32, Ui};
use std::sync::Arc;
use eframe::egui::{self, Color32, Sense, Stroke, Ui};
use eframe::epaint::text::Galley;
use sccache_dash_api::View;
use crate::fmt;
@@ -54,30 +57,108 @@ pub fn section(ui: &mut Ui, view: &View) {
));
}
/// "Why compiles were not cacheable": the reasons table, one row per reason.
/// One reason laid out for a width: its name, numbers and the two small paragraphs.
struct Block {
name: Arc<Galley>,
count: Arc<Galley>,
share: Arc<Galley>,
meaning: Arc<Galley>,
/// `None` when sccache gives nothing to do.
action: Option<Arc<Galley>>,
/// The first line: the name, or as tall as the name when it wraps.
row: f32,
}
impl Block {
/// Its height, counting the room each part is given.
fn height(&self) -> f32 {
let line = theme::space::LINE;
let mut height = self.row + line + self.meaning.size().y + line;
if let Some(action) = &self.action {
height += action.size().y + line;
}
height
}
}
/// How far the name is from the numbers, and from the dot.
const NAME_GAP: f32 = 8.0;
/// Lay every reason out in `width`; counts and shares line up in columns, the name takes the rest.
fn blocks(ui: &Ui, view: &View, width: f32) -> Vec<Block> {
let number = |text: String| style::galley(ui, theme::number(text), false, f32::INFINITY);
let numbers: Vec<(Arc<Galley>, Arc<Galley>)> = view
.not_cached
.iter()
.map(|r| (number(fmt::count(r.count)), number(fmt::share(r.count, view.totals.not_cacheable))))
.collect();
let widest = |pick: fn(&(Arc<Galley>, Arc<Galley>)) -> &Arc<Galley>| {
numbers.iter().map(|n| pick(n).size().x).fold(0.0, f32::max)
};
let (count_width, share_width) = (widest(|n| &n.0), widest(|n| &n.1));
let dot = theme::drawing::SEVERITY_DOT + NAME_GAP;
let name_width = (width - dot - count_width - share_width - 2.0 * NAME_GAP).max(40.0);
view.not_cached
.iter()
.zip(numbers)
.map(|(r, (count, share))| {
let name = style::galley(ui, theme::body(r.name.clone()), true, name_width);
let small = |text: &str| style::galley(ui, theme::small(ui, text), true, width);
Block {
row: theme::space::ROW.max(name.size().y + 6.0),
name,
count,
share,
meaning: small(&r.meaning),
action: (!r.action.is_empty()).then(|| small(&r.action)),
}
})
.collect()
}
/// "Why compiles were not cacheable": each reason with a dot (the warning colour when a
/// setting would fix it, the muted one when it is expected), its plain name, its count and
/// share, and under it, in small print, what it means and what to do.
pub fn reasons(ui: &mut Ui, view: &View) {
if view.not_cached.is_empty() {
ui.label(theme::small(ui, "Every compile could be cached in this range."));
return;
}
let rows: Vec<Vec<Cell>> = view
.not_cached
.iter()
.map(|(reason, count)| {
vec![
Cell::Text(theme::body(reason.clone())),
Cell::Text(theme::number(fmt::count(*count))),
Cell::Text(theme::number(fmt::share(*count, view.totals.not_cacheable))),
]
})
.collect();
style::table(ui, &["Reason", "Compiles", "Share"], &rows);
let p = theme::ui(ui);
let width = ui.available_width();
let blocks = blocks(ui, view, width);
for (index, (reason, block)) in view.not_cached.iter().zip(&blocks).enumerate() {
if index > 0 {
let (gap, _) = ui.allocate_exact_size(egui::vec2(width, theme::space::BETWEEN_PARTS), Sense::hover());
ui.painter().hline(gap.x_range(), gap.center().y.round() + 0.5, Stroke::new(1.0, p.grid));
}
let (row, _) = ui.allocate_exact_size(egui::vec2(width, block.row), Sense::hover());
let painter = ui.painter();
let side = theme::drawing::SEVERITY_DOT;
let dot = if reason.fixable { p.warn } else { p.not_cacheable };
let name_top = row.top() + (block.row - block.name.size().y) / 2.0;
painter.circle_filled(egui::pos2(row.left() + side / 2.0, name_top + 8.0), side / 2.0, dot);
painter.galley(egui::pos2(row.left() + side + NAME_GAP, name_top), block.name.clone(), p.text);
let share_left = row.right() - block.share.size().x;
let at = |galley: &Arc<Galley>, right: f32| {
egui::pos2(right - galley.size().x, row.top() + (block.row - galley.size().y) / 2.0)
};
painter.galley(at(&block.share, row.right()), block.share.clone(), p.text);
painter.galley(at(&block.count, share_left - NAME_GAP), block.count.clone(), p.text);
for galley in std::iter::once(&block.meaning).chain(block.action.as_ref()) {
let (place, _) = ui.allocate_exact_size(galley.size(), Sense::hover());
ui.painter().galley(place.min, galley.clone(), p.muted);
}
}
}
/// How tall "Why compiles were not cacheable" is with `rows` reasons.
pub fn reasons_height(rows: usize) -> f32 {
let rows = rows.max(1);
theme::layout::REASONS_FIXED_HEIGHT + rows as f32 * theme::space::ROW
/// How tall "Why compiles were not cacheable" is in a panel `panel_width` wide.
pub fn reasons_height(ui: &Ui, view: &View, panel_width: f32) -> f32 {
let inner = panel_width - 2.0 * (theme::space::PANEL_PADDING + 1.0);
let blocks = blocks(ui, view, inner);
let gaps = blocks.len().saturating_sub(1) as f32 * (theme::space::BETWEEN_PARTS + theme::space::LINE);
let content: f32 = blocks.iter().map(Block::height).sum();
theme::layout::REASONS_FIXED_HEIGHT + content.max(theme::space::ROW) + gaps
}
/// "By language": one row per language, with hits, misses, errors, the hit rate