Repository navigation
Description
With --run-count > 1, the AGGREGATED AVERAGE RESULTS Totals row in the JSON output always reports "KB/sec RX": 0.0 and "KB/sec TX": 0.0. This happens with every workload. The combined KB/sec next to them is correct, and so are the per-command Sets/Gets/arbitrary-command RX/TX values and the BEST/WORST rows.
Reproduce:
redis-server --port 31720 --save "" &
memtier_benchmark -p 31720 -t 1 -c 2 -n 5000 --run-count 3 --hide-histogram --json-out-file out.json
Arbitrary commands behave the same (--command="SET __key__ __data__" --command="GET __key__").
What happens: on master (f33599f):
| Section | KB/sec |
KB/sec RX |
KB/sec TX |
|---|---|---|---|
| BEST RUN RESULTS Totals | 4915.97 | 565.87 | 4350.10 |
| WORST RUN RESULTS Totals | 3281.90 | 377.78 | 2904.13 |
| AGGREGATED AVERAGE Totals | 3990.15 | 0.0 | 0.0 |
| AGGREGATED AVERAGE Sets | 658.99 | 41.80 | 617.19 |
| AGGREGATED AVERAGE Gets | 3331.16 | 417.51 | 2913.66 |
With arbitrary commands: AVERAGE Totals 7340.49 / 0.0 / 0.0, while BEST is 7590.70 / 816.21 / 6774.49.
The text table only prints the combined KB/sec, which is correct. The --client-stats CSV files are per run and per client and have no AVERAGE section. So only the JSON is wrong.
Cause: run_stats::aggregate_average() builds the AVERAGE totals by calling summarize() on each run, which fills m_bytes_sec_rx/m_bytes_sec_tx, and then calling m_totals.add(i_totals). Two steps are missing:
totals::add()(run_stats_types.cpp) addsm_bytes_secbut notm_bytes_sec_rx/m_bytes_sec_tx.aggregate_average()dividesm_bytes_secby the run count (run_stats.cpp:992) but not the RX/TX fields.
Also, the totals::totals() constructor doesn't initialize m_bytes_sec_rx/m_bytes_sec_tx. The average therefore prints whatever the uninitialized value is. In practice that was 0.0 in every run, but strictly it's indeterminate. print() skips summarize() for the AVERAGE object because it has no per-second stats, so nothing overwrites the value.
The per-command totals_cmd::add()/aggregate_average() handle both fields, which is why Sets/Gets are correct.
Possible fix: initialize both fields in totals::totals(), add them in totals::add(), and divide them by all_stats.size() next to m_bytes_sec. A JSON test with --run-count 2 could check that Totals RX + TX ≈ Totals KB/sec.
Found while fixing #566 (PR #573).
Affected versions
2.1.0 through 2.5.2 (latest) and master.
- Introduced by: 20c013d, "List ingress and egress separately on JSON and CSV exports" (List ingress and egress separately on JSON and CSV exports. Include BW and also raw values per second #246, 2023). It added
m_bytes_sec_rx/m_bytes_sec_txtototalsand wired them intototals_cmd::add()/aggregate_average()but nottotals::add()orrun_stats::aggregate_average().git tag --contains 20c013d→ first tag 2.1.0. - Confirmed by running the repro above (local redis,
--run-count 3, JSON):- 2.0.0: no
KB/sec RX/TXkeys yet, so not affected. - 2.1.0: AVERAGE Totals
3734.99 / 0.0 / 0.0. - 2.5.2: AVERAGE Totals
3591.94 / 0.0 / 0.0. - master f33599f: AVERAGE Totals
3990.15 / 0.0 / 0.0.
- 2.0.0: no
- Derived from history: 2.1.1–2.4.4 and 2.5.0–2.5.1. The code is unchanged between the confirmed versions.
Activity
Average Totals Connection Errors/sec across runs; tighten #577 tests
Average Totals Connection Errors/sec across runs; tighten #577 tests