Repository navigation
Fix JSON Totals latency precision and add integrity regression tests - #364
Merged
fcostaoliveira merged 1 commit intoMay 5, 2026
Merged
fcostaoliveira merged 1 commit into
fcostaoliveira merged 1 commit into
Conversation
The Totals section of --json-out-file reported "Latency" and "Average Latency" as integer-truncated values. A real average of 1.291 ms came out as 1.000; sub-millisecond averages came out as 0.000. The Sets and Gets sections were correct because totals_cmd::m_latency is double; only the outer totals::m_latency was unsigned long long, and run_stats::summarize assigned the averaged double into it, truncating fractional milliseconds. Three changes: - run_stats_types.h: change totals::m_latency from unsigned long long to double so the averaged value survives summarize(). - run_stats_types.cpp: fix a long-standing typo in totals::add() that conflated m_latency and m_total_latency. The two fields held the same value before summarize() ran, so the typo was harmless on the live accumulator path but corrupted m_total_latency once summarize() turned m_latency into an average for the multi-run aggregate path. - run_stats.cpp: have summarize() also write the raw latency sum into result.m_total_latency, so the BEST/WORST/AGGREGATED sections produced by aggregate_average() carry a correct "Accumulated Latency". Tests: tests/test_json_output_integrity.py asserts the invariant Latency == Average Latency == Accumulated / Count for Sets, Gets, Totals across single-run, SET-only, GET-only and multi-run aggregated outputs, plus the per-second time-series buckets. The existing total_latency > 0 check was insufficient because the bug surfaced as 1.000 ms (looks plausible) rather than 0. Refs: RED-191460 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
fcostaoliveira
force-pushed
the
fix/red-191460-json-totals-latency
branch
from
May 5, 2026 13:42
8db6e79 to
550a695
Compare
paulorsousa
approved these changes
May 5, 2026
fcostaoliveira
added a commit
to filipecosta90/memtier_benchmark
that referenced
this pull request
May 5, 2026
…edis#364) The Totals section of --json-out-file reported "Latency" and "Average Latency" as integer-truncated values. A real average of 1.291 ms came out as 1.000; sub-millisecond averages came out as 0.000. The Sets and Gets sections were correct because totals_cmd::m_latency is double; only the outer totals::m_latency was unsigned long long, and run_stats::summarize assigned the averaged double into it, truncating fractional milliseconds. Three changes: - run_stats_types.h: change totals::m_latency from unsigned long long to double so the averaged value survives summarize(). - run_stats_types.cpp: fix a long-standing typo in totals::add() that conflated m_latency and m_total_latency. The two fields held the same value before summarize() ran, so the typo was harmless on the live accumulator path but corrupted m_total_latency once summarize() turned m_latency into an average for the multi-run aggregate path. - run_stats.cpp: have summarize() also write the raw latency sum into result.m_total_latency, so the BEST/WORST/AGGREGATED sections produced by aggregate_average() carry a correct "Accumulated Latency". Tests: tests/test_json_output_integrity.py asserts the invariant Latency == Average Latency == Accumulated / Count for Sets, Gets, Totals across single-run, SET-only, GET-only and multi-run aggregated outputs, plus the per-second time-series buckets. The existing total_latency > 0 check was insufficient because the bug surfaced as 1.000 ms (looks plausible) rather than 0. Refs: RED-191460 Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
4 tasks done
fcostaoliveira
added a commit
that referenced
this pull request
May 5, 2026
…364) The Totals section of --json-out-file reported "Latency" and "Average Latency" as integer-truncated values. A real average of 1.291 ms came out as 1.000; sub-millisecond averages came out as 0.000. The Sets and Gets sections were correct because totals_cmd::m_latency is double; only the outer totals::m_latency was unsigned long long, and run_stats::summarize assigned the averaged double into it, truncating fractional milliseconds. Three changes: - run_stats_types.h: change totals::m_latency from unsigned long long to double so the averaged value survives summarize(). - run_stats_types.cpp: fix a long-standing typo in totals::add() that conflated m_latency and m_total_latency. The two fields held the same value before summarize() ran, so the typo was harmless on the live accumulator path but corrupted m_total_latency once summarize() turned m_latency into an average for the multi-run aggregate path. - run_stats.cpp: have summarize() also write the raw latency sum into result.m_total_latency, so the BEST/WORST/AGGREGATED sections produced by aggregate_average() carry a correct "Accumulated Latency". Tests: tests/test_json_output_integrity.py asserts the invariant Latency == Average Latency == Accumulated / Count for Sets, Gets, Totals across single-run, SET-only, GET-only and multi-run aggregated outputs, plus the per-second time-series buckets. The existing total_latency > 0 check was insufficient because the bug surfaced as 1.000 ms (looks plausible) rather than 0. Refs: RED-191460 Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
7 tasks done
This was referenced Sep 19, 2026
This was referenced Oct 9, 2026
This was referenced Oct 14, 2026
This was referenced Oct 16, 2026
This was referenced Oct 23, 2026
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.
Summary
Totals.Latency/Totals.Average Latencyin--json-out-filereporting integer-truncated values (e.g. real avg 1.291 ms shown as 1.000; sub-ms shown as 0.000). Root cause:totals::m_latencywasunsigned long long, andrun_stats::summarize()assigned the averaged double into it. Sets/Gets sections were unaffected becausetotals_cmd::m_latencyis alreadydouble.totals::add()that conflatedm_latencywithm_total_latency— harmless beforesummarize(), corruptedm_total_latencyafterwards in the multi-run aggregate path.summarize()populateresult.m_total_latencyfrom the per-cmd raw latency sum, soBEST RUN,WORST RUN, andAGGREGATED AVERAGEsections carry a correctAccumulated Latency(was 0 in the aggregated path becausesummarize()only setm_latency).tests/test_json_output_integrity.pythat pins the invariantLatency == Average Latency == Accumulated / Countfor Sets / Gets / Totals across single-run, SET-only, GET-only and multi-run aggregated outputs, plus per-second time-series buckets. The existingtotal_latency > 0check did not catch this because the bug surfaced as1.000(plausible-looking) rather than0.Refs: RED-191460
Test plan
OSS_STANDALONE=1 TEST=test_json_output_integrity.py ./tests/run_tests.sh— all 4 new tests pass on the fix; the multi-run test fails on master without thesummarize()change, validating it catches both bugs.OSS_STANDALONE=1 TEST=test_scan.py ./tests/run_tests.sh— 15/15 pass (sanity check that unrelated tests still work).Totals.Latencynow matchesAccumulated Latency / Countinstead of being 0.000.🤖 Generated with Claude Code
Note
Medium Risk
Changes how
Totalslatency/accumulated latency are computed and aggregated for--json-out-file, which can affect reported benchmark metrics and downstream consumers. Adds regression tests that may surface previously hidden inconsistencies across multi-run and time-series outputs.Overview
Fixes incorrect
TotalsJSON latency reporting by preserving fractional precision (storestotals::m_latencyasdouble) and by computing both average latency andAccumulated Latencyfrom a single summedtotal_latency_suminrun_stats::summarize().Corrects multi-run aggregation by summing
m_total_latency(notm_latency) intotals::add(), ensuringBEST/WORST/AGGREGATEDsections carry consistent accumulated latency.Adds
tests/test_json_output_integrity.pyto regression-test the invariantLatency == Average Latency ~= Accumulated Latency / Countacross Sets/Gets/Totals, multi-run aggregate sections, and per-second time-series buckets.Reviewed by Cursor Bugbot for commit 550a695. Bugbot is set up for automated code reviews on this repo. Configure here.