Skip to content

Use 64-bit hit, miss, MOVED and ASK counters in one_sec_cmd_stats - #659

Merged
fcostaoliveira merged 1 commit into
masterfrom
fix-642-hits-misses-64bit
Oct 15, 2026
Merged

fcostaoliveira merged 1 commit into
masterfrom
fix-642-hits-misses-64bit

Conversation

@fcostaoliveira

@fcostaoliveira fcostaoliveira commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

The run summary reports Hits/sec, Misses/sec, MOVED/sec and ASK/sec from whole-run totals held in unsigned int. After 4,294,967,296 GET hits, misses, MOVED or ASK replies in one run (about 72 minutes at 1M GET hits/sec), the counter wraps and the reported rate is silently far too low, in both the text table (Gets/Totals rows) and the JSON output.

Root cause

run_stats::summarize() merges every per-second one_second_stats into one one_second_stats totals(0) via one_sec_cmd_stats::merge(), so one_sec_cmd_stats doubles as the whole-run accumulator. m_ops, m_bytes_rx/tx and m_total_latency are unsigned long long, but m_hits, m_misses, m_moved and m_ask were unsigned int. The wrapped sums feed m_hits_sec / m_misses_sec / m_moved_sec / m_ask_sec in run_stats::summarize() and totals_cmd::summarize().

Fix

  • run_stats_types.h: widen m_hits, m_misses, m_moved, m_ask to unsigned long long int, like m_ops.
  • run_stats.cpp: update the three printf consumers (per-second CSV, per-second cluster CSV, debug dump) from %u to %llu.

No other consumers: JSON/text use the derived double rates, and totals::m_hits/m_misses and m_arbitrary_misses were already 64-bit. Nothing serializes the struct as binary. gcc and clang -Wall -Wformat=2 are clean on the touched files.

Test evidence

New unit test tests/unit/run_stats_counters_test.cpp (wired into make check like hdr_histogram_test, coverage runtime linked through $(CODE_COVERAGE_LDFLAGS)). It sums 5000 seconds x 1e6 hits/misses/MOVED/ASK (5e9 > 2^32) through one_second_stats::merge(), checks the totals and the MOVED/sec and ASK/sec from totals_cmd::summarize(), and checks that update_op() carries past 2^32.

  • origin/master (fix reverted, test kept): 5/5 runs fail, 10 checks fail each time (totals.m_get_cmd.m_hits == expected, ..., result.m_moved_sec == per_second, stats.m_hits == 4294967296ULL).
  • This branch: 5/5 runs pass. make check: 7/7 PASS.
  • Short live run against a local redis: Gets/Totals rows and JSON Hits/sec/Misses/sec unchanged in shape and values.

Fixes #642

Affected versions

1.0.0 through 2.5.2 (latest) and master.

  • Introduced by 833a8df "First memtier_benchmark version" (unsigned int m_get_hits, all seconds merged into one one_second_stats in summarize()); 58a1bdb "Stats restructure and reorganization (Stats restructure and reorganization #66)" (first tag 1.2.16) moved the fields into one_sec_cmd_stats and kept them unsigned int.
  • Confirmed by running: master, via the unit test above (a live run needs > 4.29e9 events).
  • Derived from history: all releases 1.0.0–2.5.2 (2.5.2 run_stats_types.h:83-86 still declares them unsigned int).

🤖 Generated with Claude Code


Note

Low Risk
Narrow stats-type and printf changes with a dedicated unit test; reported rates and CSV columns stay the same except correctness above 4B events.

Overview
Fixes silent under-reporting of Hits/sec, Misses/sec, MOVED/sec, and ASK/sec on long or high-throughput runs when whole-run totals exceed 2³² events (issue #642).

one_sec_cmd_stats widens m_hits, m_misses, m_moved, and m_ask from unsigned int to unsigned long long, matching m_ops and the merge path used by run_stats::summarize(). run_stats.cpp updates per-second CSV, cluster CSV, and debug logging to print those fields with %llu.

Adds run_stats_counters_test to make check, merging 5×10⁹ counter events and asserting update_op() increments past UINT_MAX.

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

run_stats::summarize() merges every per-second one_second_stats of a run
into one one_second_stats, so one_sec_cmd_stats also serves as the
whole-run accumulator. m_ops, the byte counters and m_total_latency are
unsigned long long, but m_hits, m_misses, m_moved and m_ask were
unsigned int. After 2^32 GET hits, misses, MOVED or ASK replies in one
run the sums wrapped, and the reported Hits/sec, Misses/sec, MOVED/sec
and ASK/sec (text table and JSON) came out far too low.

Widen the four fields to unsigned long long and switch the per-second
CSV and debug printf formats from %u to %llu. Add a unit test that sums
5e9 events through one_second_stats::merge() and totals_cmd::summarize();
it fails on master and passes with this change.

Fixes #642

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

Whole-run Hits/sec, Misses/sec, MOVED/sec and ASK/sec wrap after 2^32 events: 32-bit counters in one_sec_cmd_stats are summed across the run

1 participant