Repository navigation
Fix empty Totals histogram in --run-count AGGREGATED AVERAGE JSON - #572
Merged
Merged
Conversation
With --run-count N, the JSON "AGGREGATED AVERAGE RESULTS" Totals block prints its percentiles, Min/Max Latency and compressed histogram from m_totals.latency_histogram. aggregate_average() builds m_totals from the totals that summarize() returns, which never carry a histogram, so that histogram stayed empty: Count was right but every percentile was the empty-histogram value (0.007) and the encoded histogram had no samples. The text table was correct because it builds its Totals row from the per-type histograms. Merge each run's m_totals.latency_histogram, the same histogram the per-run JSON Totals block uses, alongside the per-type histograms. Fixes #567 Co-Authored-By: Claude Opus 5.5 <[email protected]>
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
With
--run-count N --json-out-file, the"AGGREGATED AVERAGE RESULTS (N runs)"→"Totals"block reports percentiles from an empty histogram.Countis right, but every percentile is the empty-histogram value and the compressed histogram has no samples.Min Latency/Max Latencyare wrong for the same reason. The text table's Totals row in the same section is correct.On master (
--run-count 2 -n 1000 -c 2 -t 2):Root cause
The JSON Totals block reads
m_totals.latency_histogram.run_stats::aggregate_average()buildsm_totalsbyadd()ing thetotalsthatsummarize()returns, and those never carry a histogram. The function merges the per-type histograms andm_totals_latency_histogram, but notm_totals.latency_histogram. The table builds its Totals row from the per-type histograms, so it was not affected. #251 fixed the totals histogram inmerge()but not inaggregate_average().Fix
In
aggregate_average(), merge each run'sm_totals.latency_histogram(the histogram the per-run JSON Totals block uses) next to the per-type histograms. This is a one-line change.Test
tests/test_hdr_histogram.py::test_aggregated_average_totals_histogramruns--run-count=2 --print-all-runsand decodes the compressed histograms. It checks that the AVERAGE Totals histogram:Countsamples,RUN #1andRUN #2Totals histograms.It also checks that the JSON percentiles and Min/Max match exact HDR ranks of that histogram, and that they match the AVERAGE table's Totals row.
Before the fix (origin/master):
After the fix,
test_hdr_histogram.pypasses 3/3, repeated 4 times, andtest_cli_validation_run_count.pypasses.Fixes #567
Affected versions: 1.4.0 through 2.5.2 and master. The bug was introduced by fdf704b (#100), which added percentile output.
🤖 Generated with Claude Code
Note
Low Risk
Small, targeted fix to multi-run aggregation output; aligns JSON Totals with existing table behavior and adds regression coverage.
Overview
Fixes AGGREGATED AVERAGE JSON when using
--run-count: the"Totals"block had correctCountbut wrong percentiles, min/max, and an empty compressed histogram becauseaggregate_average()never merged each run'sm_totals.latency_histogram(the histogramprint_jsonuses for Totals), while per-type histograms were already merged.run_stats::aggregate_average()now callshdr_add(m_totals.latency_histogram, i->m_totals.latency_histogram)alongside the existing GET/SET/WAIT merges, with a comment thatsummarize()leaves the summarizedtotalshistogram empty.Adds
test_aggregated_average_totals_histogramintest_hdr_histogram.py: runs--run-count=2, decodes HDR payloads, and asserts AVERAGE Totals matches merged Sets+Gets and merged per-run Totals, and that JSON percentiles/min/max and the text table Totals row agree.Reviewed by Cursor Bugbot for commit 480d404. Bugbot is set up for automated code reviews on this repo. Configure here.