Skip to content

fix(run_stats): normalize through int64_t microseconds (backport #463/#465 to 2.4) - #503

Merged
fcostaoliveira merged 1 commit into
2.4from
backport/run-stats-int64-2.4
Jul 1, 2026
Merged

fcostaoliveira merged 1 commit into
2.4from
backport/run-stats-int64-2.4

Conversation

@fcostaoliveira

@fcostaoliveira fcostaoliveira commented Jul 1, 2026 •

Copy link
Copy Markdown
Collaborator

Backport of #463/#465 to the 2.4 release branch, for inclusion in 2.4.4.

Why

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 µs, making summarize() report Ops/sec = 0 (and Hits/sec, KB/sec) even when Count > 0 and Avg Latency > 0. That's a user-facing results-correctness bug — exactly what a patch release should carry.

Fix

Normalize both timevals to int64_t microseconds, 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 master since 2.4.3 that was missing from 2.4 and 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_average no longer averages tv_sec and tv_usec separately with floating-point truncation. It now converts both timevals to int64_t total microseconds, applies the weighted average in integer math, and splits the result back into tv_sec / tv_usec. That keeps non-zero duration for run_stats::merge() start/end times so summarize() 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.

…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-ci

jit-ci Bot commented Jul 1, 2026

Copy link
Copy Markdown

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

@fcostaoliveira
fcostaoliveira merged commit 405d596 into 2.4 Jul 1, 2026
64 checks passed
@fcostaoliveira
fcostaoliveira deleted the backport/run-stats-int64-2.4 branch July 1, 2026 17:13
@fcostaoliveira fcostaoliveira mentioned this pull request Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant