Repository navigation
Fix doubled Totals KB/sec with arbitrary commands - #573
Merged
Merged
Conversation
run_stats::summarize() added ar_one_sec_cmd_stats::bytes(), which is already rx + tx, to both the Totals RX and TX byte counters. In --command mode the Totals KB/sec was therefore twice the sum of the per-command rows, and the Totals RX/TX split was wrong in the text, JSON and CSV outputs (including the --run-count BEST/WORST/AGGREGATED sections). Split bytes() into bytes_rx() and bytes_tx() so each direction only counts its own bytes, like SET/GET already do. Introduced in 20c013d (#246). Fixes #566 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 13, 2026
Collaborator
Author
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
In arbitrary-command mode (
--command=...), the Totals row's KB/sec is about twice the sum of the per-command rows. For example, with--command "SET __key__ __data__" --command "GET __key__" --run-count 2, the rows are 3009.17 + 1520.75 KB/sec but Totals shows 9059.85. The TotalsKB/sec RX/KB/sec TXsplit is also wrong: both directions are set to the same, inflated value. This affects the text table, the JSON, and the CSV output, for single runs and for the--run-countBEST/WORST/AGGREGATED sections.Root cause
run_stats::summarize()addsm_ar_commands.bytes()to bothresult.m_bytes_rxandresult.m_bytes_tx. Butar_one_sec_cmd_stats::bytes()already returns rx + tx for every command. Totals KB/sec is computed from rx + tx, so the arbitrary-command bytes are counted twice. SET and GET are not affected, because they already add rx and tx separately. The bug came in with 20c013d (#246), which splitm_bytesinto_rxand_tx.Fix
Replace
ar_one_sec_cmd_stats::bytes()withbytes_rx()andbytes_tx().bytes()has no other caller. Each Totals direction now sums only its own bytes, the same way the SET/GET terms do.Test
The new test
test_json_output_integrity.py:test_json_arbitrary_commands_totals_bandwidthruns SET + GET--commands with--run-count=2. It asserts that TotalsKB/sec,KB/sec RXandKB/sec TXequal the sum of the per-command rows (within %.2f rounding) in BEST and WORST. In AGGREGATED it checks onlyKB/sec, because the aggregated Totals RX/TX are a separate pre-existing problem (see below).BEST RUN RESULTS: Totals 'KB/sec' (41053.59) != sum of ['Sets', 'Gets'] (20526.79), RX 20526.79 vs 15670.36, TX 20526.79 vs 4856.45. WORST shows the same, and AGGREGATED shows 36322.09 vs 18161.05.test_json_output_integrity.py(10/10).Note: separate pre-existing issue, not fixed here
In the
--run-countAGGREGATED AVERAGE section, TotalsKB/sec RXandKB/sec TXare always0.0.totals::add()does not accumulatem_bytes_sec_rx/_tx, andrun_stats::aggregate_average()does not average them. This happens for all workloads, not only--command. I left it out of this PR to keep the diff small.Fixes #566
Affected versions: 2.1.0 through 2.5.2, and master. Introduced by 20c013d (#246).
🤖 Generated with Claude Code
Note
Low Risk
Narrow stats aggregation fix for arbitrary-command mode with a targeted regression test; no auth, I/O protocol, or runtime behavior changes beyond reported bandwidth totals.
Overview
Fixes #566: in
--commandmode, Totals bandwidth in JSON/text/CSV was roughly double the sum of per-command rows because arbitrary-command bytes were counted twice in RX and TX.ar_one_sec_cmd_statsno longer exposes a singlebytes()that summed RX+TX for every command. It now hasbytes_rx()andbytes_tx(), andrun_stats::summarize()adds those separately intoresult.m_bytes_rx/result.m_bytes_tx—matching how SET/GET totals are built.A regression test in
test_json_output_integrity.pyruns SET+GET arbitrary commands with--run-count=2and checks that TotalsKB/sec(and RX/TX in BEST/WORST) equals the sum of per-command rows within rounding slack.Reviewed by Cursor Bugbot for commit 664fa79. Bugbot is set up for automated code reviews on this repo. Configure here.