Repository navigation
Use 64-bit hit, miss, MOVED and ASK counters in one_sec_cmd_stats - #659
Merged
Merged
Conversation
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]>
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
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-secondone_second_statsinto oneone_second_stats totals(0)viaone_sec_cmd_stats::merge(), soone_sec_cmd_statsdoubles as the whole-run accumulator.m_ops,m_bytes_rx/txandm_total_latencyareunsigned long long, butm_hits,m_misses,m_movedandm_askwereunsigned int. The wrapped sums feedm_hits_sec/m_misses_sec/m_moved_sec/m_ask_secinrun_stats::summarize()andtotals_cmd::summarize().Fix
run_stats_types.h: widenm_hits,m_misses,m_moved,m_asktounsigned long long int, likem_ops.run_stats.cpp: update the three printf consumers (per-second CSV, per-second cluster CSV, debug dump) from%uto%llu.No other consumers: JSON/text use the derived
doublerates, andtotals::m_hits/m_missesandm_arbitrary_misseswere already 64-bit. Nothing serializes the struct as binary. gcc and clang-Wall -Wformat=2are clean on the touched files.Test evidence
New unit test
tests/unit/run_stats_counters_test.cpp(wired intomake checklikehdr_histogram_test, coverage runtime linked through$(CODE_COVERAGE_LDFLAGS)). It sums 5000 seconds x 1e6 hits/misses/MOVED/ASK (5e9 > 2^32) throughone_second_stats::merge(), checks the totals and the MOVED/sec and ASK/sec fromtotals_cmd::summarize(), and checks thatupdate_op()carries past 2^32.totals.m_get_cmd.m_hits == expected, ...,result.m_moved_sec == per_second,stats.m_hits == 4294967296ULL).make check: 7/7 PASS.Hits/sec/Misses/secunchanged in shape and values.Fixes #642
Affected versions
1.0.0 through 2.5.2 (latest) and master.
unsigned int m_get_hits, all seconds merged into oneone_second_statsinsummarize()); 58a1bdb "Stats restructure and reorganization (Stats restructure and reorganization #66)" (first tag 1.2.16) moved the fields intoone_sec_cmd_statsand kept themunsigned int.run_stats_types.h:83-86still declares themunsigned 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_statswidensm_hits,m_misses,m_moved, andm_askfromunsigned inttounsigned long long, matchingm_opsand the merge path used byrun_stats::summarize().run_stats.cppupdates per-second CSV, cluster CSV, and debug logging to print those fields with%llu.Adds
run_stats_counters_testtomake check, merging 5×10⁹ counter events and assertingupdate_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.