Skip to content

fix(run_stats): normalize through int64_t microseconds in timeval_factorial_average (#463) - #465

Merged
fcostaoliveira merged 1 commit into
masterfrom
fix/issue-463-timeval-precision
Jun 9, 2026
Merged

fcostaoliveira merged 1 commit into
masterfrom
fix/issue-463-timeval-precision

Conversation

@fcostaoliveira

@fcostaoliveira fcostaoliveira commented Jun 9, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #463.

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, causing run_stats::summarize() to emit Ops/sec = 0 (and Hits/sec, KB/sec, …) even when Count > 0 and Avg Latency > 0.

This regression surfaced in two CI tests:

  • test_monitor_cluster_backpressure:test_monitor_cluster_completes_and_routes (worked around in commit 1033e0d by bumping requests)
  • test_miss_rate_tracking:test_json_totals_hits_sec_consistent (coverage-ubuntu fail on master 36f878e)

Fix: normalize both timevals to int64_t microseconds, average via integer math, then split back. No precision loss for any aggregate duration > 0 µs.

The round-40 test workaround (requests=4000) can be reverted in a follow-up once this lands.

🤖 Generated with Claude Code


Note

Low Risk
Single helper used when merging run timings; localized stats math fix with no auth or I/O behavior changes.

Overview
Fixes #463 by changing how merged benchmark runs compute averaged start/end times when multiple clients’ run_stats are combined.

timeval_factorial_average no longer averages tv_sec and tv_usec separately with doubles and truncation. It now converts each timeval to total microseconds (int64_t), applies the weighted average in integer math, then splits back into tv_sec / tv_usec. That avoids sub‑millisecond merged durations rounding to 0 µs, which made run_stats::summarize() report Ops/sec, Hits/sec, and KB/sec as 0 despite Count > 0 and positive average latency (notably in multi-client / CI scenarios).

Reviewed by Cursor Bugbot for commit afb1485. Bugbot is set up for automated code reviews on this repo. Configure here.

…torial_average (#463)

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]>
@jit-ci

jit-ci Bot commented Jun 9, 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 b4b18c0 into master Jun 9, 2026
117 checks passed
fcostaoliveira added a commit that referenced this pull request Jul 1, 2026
…torial_average (#463) (#465) (#503)

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.


(cherry picked from commit b4b18c0)

Co-authored-by: Claude Sonnet 4.6 <[email protected]>
@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.

run_stats: timeval_factorial_average loses precision below 1ms aggregate duration

1 participant