Repository navigation
fix(bench): interleave baseline and current samples - #415
Merged
Merged
Conversation
The gate ran every benchmark for the PR code, then every benchmark for the base code. Two contiguous blocks means two separate time windows, so anything that changed the runner between them (cold caches, CPU frequency ramp, a noisy neighbour) shifted one whole block at once. benchstat read that as a large, uniform, statistically significant regression across entire packages, including packages the PR could not reach. Tight variance and a small p-value did not rule this out. Same-runner comparison controls for runner-to-runner variance, not for one runner drifting over time. Three PRs showed it: #411 (deps only) failed on filetree on linux and crashlog on macOS; #413 (one _test.go file in internal/github) and #414 (one file in cmd/) both failed on macOS blaming internal/ai and internal/config. The same code passed on main after merge. A local benchstat A/B on #411 showed the flagged benchmark 9.77% faster, not slower. scripts/bench-interleaved.sh compiles both versions up front, then alternates between them one round at a time, so both are sampled across the same window and drift applies equally. The version that runs first alternates each round so neither absorbs any per-round warm-up cost. Total benchmark time is unchanged. The PR comment now lists which benchmarks were flagged and how to confirm locally, so a false positive is diagnosable without downloading artifacts. Closes #412 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 98ae0c9c-bdbe-418e-8488-15082edca7dc
Contributor
Benchmarks:
|
Contributor
Benchmarks:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #412
Problem
The gate ran every benchmark for the PR code, then every benchmark for the base code. Two contiguous blocks means two separate time windows, so anything that changed the runner between them (cold caches, CPU frequency ramp, a noisy neighbour on a shared VM) shifted one whole block at once. benchstat read that as a large, uniform, statistically significant regression across entire packages, including packages the PR could not reach.
Tight variance and a small p-value did not rule this out. Same-runner comparison controls for runner-to-runner variance, but not for one runner drifting over time.
Three PRs demonstrated it:
go.mod,go.sumfiletree)crashlog)_test.goininternal/githubai,config)cmd/theme.goai,config)All three passed every
testjob on all three platforms, and the same code passed on main after merge. A local benchstat A/B on #411 showed the flagged benchmark 9.77% faster, not slower.Fix
scripts/bench-interleaved.shcompiles both versions up front, then alternates between them one round at a time. Both versions are sampled across the same window, so drift applies to both equally and cancels in the comparison.The version that runs first alternates each round, so neither systematically absorbs any per-round warm-up cost.
Total benchmark time is unchanged: 6 rounds of
-count=1costs the same as one-count=6. The extra process launches add roughly a second.The PR comment now lists which benchmarks were flagged and how to confirm locally, so a future false positive is diagnosable without downloading artifacts (third acceptance criterion in #412).
Verification
Compiled test binaries and benchstat behaviour were checked before writing the script:
go test -cbinary emits the fullgoos/goarch/pkg/cpuheader from any working directorynBENCH_PKGSdepends ontestdataor its source directory at runtimeThe shell logic was exercised in an isolated scratch repo with a stubbed
go, confirming:Also
bash -nclean,go build ./...,go vet ./...,gofmt -lclean, andgo test ./...green.Note
This PR is its own test. The bench jobs here run through the new interleaved path on both runners.
Acceptance criteria
bench-regress.shlogic unchanged)