From f342dba86ed2f94145679ad59ad4401f74185d53 Mon Sep 17 00:00:00 2001 From: Brennan Stehling <277419+brennanMKE@users.noreply.github.com> Date: Sun, 25 Oct 2026 22:33:56 -0700 Subject: [PATCH] xtask perf: a row that failed in any run gets no baseline; judge contention on the load before the build (#7494) Co-Authored-By: Claude Opus 5.5 (1M context) --- docs/development.md | 3 ++- xtask/src/perf.rs | 21 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/docs/development.md b/docs/development.md index bf36f8ce4e7..1a111c6a95c 100644 --- a/docs/development.md +++ b/docs/development.md @@ -441,7 +441,8 @@ against a baseline from the same machine class and mode, or when a bench fails. different machine classes are never compared, and `--quick` numbers are only compared with a quick baseline. Machines that run other work give noisy numbers: check the load average in the summary before trusting a regression, and record it next to any number you quote. A run whose -1-minute load at the start is above `settings.max_load_per_core` per core is marked **contended** +1-minute load at the start (sampled before the release build, so the harness's own compile doesn't +count) is above `settings.max_load_per_core` per core is marked **contended** in the summary, and `--update-baseline` refuses to record it unless `--allow-contended` is given. **Recording a baseline.** One run is noisy, especially on the shared nightly runner, so build the diff --git a/xtask/src/perf.rs b/xtask/src/perf.rs index 0fb63fc4223..5f79193f9a0 100644 --- a/xtask/src/perf.rs +++ b/xtask/src/perf.rs @@ -731,7 +731,10 @@ pub fn baseline_from_runs(old: Option<&Value>, runs: &[Value], rules: &BaselineR } let mut scenarios = serde_json::Map::new(); for (k, st) in &per { - failed.remove(k); + // A row that crashed in any run stays failed: no partial aggregate. + if failed.contains_key(k) { + continue; + } let mut p50: Vec = st.iter().filter_map(|s| s.p50).collect(); let mut p95: Vec = st.iter().filter_map(|s| s.p95).collect(); let fmax = |f: fn(&Stats) -> Option| st.iter().filter_map(f).reduce(f64::max); @@ -898,6 +901,9 @@ pub fn run(root: &Path, rest: &[&str]) -> Result<(), String> { plan.push((b, args)); } + // Sampled before the build: the harness's own compile isn't contention. The load after the + // build is still recorded, as the first bench's `load_avg_before`. + let load_start = load_avg(); if !o.skip_build { let mut by_pkg: BTreeMap<&str, Vec<&str>> = BTreeMap::new(); for (b, _) in &plan { @@ -913,7 +919,6 @@ pub fn run(root: &Path, rest: &[&str]) -> Result<(), String> { } } - let load_start = load_avg(); let mut reports: BTreeMap> = BTreeMap::new(); let mut bench_meta = serde_json::Map::new(); for (b, args) in &plan { @@ -1375,6 +1380,18 @@ not_measurable = "needs a frame harness" assert_eq!(median(&mut [4.0, 1.0, 3.0, 2.0]), Some(2.5)); } + #[test] + fn baseline_from_runs_keeps_a_row_failed_in_any_run() { + let mut runs: Vec = (1..=3).map(|d| run_of(&format!("2026-10-2{d}"), 1.0, &[("P1", 3.0), ("P2", 5.0)])).collect(); + runs[1]["scenarios"]["P1"] = json!({"status": format!("{MISSING_PREFIX}bench crashed")}); + let b = baseline_from_runs(None, &runs, &rules(3, false)).unwrap(); + let m = &b["modes"]["full"]; + assert!(m["scenarios"].get("P1").is_none(), "no partial aggregate: {m}"); + assert_eq!(m["failed"]["P1"], json!("bench crashed")); + assert_eq!(m["scenarios"]["P2"]["p50_ms"], json!(5.0)); + assert!(m["failed"].get("P2").is_none()); + } + #[test] fn baseline_from_runs_rejects_mixed_classes_modes_dirty_and_too_few() { let runs: Vec = (1..=5).map(|d| run_of(&format!("2026-10-2{d}"), 1.0, &[("P1", 3.0)])).collect();