Implement round-robin timing strategy to reduce benchmark noise - #110
Merged
Conversation
Replace back-to-back timing trials with round-robin rounds that spread measurements across time. In each round, every expression is recompiled and timed once; between rounds, significant wall time passes (processing all other expressions), so a VM/container scheduling hiccup affects at most one round per expression instead of all trials. The minimum across rounds is taken as the result since noise only adds latency, never removes it -- the fastest observed run is closest to the true execution time. Adaptive round count: 7 rounds for <1000 iterations, 5 for 1000-9999, 3 for >=10000. Verified across 3 concurrent runs at 500 iterations: - 0 expressions with >2x jitter (was 85 at 50 iterations with old method) - Median coefficient of variation: 0.0% - Total eval times within 1% across runs https://claude.ai/code/session_01S5ELKkY3xhYFDE3En7yAkQ
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Summary
Refactored the benchmark timing methodology to use a round-robin strategy instead of back-to-back timing trials. This reduces the impact of VM/container scheduling hiccups and other transient noise on benchmark results by spreading measurements across multiple rounds and taking the minimum observed time.
Key Changes
Replaced median-based timing with round-robin minimum: Instead of running multiple consecutive trials for each expression and taking the median, the new approach runs one timing trial per expression per round, then takes the minimum across all rounds. This ensures that transient noise (which only adds latency) doesn't inflate results.
Adaptive round count: Changed from a fixed
timing_trialsvariable tonum_roundsthat adapts based on iteration count:Restructured benchmark into three phases:
Separated timing collection: Timing is now collected in dedicated phases after all compilation and correctness checks, improving code clarity and reducing variable state management.
Updated progress output: Added round count to the final progress message for transparency.
Implementation Details
round_timingsandnative_round_timings) indexed by expression, with each inner vector containing one sample per round.std::min_element, which is theoretically sound since noise only adds latency, never removes it.https://claude.ai/code/session_01S5ELKkY3xhYFDE3En7yAkQ