Repository navigation
fix(ts): shuffle the bench's order each round so no route keeps a slot - #39
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
…ation # Conflicts: # ts/README.md # ts/bench/time.ts
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Collaborator
Author
|
Ready to merge:
(written by Opus 5.5) |
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.
Problem
just ts benchran every round in nearly the same order: each round started one body later, but with ~180 bodies and 15 rounds every route always ran right after the same one. Identical code then timed differently by slot, and earlier A/B conclusions throughA/A(such as #24's "Bun varint decode 10-30% slower") were mostly that bias.Reproduced on main with an A/A/A run (
--route same=target/bench, sotranslated,A/A, andsameall load the same translation), 6 runs:translated÷A/A, median workload per runtranslatedis slowerIn Bun and Chrome the slots order by position:
translated>A/A>same, each identical copy faster than the one before it on the same workload.Approach
Each round runs the bodies in a new Fisher-Yates order from a seeded PRNG. The seed is random per run, recorded in
report.mdandreport.json, andbench/main.ts --seedreplays it. After the fix, 5 runs:translated÷A/A, median workload per runtranslatedis slowerA/A÷sameandtranslated÷samelook the same (45-52% slower, per-run medians within ±3.3%), so the gap is now the A/A noise floor: no sign, coin-flip direction. Host: 32 threads shared with other agents' benches, load average 12-31 throughout; runs alternated main's harness and this one.Cause, from a Bun-only harness over the three identical copies: with the copies adjacent on each workload, the earlier copy is slower (26-30 of 34 workloads); running all workloads of one copy before the next removes the bias (11-21 of 34), and so does a full
Bun.gc(true)before each sample (10-23 of 34). So a body inherits the allocator and GC state its predecessor leaves, and a fixed order hands every body the same predecessor.The README now says how to read an A/B run: its gap from
translatedagainst A/A's in the same run, with no reversed run needed.Impact
bench/main.tstakes--seed <u32>; the report records the seed. No public API change.Alternatives
Follow-ups
fixtures/bench.rs) still times its workloads in a fixed order; it has no identical-code slots to compare, so no bias was measured there.🤖 Generated with Claude Code
https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn
(written by Opus 5.5)