Repository navigation
Fix AGGREGATED Totals KB/sec RX/TX always 0.0 in JSON with --run-count (#577) - #581
Conversation
With --run-count > 1 the AGGREGATED AVERAGE Totals "KB/sec RX" and "KB/sec TX" JSON fields were always 0.0. totals::add() did not accumulate m_bytes_sec_rx/m_bytes_sec_tx, run_stats::aggregate_average() did not divide them by the run count, and the totals constructor left them uninitialized (so the printed value was strictly indeterminate). Initialize, accumulate and average them like m_bytes_sec, matching what totals_cmd already does for the per-command rows. Extend test_json_output_integrity.py: the AGGREGATED Totals RX/TX must equal the sum of the per-command rows, add up to KB/sec, and equal the mean of the two runs with --run-count=2. Fixes #577 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Widen the #577 fix to the same bug class: totals::add() sums m_connection_errors_sec across runs, but run_stats::aggregate_average() never divided it, so the AGGREGATED "Connection Errors/sec" was the sum of the per-run rates instead of their mean. Divide it alongside the RX/TX rates. Make the tests discriminate the run-count divisor: - test_json_aggregated_totals_rx_tx now uses --run-count=3 on 2 threads with --print-all-runs, and checks each AGGREGATED Totals rate against the mean of the RUN #i sections instead of BEST/WORST. A divisor of a literal 2 or of the thread count no longer passes. It also asserts Connection Errors/sec stays 0 when no connection breaks. - test_json_arbitrary_commands_totals_bandwidth uses the same per-run mean check. - New test_json_aggregated_connection_errors_sec kills memtier's connections every 0.25s during 3 x 2s runs (--reconnect-on-error) and checks the AGGREGATED Connection Errors/sec is the per-run mean. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🤖 Automated first-pass review — a human maintainer's review is still required before merge. Thanks for this. The C++ change looks right to me. One question about Nitpicking: Otherwise this looks good to me. |
|
Thanks for the review. Answers to both points: 1. Can
Why a kill during connection setup or the slot-map fetch shouldn't fail the run: with 2. Release notes: I added a "Release notes" section to the PR description. It says that the AGGREGATED 🤖 Generated with Claude Code |
Problem
With
--run-count> 1, theAGGREGATED AVERAGE RESULTS→Totalssection of the JSON output always reports"KB/sec RX": 0.0and"KB/sec TX": 0.0, for every workload (default SET/GET and--commandmode). The combinedKB/sec, the per-command rows and the BEST/WORST sections are correct. The text table only prints the combinedKB/sec, so only the JSON is wrong."Connection Errors/sec"in the same section has a related bug. It reports the sum of the per-run rates rather than their mean. One reviewer measured BEST 1.86, WORST 1.9 and AGGREGATED 3.76 with--reconnect-on-errorwhile connections were being killed.Root cause
20c013d (#246) added
m_bytes_sec_rx/m_bytes_sec_txto bothtotals_cmdandtotals. It wired them intototals_cmd::add()/aggregate_average(), but not into the run-leveltotals:totals::totals()constructor never initializes the two fields.totals::add()addsm_bytes_secbut not the RX/TX fields.run_stats::aggregate_average()dividesm_bytes_secby the run count but not the RX/TX fields.print()callssummarize()only whenm_statsis non-empty. The AVERAGE object has no per-second stats, so that call is skipped and nothing overwrites the value. In practice it came out as 0.0, but strictly it was indeterminate.m_connection_errors_secis in the same position:totals::add()sums it, butrun_stats::aggregate_average()never divides it.Fix
m_bytes_sec_rx/m_bytes_sec_txexactly likem_bytes_sec, astotals_cmdalready does.m_totals.m_connection_errors_secby the run count alongside them.That adds 7 lines in
run_stats_types.cppandrun_stats.cpp.I audited the other fields as well:
totals_cmd(Sets/Gets/Waits/arbitrary commands, viaar_totals_cmd) already initializes, adds and averages both RX/TX rates.m_bytes_rx/m_bytes_txandm_connection_errorscounters are summed across runs on purpose. They are cumulative, likeCount.run_stats::summarize(), the BEST/WORST/single-run path, computes the rates directly from the per-second stats.The only gaps in the run-level
totalswere the three RX/TX ones above andm_connection_errors_sec.Tests
All tests are in
tests/test_json_output_integrity.py.test_json_aggregated_totals_rx_tx(new) runs--run-count=3 --print-all-runson 2 threads. The run count, the thread count and the literal 2 all differ, so a wrong divisor can't pass. It checks these AGGREGATED Totals values:KB/sec.KB/sec, RX and TX each equal the mean of theRUN #i RESULTSsections.Connection Errors/secis 0 when no connection breaks.test_json_aggregated_connection_errors_sec(new) runs 3 × 2 s with--reconnect-on-errorwhile a thread runsCLIENT KILL TYPE normal SKIPME yesevery 0.25 s. It asserts that connection errors happened, and that the AGGREGATEDConnection Errors/secequals the mean of the per-run values.test_json_arbitrary_commands_totals_bandwidth(#566) now checks RX/TX in the AGGREGATED section too, using the same per-run mean check. Before this fix it had to skip them.Before:
2, the 3-run test fails:After:
test_json_output_integrity.pypasses 12/12, three times in a row.Manual repro (
-t 1 -c 2 -n 5000 --run-count 3, local redis), TotalsKB/sec / RX / TX:Release notes
With
--run-count> 1, the JSONAGGREGATED AVERAGE RESULTS→Totalssection changes in two ways:KB/sec RX/KB/sec TXnow report the per-run average. Before, they were always0.0.Connection Errors/secis now the mean of the per-run rates. Before, it was their sum, so older JSON overstates it by a factor of the run count. TheConnection Errorscount is still the total across runs, unchanged.Fixes #577
Affected versions
2.1.0–2.5.2 and master (introduced by 20c013d / #246).
🤖 Generated with Claude Code