Skip to content

bug(bench): bench-compare base-then-head ordering fabricates large false regressions under thermal load #714

Description

@ohdearquant

Summary

make bench-compare (scripts/bench-compare.sh) builds and benches BASE first, then HEAD second, in the same process on the same machine. The second half runs on a CPU already thermally saturated by the first half's full Criterion sweep, so it throttles and every HEAD bench inflates uniformly. This fabricates large one-sided "regressions" that are pure artifacts of run order, not code.

Reproduction (null A/B — identical source both sides)

scripts/bench-compare.sh origin/main origin/main   # same commit vs itself, zero diff

Result on an idle M2 Max (all other jobs quiesced), 2026-07-08:

  • 56 FAIL / 12 WARN, worst simd_cosine_similarity/simd/384 +378.87% (CI [+371.58%, +386.27%]).
  • 42 co-reported "confirmed improvements" from the same zero-diff comparison.

Since BASE and HEAD are the byte-identical commit, all 56 "regressions" are instrument artifacts. For reference, a real PR (#713, whose diff is entirely #[cfg(feature = "bench-internals")]-gated and cannot affect these benches) reported fewer — 35 FAIL — i.e. a genuine no-op change scores better than the tool comparing main to itself.

Impact

bench-compare output is currently uninterpretable as a perf gate on this machine: the false-positive floor (56 FAIL from nothing) swamps any real signal. Every perf PR that pastes bench-compare output is affected, and reviewers cannot distinguish real regressions from thermal noise.

Fix directions

  1. Interleave the two refs at the per-group level (A/B/A/B) instead of all-BASE-then-all-HEAD, so thermal drift lands symmetrically (this is the same mitigation the GDN perf(inference): chunked GDN prefill scan (B=64 to 128, simdgroup_matrix) #175 harness adopted with its --interleaved mode).
  2. Insert a cooldown between the BASE and HEAD halves and/or a longer warmup on the second half.
  3. Randomize/alternate which ref runs first and report order-sensitivity.

Until fixed, treat bench-compare deltas as advisory only; disprove any flagged regression with a same-ref null A/B or a same-binary re-run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions