Repository navigation
Report per-run means in the --run-count AGGREGATED AVERAGE section - #757
Conversation
|
🤖 Automated first-pass review — a human maintainer's review is still required before merge. Thanks for this. The write-up is unusually thorough, and the Runtime part is clearly a bug fix: 1. Changing the counts silently is the part I'm least sure about. Keeping the JSON types is the right instinct, and the doubles round shows you already went through this trade-off once. But the semantic change is arguably harder on consumers than a type change. Anything that reads 2. Totals can't be recovered after this. The PR body suggests multiplying by 3. The section now disagrees with itself. The histogram's encoded count is now 4. Per-Key Misses 5. Nitpicking: CPU seconds are divided by The tests are solid. The fails-on-master / mutant table is the bar PR#364 set, and covering both (I'd file this as a comment, not a formal block.) |
Review of #757: rounding each averaged count with (x + n/2) / n broke two things. Totals and every command row were rounded separately, so the AGGREGATED Totals Count no longer equalled the sum of its rows (off by up to 4 with 8 --command rows, by 1 on the default workload). And a small count (1 connection error, unanswered request or miss over 3 runs) printed 0 next to a non-zero /sec rate. Keep every count summed internally, as before this PR, and write it in the AGGREGATED section as count / N, a double that reads back exactly ("Count": 9886.333333333334, always with a decimal point). This covers Count, Accumulated Latency, Connection Errors, Unanswered requests and the Per-Key Misses counts, while the CPU seconds already were doubles. Totals again equals the sum of the rows up to float precision. The rounding helpers, and the divisions of counters the AVERAGE never prints (bytes, retry counters), are gone. Tests: Totals Count == sum of 8 --command rows within 1e-6 with --run-count 2, and per-run means for those rows, the MGET Per-Key Misses counts, Unanswered requests (writes paused for the whole series) and the CPU user/sys seconds. README: --command Hits/sec and Misses/sec are time-weighted, the "(N runs)" header follows --run-count while the means use the runs completed, and CPU seconds average the runs that reported CPU. Co-Authored-By: Claude Opus 5.5 <[email protected]>
8503a17 to
b202637
Compare
|
Thanks for the review. Taking your points in order (fixed in b202637): (a) Compatibility of the counts. The keys stay the same and the values change. That is intended, and it is now spelled out in the PR's compatibility section. An "AGGREGATED AVERAGE" section that reports N-fold totals next to per-run rates misleads every reader, and a consumer that wants series totals can multiply by (b) Histogram total = N × Count. This is deliberate. The section's percentiles come from the merged histogram of all samples, and a histogram cannot be scaled by 1/N exactly. The README "Repeated runs" section documents it, and the #567 test ( (c) Small counts rounded to 0. Fixed. Nothing is rounded any more. The counts stay summed internally and are written in the AGGREGATED section as the exact mean (d) Duplicated rounding helper. Gone, along with the rounding itself and the divisions of counters the AVERAGE never prints. |
|
Following up on the updated review (point numbers refer to that comment). Fixed in e204690: 2. JSON type depending on runs completed. Fixed. 3. 4. Separately, the README example (and my earlier reply) now shows memtier's real output, |
Review of #757: rounding each averaged count with (x + n/2) / n broke two things. Totals and every command row were rounded separately, so the AGGREGATED Totals Count no longer equalled the sum of its rows (off by up to 4 with 8 --command rows, by 1 on the default workload). And a small count (1 connection error, unanswered request or miss over 3 runs) printed 0 next to a non-zero /sec rate. Keep every count summed internally, as before this PR, and write it in the AGGREGATED section as count / N, a double that reads back exactly ("Count": 9886.333333333334, always with a decimal point). This covers Count, Accumulated Latency, Connection Errors, Unanswered requests and the Per-Key Misses counts, while the CPU seconds already were doubles. Totals again equals the sum of the rows up to float precision. The rounding helpers, and the divisions of counters the AVERAGE never prints (bytes, retry counters), are gone. Tests: Totals Count == sum of 8 --command rows within 1e-6 with --run-count 2, and per-run means for those rows, the MGET Per-Key Misses counts, Unanswered requests (writes paused for the whole series) and the CPU user/sys seconds. README: --command Hits/sec and Misses/sec are time-weighted, the "(N runs)" header follows --run-count while the means use the runs completed, and CPU seconds average the runs that reported CPU. Co-Authored-By: Claude Opus 5.5 <[email protected]>
10223cf to
094dd7a
Compare
Review of #757: rounding each averaged count with (x + n/2) / n broke two things. Totals and every command row were rounded separately, so the AGGREGATED Totals Count no longer equalled the sum of its rows (off by up to 4 with 8 --command rows, by 1 on the default workload). And a small count (1 connection error, unanswered request or miss over 3 runs) printed 0 next to a non-zero /sec rate. Keep every count summed internally, as before this PR, and write it in the AGGREGATED section as count / N, a double that reads back exactly ("Count": 9886.333333333334, always with a decimal point). This covers Count, Accumulated Latency, Connection Errors, Unanswered requests and the Per-Key Misses counts, while the CPU seconds already were doubles. Totals again equals the sum of the rows up to float precision. The rounding helpers, and the divisions of counters the AVERAGE never prints (bytes, retry counters), are gone. Tests: Totals Count == sum of 8 --command rows within 1e-6 with --run-count 2, and per-run means for those rows, the MGET Per-Key Misses counts, Unanswered requests (writes paused for the whole series) and the CPU user/sys seconds. README: --command Hits/sec and Misses/sec are time-weighted, the "(N runs)" header follows --run-count while the means use the runs completed, and CPU seconds average the runs that reported CPU. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Follow-up on the compatibility point (1). I've switched approaches, in 094dd7a. The AGGREGATED counts are integers again, still as per-run means, so values change, types don't. That resolves the concern about strictly typed consumers: a Go
|
With --run-count N, the AGGREGATED AVERAGE RESULTS section printed its rates and latencies as per-run means, but its Runtime said Start time 0, Finish time and Total duration equal to the SUM of the run durations, and its Count, Accumulated Latency, Connection Errors, Unanswered requests, Per-Key Misses counts and CPU seconds were sums over the runs too. A reader of an "average" section takes 6000 ms as the length of an average 2 s run. aggregate_average() kept the summed duration on purpose: the hit/miss counts stay summed so that Σhits / Σduration gives the exact time-weighted rate without truncating small miss counts. Keep that internally, but: - divide the summed counters (totals and per command) by N, rounded; - start the section at the first run's start and record N, so the JSON Runtime prints the mean run duration, with Finish - Start == Total duration as in every other section; - print the Per-Key Misses counts per run; - report the CPU and wall seconds per run (the ratios are unchanged). The JSON keys are unchanged; only the values in the AGGREGATED section change. Its merged HDR histogram still holds the samples of all runs, so its encoded count is N x Count. A run that never started still counts as one of the N runs with zero duration, like its zero Ops/sec. The stderr miss-rate warning keeps the summed counts, since it reports the ratio over the whole series. Documented in the README. Fixes #703 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review of #757: rounding each averaged count with (x + n/2) / n broke two things. Totals and every command row were rounded separately, so the AGGREGATED Totals Count no longer equalled the sum of its rows (off by up to 4 with 8 --command rows, by 1 on the default workload). And a small count (1 connection error, unanswered request or miss over 3 runs) printed 0 next to a non-zero /sec rate. Keep every count summed internally, as before this PR, and write it in the AGGREGATED section as count / N, a double that reads back exactly ("Count": 9886.333333333334, always with a decimal point). This covers Count, Accumulated Latency, Connection Errors, Unanswered requests and the Per-Key Misses counts, while the CPU seconds already were doubles. Totals again equals the sum of the rows up to float precision. The rounding helpers, and the divisions of counters the AVERAGE never prints (bytes, retry counters), are gone. Tests: Totals Count == sum of 8 --command rows within 1e-6 with --run-count 2, and per-run means for those rows, the MGET Per-Key Misses counts, Unanswered requests (writes paused for the whole series) and the CPU user/sys seconds. README: --command Hits/sec and Misses/sec are time-weighted, the "(N runs)" header follows --run-count while the means use the runs completed, and CPU seconds average the runs that reported CPU. Co-Authored-By: Claude Opus 5.5 <[email protected]>
write_json_count() and the Accumulated Latency branch keyed off runs > 1, so a --run-count series cut short after its first run (Ctrl+C) printed the AGGREGATED counts as integers, and a complete series as doubles. The JSON type depended on the number of runs completed. m_averaged_runs is 0 for a real run, so key off runs > 0. Assert in the run-count interrupt tests (SIGINT during, and after, run 1 of 3) that the AGGREGATED Count, Accumulated Latency, Connection Errors and Unanswered requests are doubles while RUN #1 keeps integers. Also drop the dead 'n' from the decimal-point check, note that per-run sections keep integer Accumulated Latency, and use memtier's real %.17g output in the README example. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The arbitrary-command count test only ran with --command-stats-breakdown=line, so the default per-type path in print_json() was untested: passing 0 instead of m_averaged_runs there printed summed --command rows next to a mean Totals and no test noticed. Run it with both breakdowns, over 9 --command lines of 8 types (two GET lines, which the per-type rows merge). Also require the CPU block on Linux in the duration test instead of skipping the CPU checks when it is missing, and warn next to the assignment that the average's m_end_time is synthetic. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Writing the averaged counts as doubles (b202637) changed their JSON type, and strictly typed consumers fail to parse the whole file on it: a Go struct with `Count int64` rejects `1000.0`. Keep the per-run means but write them as integers again, so only the values in the AGGREGATED section change, not their types: - each row's Count and Accumulated Latency is its summed count divided by the runs, rounded to the nearest integer; - Totals Count and Accumulated Latency are the sum of the rounded rows, so Totals is exactly the sum of its rows (rounding Totals on its own drifts from it, by up to 4 with 8 --command rows); - Connection Errors, Unanswered requests and the Per-Key Misses counts use the same rounded mean, but a non-zero sum never rounds to 0, so a single error or miss stays visible next to its non-zero /sec rate; - the CPU seconds stay doubles, as they always were. result_print_to_json() is back to master's signature: print_json() passes it the rounded row values and the summed Totals. The Runtime mean-duration check now uses m_averaged_runs > 0 like the counts. Tests assert integers again: rows are exactly the rounded mean of the per-run values, Totals Count and Accumulated Latency exactly the sum of the rows (both breakdowns, 9 --command lines), 1 miss over 3 runs gives 1 (GET then SET of one key per run, so only run 1 misses), and the interrupt tests check that a series cut after run 1 reports run 1's integers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
In the AGGREGATED Per-Key Misses, Total Hits / Total Misses were rounded on their own, separately from the key[i] values, so a Total could be one off the sum of its keys (HMGET Total Misses 17551 vs a key sum of 17550). When a command's summed totals are the sum of its per-key buckets, write each Total as the sum of the rounded buckets, like Totals and its rows, and assert it in the MGET test. README: Totals can be about one unit per row away from the mean of the per-run Totals (the never-0 floor and the per-row ms truncation of Accumulated Latency make half a unit too tight). Co-Authored-By: Claude Opus 5.5 <[email protected]>
094dd7a to
e53a23a
Compare
|
On point 3 of the updated review: yes, the never-0 floor also applies to a row's The |
|
Addendum to the updated review:
|
Problem
With
--run-count N, theAGGREGATED AVERAGE RESULTS (N runs)section shows its rates and latencies as per-run means, but several other fields in the same section are not means:Runtime:Start time0 (not a timestamp), andFinish time/Total durationequal to the sum of the run durations (6000 ms for 3 x 2 s runs).CountandAccumulated Latency(Totals and per command),Connection Errors,Unanswered requests, thePer-Key Missescounts, and theCPUcpu_*_seconds/cpu_wall_secondsare all sums over the runs.Reproduced on master 38dfbaa (
-t 1 -c 2 --test-time 2 --run-count 3 --print-all-runs):Root cause
run_stats::aggregate_average()builds the section withtotals::add(), which sums every counter, and then divides only the rate and latency fields by N. It also setsm_start_time = 0andm_end_time = Σ run durationson purpose. The hit/miss counts are kept summed, and the print paths computecount / ts_diff(start, end), which gives the exact time-weighted rate Σhits / Σduration without truncating small miss counts (0010c1f, #398). The JSONRuntimeblock then printed that internal interval as if it were a run.History: in 2.1.0 the section's
Total durationwas 0, becauseaggregate_average()never set the times. 0010c1f set them to make Hits/sec non-zero. It first stamped the average duration, and the version that landed in #398 switched to the sum to avoid truncation. The JSON was never adjusted.Fix
Every value in an "average" section is now a per-run value, consistent with Ops/sec and the latencies. JSON types are unchanged.
m_averaged_runs), andprint_json()writes them as follows:CountandAccumulated Latencyisround(sum / N).CountandAccumulated Latencyare the sum of the rounded rows, so Totals is exactly the sum of its rows. Rounding Totals on its own drifts from that, by up to 4 with 8--commandrows.Per-Key Misses, when a command's totals are the sum of itskey[i]buckets,Total Hits/Total Missesare the sum of the rounded buckets, so they stay the sum of their keys.Connection Errors,Unanswered requestsand thePer-Key Missescounts use the same rounded mean, but a non-zero sum never rounds to 0: 1 error or miss over 3 runs prints 1, so it stays visible next to its non-zero /sec rate.result_print_to_json()keeps master's signature, andprint_json()passes it the rounded values.Total duration= mean run duration.Start time= the first run's start, a real timestamp.Finish time=Start time + Total duration, soFinish - Start == Total durationholds as in every other section.m_averaged_runs > 0, so a series cut short after one run is handled the same way.CPUseconds (already doubles) are the mean over the runs that reported CPU usage, which is every run on Linux.cores_usedand the utilization ratios are unchanged.--commandrows, Hits/sec and Misses/sec are therefore time-weighted (Σcount / Σduration). Ops/sec, KB/sec and the default workload's Hits/Misses/sec remain means of the per-run rates.(N runs)header still follows--run-count, so the JSON key is stable. If the series is cut short, the means are over the runs completed (Runs completed). This is documented in the README's new "Repeated runs" section.The text table has no counts or duration, so it is unchanged. The stderr CPU summary for the AVERAGE shows per-run seconds, the same as the JSON. The stderr miss-rate warning keeps the summed
(X misses / Y ops)on purpose: it reports the ratio over the whole series, and #585's tests check those exact sums.Interactions:
--connection-stage-timeoutabort before any connection, see --run-count: exit code 2 (--connection-stage-timeout abort) is lost unless the last run aborted #739/Exit 2 when any --run-count run hits --connection-stage-timeout #752) still counts as one of the N runs, with zero duration and zero ops, just as it already contributes 0 to the averaged Ops/sec. Whether such runs should be excluded is --run-count: after Ctrl+C, BEST/WORST RUN RESULTS can select the interrupted partial run over complete runs (intended?) #711's question. This change takes N fromall_stats, so it follows whatever set of runs --run-count: after Ctrl+C, BEST/WORST RUN RESULTS can select the interrupted partial run over complete runs (intended?) #711 settles on.Interruptedhandling (Stop the --run-count series on Ctrl+C #698) is untouched.Compatibility note
Values change, types don't. In the
AGGREGATED AVERAGE RESULTSsection, no keys are added or removed and every value keeps its JSON type. Integers stay integers, so strictly typed consumers (for example GoCount int64) still parse the file. BEST, WORST, RUN #i and ALL STATS are unaffected.Count,Accumulated Latency,Connection Errors,Unanswered requestsand thePer-Key Missescounts become rounded per-run means, about 1/N of the old sums. For example, 29659 ops over 3 runs gives"Count": 9886instead of29659.CPUseconds,Total durationandFinish timedrop by about N, andStart timebecomes the first run's start instead of 0.Histogram log format) still holds the samples of all runs, so its encoded total count is about N ×Count. This is deliberate: the percentiles come from all samples. It is documented and covered by the --run-count JSON: AGGREGATED AVERAGE Totals percentiles come from an empty histogram #567 test.Runs completedonly approximates the series totals. Exact totals are the sum of theRUN #isections (--print-all-runs). The main downstream consumer we checked, redis-benchmarks-specification'sdefaults.yml, reads only rates and latencies from these files.Tests
test_json_aggregated_duration_and_counts_are_run_mean(--run-count=3 --test-time=2 --print-all-runs) checks:Total durationequals the mean of the run durations (±2 ms) and is close to--test-time.Start timeequals RUN pcre required for build #1's start, andFinish - Start == Total duration.Countare exactly the rounded mean of the per-run counts, integers.CountandAccumulated Latencyare exactly the sum of the rows.Unanswered requestsis the rounded mean.test_json_aggregated_arbitrary_command_counts_are_run_mean(default--command-stats-breakdown=command, 8 type rows) andtest_json_aggregated_arbitrary_command_line_counts_are_run_mean(line, 9 rows) both run 9--commandlines of 8 types (two GET lines) with--run-count=2. They check that every row Count is the exact rounded mean, that Totals is exactly the sum of the rows, and that the MGETPer-Key Misseskey[i]counts are the rounded means, with eachTotalexactly the sum of its keys. At 094dd7a, where Total was rounded on its own, those checks failed in 2 of 3 runs, depending on rounding; at e53a23a they passed 5/5.test_json_aggregated_small_count_never_rounds_to_zero: one client sends GET then SET of one key per run,--run-count=3, so only run 1's GET misses. It checks that the AGGREGATEDTotal Misses/key[0] Missesis 1, not 0, next to a non-zero Misses/sec.test_json_aggregated_unanswered_requests_are_run_meanpauses writes for the whole series, so every run abandons its in-flight SETs, and checks the rounded mean.test_json_aggregated_connection_errors_secalso checks theConnection Errorscount.--run-count 3interrupt tests intests_oss_simple_flow.py(SIGINT during, and after, run 1) check that the AGGREGATED Count, Connection Errors and Unanswered requests equal RUN pcre required for build #1's integers, and Accumulated Latency is within 3.test_aggregated_average_totals_histogram(--run-count JSON: AGGREGATED AVERAGE Totals percentiles come from an empty histogram #567) expectsCount4000 per run and a histogram of 2 × Count.Evidence (
--env oss; the table was measured at 094dd7a, the current head e53a23a is on master 3093d17). The four count tests (small-count, both breakdowns, duration):With the fix:
test_json_output_integrity.pywith the two interrupt tests and the --run-count JSON: AGGREGATED AVERAGE Totals percentiles come from an empty histogram #567 test passes 28/28 at e53a23a.test_json_output_integrity.pywithtest_arbitrary_command_misses.pypasses 41/41.tests_oss_simple_flow.pyandtest_prometheus.pyrun-count tests,test_hdr_histogram.pyandtest_miss_rate_tracking.pypass 36/36.test_cpu_stats.py,test_arbitrary_command_misses.py,test_cli_validation_run_count.pyandtest_cli_validation_count_flags.pypass 55/55.--env oss-cluster --shards-count 3: 3/3.Affected versions
2.4.0 through 2.5.2 (latest) and master for the summed
Total duration/Finish timeandStart time0. Introduced by 0010c1f, landed via 1485147 (#398), first tag 2.4.0.Count/Accumulated Latency/Connection Errorsare sums in 2.5.2 and master. 2.1.0 printed 0 for duration and Count in this section.Fixes #703
🤖 Generated with Claude Code