Skip to content

bench(alias): use BatchSize::PerIteration for cold-cache variants - #2731

Merged
max-sixty merged 1 commit into
mainfrom
bench-cold-per-iteration
May 12, 2026
Merged

max-sixty merged 1 commit into
mainfrom
bench-cold-per-iteration

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Summary

Follow-up to #2728. benches/alias.rs was the last iter_batched(invalidate_caches_auto, …, BatchSize::SmallInput) site in the bench suite. Under SmallInput, criterion calls the setup closure once per batch and times the routines back-to-back inside one timing window — so only iter 1 per batch is actually cold, and iters 2-N hit the worktrunk.default-branch git-config entry that build_hook_context wrote on iter 1 (default-branch resolution is ~17ms on a synthetic repo per benches/CLAUDE.md). BatchSize::PerIteration runs setup → time(routine) per iter, so every measurement is genuinely cold.

Measurement

dispatch/cold/1 (stub alias, 1 worktree):

Before After
Median 23.14 ms 23.94 ms
Range [22.34, 24.01] [22.91, 25.03]

Median +6.9% (p=0.05, "Change within noise threshold"). The correction is small — alias dispatch is cheap (~23ms) and only the default-branch cache is being repopulated, so each warm iter saved ~1ms — but the direction is right and it brings the bench in line with the rest of the suite (#2728) and the benches/CLAUDE.md "Cache Handling" guidance.

Test plan

  • cargo run -- hook pre-merge --yes — 3684 tests pass, 0 failed
  • dispatch/cold/1 run before+after on this branch with --save-baseline / --baseline

Follow-up to #2728: the `dispatch/cold/{1,100}` and
`with_vars/cold/{1,100}` variants in `benches/alias.rs` were the last
`iter_batched(invalidate_caches_auto, …, BatchSize::SmallInput)` site
left in the suite. Under `SmallInput`, criterion calls the setup
closure once per batch and times the routines back-to-back, so only
iter 1 per batch is actually cold — iters 2-N hit the
`worktrunk.default-branch` git-config entry that `build_hook_context`
wrote on iter 1 (default-branch resolution is ~17ms on a synthetic
repo). `PerIteration` runs `setup → time(routine)` per iter, so every
measurement is genuinely cold.

Measured on `dispatch/cold/1` (stub alias, 1 worktree): median
23.1ms → 23.9ms (+6.9%, within noise threshold). The correction is
small here — alias dispatch is cheap (~23ms) and only the
default-branch cache is being repopulated — but the direction is
right and it brings the bench in line with the rest of the suite and
the `benches/CLAUDE.md` "Cache Handling" guidance.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 50a3020 into main May 12, 2026
33 checks passed
@max-sixty
max-sixty deleted the bench-cold-per-iteration branch May 12, 2026 01:42
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.

2 participants