Skip to content

fix(bench): grade cache and branch behaviour on layout-stable counters - #240

Merged
blackopsrepl merged 1 commit into
mainfrom
fix/layout-sampled-simulation
Nov 10, 2026
Merged

blackopsrepl merged 1 commit into
mainfrom
fix/layout-sampled-simulation

Conversation

@blackopsrepl

Copy link
Copy Markdown
Collaborator

Closes #239.

Evidence:

  • Identical v0.25.1 source, 10 builds differing only in -C metadata: simulated instructions/D1/LL misses spread <=0.3% (construction_first_fit D1 5.9%); simulated I1 misses up to 133%, indirect mispredicts up to 475%, conditional mispredicts up to 19%. list_change indirect mispredicts 970 -> 859k between v0.25.1 and fix: core generic types make debug type names grow to megabytes #238 with equal instruction counts (hardware branch-misses +0.08%).
  • Hardware branch-misses baseline IQR 0.04-2.2% across all 13 cases (085fc927 vs v0.25.1 run); cartesian A/A within 0.6%.
  • Planted regression (300-step black_box loop in list_kernel/change.rs next_move, BASELINE=HEAD, list_change, default trials, isolated): gate exit 1 with instructions +39.0%, sim_instructions +38.5%, wall +21.2%, branch-misses +811%, semantics matched.

Budget (5%), pass rule, exact allocation checks, wall and instruction grading unchanged.

Cachegrind's simulated caches and branch predictor repeat exactly for one
binary but index by code address, so they move when the linker places
functions differently, and placement follows symbol hashes. Rebuilding
v0.25.1 with only -C metadata changed moved list_change's simulated branch
mispredictions by +6.8% with identical instructions; across ten such
layouts simulated instruction-L1 misses moved by up to 133% and indirect
mispredictions by up to 475%, and an edit inside one function turned 970
indirect mispredictions into 859k with equal instruction counts, while the
hardware branch-misses counter on the same runs moved under 0.1%.

Each side is now built in SIM_LAYOUTS (default 5) layouts that differ only
in -C metadata, and each simulated metric is taken as its median across
them (layout 0 is the timed binary; every layout's count is reported).
Simulated instructions, data-L1 misses and last-level misses, stable across
layouts, are graded on the unchanged 5% budget. Simulated instruction-L1
misses and branch mispredictions become report-only, and branch behaviour
is graded on the hardware branch-misses median instead (baseline
interquartile range 0.04-2.2% on the isolated CPU). Simulations run
SIM_JOBS at a time before the timed trials; simulated counts do not depend
on load.

Closes #239
@blackopsrepl
blackopsrepl merged commit ab2e99e into main Nov 10, 2026
7 checks passed
@blackopsrepl
blackopsrepl deleted the fix/layout-sampled-simulation branch November 10, 2026 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(bench): grade simulated cache and branch counters across code layouts

1 participant