Repository navigation
fix(run_stats): normalize through int64_t microseconds (backport #463/#465 to 2.4) - #503
Merged
Merged
Conversation
…torial_average (#463) (#465) run_stats::timeval_factorial_average averaged tv_sec and tv_usec independently with double->time_t/suseconds_t truncation. For aggregate durations < ~1ms across multiple clients, the diff could round to 0 us, causing run_stats::summarize() to emit Ops/sec = 0 (and Hits/sec, KB/sec, ...) even when Count > 0 and Avg Latency > 0. Normalize both timevals to int64_t microseconds, average via integer math, then split back. No precision loss for any aggregate duration > 0 us. Co-authored-by: Claude Sonnet 4.6 <[email protected]> (cherry picked from commit b4b18c0)
🛡️ Jit Security Scan Results✅ No security findings were detected in this PR
Security scan by Jit
|
Merged
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.
Backport of #463/#465 to the 2.4 release branch, for inclusion in 2.4.4.
Why
run_stats::timeval_factorial_averageaveragedtv_secandtv_usecindependently withdouble→time_t/suseconds_ttruncation. For aggregate durations < ~1ms across multiple clients, the diff could round to 0 µs, makingsummarize()report Ops/sec = 0 (and Hits/sec, KB/sec) even whenCount > 0andAvg Latency > 0. That's a user-facing results-correctness bug — exactly what a patch release should carry.Fix
Normalize both timevals to
int64_tmicroseconds, average via integer math, split back. No precision loss for any aggregate duration > 0 µs. 8-line change, cherry-picked cleanly from master (b4b18c0).Found during the 2.4.4 release-contents audit: this was the one correctness fix on
mastersince 2.4.3 that was missing from2.4and applies cleanly.🤖 Generated with Claude Code
Note
Low Risk
Small, localized change to stats aggregation math with no auth or I/O impact; intended correctness fix for reported rates.
Overview
Fixes incorrect benchmark throughput when merging stats from multiple clients/runs whose combined duration is under ~1ms.
timeval_factorial_averageno longer averagestv_secandtv_usecseparately with floating-point truncation. It now converts bothtimevals toint64_ttotal microseconds, applies the weighted average in integer math, and splits the result back intotv_sec/tv_usec. That keeps non-zero duration forrun_stats::merge()start/end times sosummarize()no longer reports Ops/sec, Hits/sec, or KB/sec as 0 while counts and latency remain positive.Reviewed by Cursor Bugbot for commit 26d6786. Bugbot is set up for automated code reviews on this repo. Configure here.