roadmap BUILT

300. Decompose the icount baseline drift, and re-baseline only what is proven

Re-saving a baseline commits a new performance floor, which is an architect's call like any baseline save; this milestone was briefed with that latitude and executes Decision 1 of the finding below. Decision 2 stays open for calef as the follow-on.

The drift is a removable regression, not an intended feature cost: milestone 237 (the cycle-counter grant) ships the grant OFF. The cost was an un-#[cfg]'d switch tuple, the same class milestone 299 (the x86 port-range capability) fixed for the port grant. It is fixed, the recovery confirmed on both ISAs by measurement, and the baselines are saved against the recovered numbers. The decomposition (QEMU ~0, toolchain ~0, code is the whole move, bisected to 57399c34) is in "What the decomposition found" below.

This milestone promotes and carries the proposal "the icount baselines predate the pinned nightly" (surfaced by milestone 299's lane, PR #883). The finding, verbatim, then what the decomposition found, which corrected the finding's own hypothesis.

The finding, as surfaced

bench/baseline-{aarch64,riscv64,x86_64}.txt are the icount regression tripwire's committed floors. The aarch64 and riscv64 baselines were last saved 2026-08-27 (a79fdb95). Over the following ~19 nightly bumps and ~150 commits, all individually under the 10% tripwire, main drifted to ~+6.5% over those two baselines on the switch-heavy benchmarks. The tripwire fires at +10%, so most of the headroom was spent, and the next unrelated change adding a few percent would trip the gate for a reason that is not its own. The proposal read this as the pinned nightly's codegen (PR #880 bumped to nightly-2026-09-15 changing only rust-toolchain.toml, without re-saving the baselines a new nightly's codegen was assumed to invalidate) and asked for two things:

  1. Re-measure and re-save the baselines on the new nightly (the decision, a new floor committed).
  2. Make a toolchain bump re-baseline in the same PR, or fail loudly, so this stops being found by accident.

What the decomposition found

The premise in (1) that the drift was the nightly's codegen turned out to be false, and proving it was the point. Holding QEMU at 11.1.1 and measuring a 2x2x2 grid of {baseline code, HEAD code} x {nightly-08-27, nightly-09-15}, plus the QEMU term (the dev Mac moved 11.0.2 -> 11.1.1 on 2026-08-28, after the baseline was saved), splits the drift into three:

git bisect pinned the code component to one commit: 57399c34 (2026-09-02), "sched: write the cycle-counter grant at the context switch", milestone 139 / DECISIONS 139 option 4. It adds a per-context-switch grant write: yield_switch and ctx_switch move by the identical +43.3 ticks/switch, and every IPC benchmark moves in proportion to its switch count, while pure compute (coremark) and the no-switch map primitives do not move. Milestone 299's 44890a8a later trimmed the aarch64/riscv peak to the net ~+35.7 ticks/switch at HEAD.

The bisect pinned the cost to 139, and it is not intended feature work. Milestone 237 (the cycle-counter grant) makes the cycle-counter grant a measurement-only feature that ships OFF: set_cycle_counter_grant is #[cfg(any(test, feature = "cycle_counter_grant"))] and does not appear in a feature-off binary at all. So the cost 139 introduced was not paying for a shipping feature. It was a residual 237's gating left behind, the const-false next_cycle_counter element still threaded through the shared switch tuple. (A #[cfg] is not allowed on a tuple element, which is why 237 reached for a fold instead.) That fold works in the release build but NOT in the debug build the icount gate measures, so the read, the tuple element, and a gated-off install call all stayed in the shipping switch. This is the exact class milestone 299 (the x86 port-range capability) fixed for the port grant. The fix is 299's: carry the grant in a #[cfg]-gated local read and installed at the switch site, keep the tuple at its pre-139 width. Recovered, measured on both ISAs (inflated floor -> fix, near pre-139): yield_switch 1167649->1101149 aarch64 / 195910->184875 riscv64, ctx_switch 3089320->2922971 aarch64 / 522565->495050 riscv64, ~91-93% of the drift. The ~0.5% residual is within the codegen noise floor coremark sits in (it stayed flat, 20915884->20915599 aarch64). The baselines are saved on nightly-2026-09-15 against these recovered numbers. The full per-benchmark grid, the bisect, the recovery table, and the standing "save from the shipping feature set" rule live in notes/benchmarks/drift-decomposition.md under the 2026-09-15 heading.

x86_64 is affected too. The residual was the shared switch tuple, not an aarch64/riscv-only path, so the x86 debug icount build carried the const-false element too and paid for it: the fix recovers yield_switch 20080160->18903108 (~5.9%) and tss_iomap_switch 24818161->23661444 (~4.7%), with coremark flat (306262395->306261408). bench --x86 --check passed against the inflated floor only because the residual sits under the 10% tripwire. Leaving that floor ~5.9% high would bake in exactly the removable regression this milestone removes, so x86_64's baseline is re-saved against its recovered numbers as well.

What was built

Follow-on

BUGS

Index row

Decomposed the ~+6.5% icount drift over the 2026-08-27 baselines into QEMU (~0), toolchain (~0), and code components, refuting the proposal's nightly-codegen hypothesis. The whole move bisected to one commit, milestone 139 (drive the unsafe count down)'s cycle-counter grant at the context switch (57399c34). The cost is not an intended feature cost: the grant ships OFF since milestone 237. The cost was a removable residual, the const-false switch-tuple element 237's fold did not eliminate in the debug icount build, the same class milestone 299 fixed for the port grant. Applied 299's #[cfg]-gated fix, recovered ~91-93% of the drift on aarch64/riscv64 (yield_switch/ctx_switch back within ~0.5% of pre-139) and ~5.9% on x86_64 (the tuple is shared across ISAs), and re-saved all three baselines against the recovered numbers. Decision 2 (a toolchain bump must re-baseline or fail loudly) left open as the follow-on.