Repository navigation
Fix BEST/WORST RUN RESULTS always showing run #1 with --run-count - #571
Merged
Merged
Conversation
The per-run run_stats are built with merge(), which never set m_started. Since 0228bac (#350), get_duration_usec() returns 0 until m_started is set, so every run's duration was 0, the ops/sec divisor fell back to 1 and the (int) cast overflowed to the same value for every run. Run #1 then won both the best and the worst comparison. Set m_started in merge() when a started run is merged in, and compare runs by a double ops/sec instead of an int-cast value. Fixes #565 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 13, 2026
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
With
--run-count N, BEST RUN RESULTS and WORST RUN RESULTS always show run #1, even when the runs differ clearly:Root cause
The per-run
run_statsobjects returned byrun_benchmark()are built byclient_group::merge_run_stats()viarun_stats::merge().merge()averagesm_start_time/m_end_timebut never setsm_started. Since #350 (0228bac),get_duration_usec()returns 0 whilem_startedis unset. The selection loop's divisor therefore fell back to 1, and(int)(ops * 1000000)overflowed to the same value for every run, so run #1 won both comparisons.m_totals.m_opswas correct all along; the printed Ops/sec column was right becausesummarize()usests_diff(m_start_time, m_end_time)directly.Fix
run_stats::merge(): setm_startedonce a started run is merged in (merge_run_stats()only merges started clients), soget_duration_usec()works on merged stats.doubleops/sec rather than an(int)-cast value, and uses 0 for a zero-duration run instead of dividing by 1.Test
Added
test_run_count_best_worst_selectiontotests/test_cli_validation_run_count.py. It runs--run-count=3 --print-all-runsand checks that BEST'sTotals.Ops/secequals the maximum per-run value and WORST's equals the minimum.53037.03 == 86452.84and53037.03 == 21262.8for per-run Ops/sec[53037.03, 86452.84, 21262.8].The test can only pass on unfixed code if run #1 is both the fastest and the slowest run, which means all three runs would have to report identical Ops/sec.
Fixes #565
Affected versions: 2.3.0 through 2.5.2 and master. Introduced by 0228bac ("Add client staircase ramp-up for incremental connection growth", #350).
🤖 Generated with Claude Code
Note
Low Risk
Localized fix to multi-run reporting and stats merge; no auth or data-path changes, with a targeted regression test.
Overview
Fixes BEST/WORST RUN RESULTS always picking run #1 when using
--run-count.Merged per-run stats now set
m_startedinrun_stats::merge()soget_duration_usec()returns a real duration instead of 0 (which made every run look equally fast/slow). The best/worst selection loop now comparesdoubleOps/sec and treats zero duration as 0 ops/sec instead of dividing by 1 and overflowing anintcast.Adds
test_run_count_best_worst_selectionto assert BEST/WORSTTotals.Ops/secmatch the max/min acrossRUN #N RESULTSfor--run-count=3 --print-all-runs.Reviewed by Cursor Bugbot for commit fdbcf2d. Bugbot is set up for automated code reviews on this repo. Configure here.