Repository navigation
Weight aggregate JSON latency by completed samples - #804
Conversation
|
🤖 Automated first-pass review — a human maintainer's review is still required before merge. Thanks for this. The core change looks right to me.
The fix itself looks solid. I'd mainly want the description and release-note wording corrected before this merges. (would file this as a comment, not a formal block) |
|
The grouped single-run distinction is intentional: this correction targets the aggregate section, so existing RUN/BEST/WORST values retain their HDR precision. The README now says this explicitly in124a1a3 and its wrapping is fixed. The independent baseline/fixed JSON comparison found changes only in aggregate Latency/Average Latency fields; all single-run fields, counts/rates and histogram encodings stayed unchanged. I added a Bug Fixes release-note entry to the PR description for release preparation. This repository has no maintained changelog file. The three mean expressions currently operate on the same microsecond counters with the fixed1000 conversion used by the existing summary code. I kept the small arithmetic correction local rather than adding a shared API solely for this patch; the deterministic builtin/arbitrary and grouped/per-line writer controls check consistency across these call sites. The doc-only follow-up leaves production and tests byte-identical to the tested f651d9e. Fresh exact-head CI and all seven reviews remain merge gates. The pre-existing Waits writer constant is separately tracked in#803, as documented in the PR body. |
|
Yes, the single-run integer-microsecond truncation is intentionally unchanged here. This patch corrects the aggregate's weighting using its original integer sample sums; changing summarize() would also alter ordinary single-run output, expanding the compatibility surface beyond #671. Identical runs can consequently differ by one printed microsecond between a truncated per-line run mean and the exact aggregate mean. The regression uses non-integral sample means and compares against sums rather than requiring equality with a rounded/truncated per-run mean. The separate precision/test-tolerance work can address that single-run convention explicitly. The grouped distinction is intentional for the same reason and is now explicit in the README: aggregate rows use exact sums, real-run grouped rows retain HDR quantization. Independent OUT checked40 aggregate means,36 unchanged real-run JSON sections, and byte-identical text output. Its baseline fails19 mean assertions, including grouped precision controls. LATENCY_HDR_RESULTS_MULTIPLIER is currently1000; these expressions convert the same microsecond counters as existing summarize()/Totals code. The literal introduces no separate scale today. I have retained the local correction and its consistency tests rather than widening this patch into shared precision/unit refactoring. No source change followed124a1a3; exact-head CI and the remaining reviews are still pending. |
|
Following the 13:04:41 review edit, pushed Preserving the single-run grouped HDR mean is deliberate. Changing its convention would expand this aggregate-correctness fix to existing single-run results; README explicitly documents that distinction. Authentication is also deliberate: every private test endpoint in this workflow requires authentication, and the fixture checks it before accepting workload commands. The preceding master merge preserves both latency and retry unit functions/calls. Its tree exactly matches the independently tested integration composition; the fresh build and all 17 unit programs pass. The subsequent timing-margin change touches only the Python test. The prior ASAN TLS mget job failed before tests while cloning the pinned RLTest dependency (GitHub connection dropped, git exit128). This push starts new exact-head CI; I am not treating that dependency failure as a passing sanitizer result. Final CI and focused review carryforwards remain required. |
|
Agreed on the grouped-row scope point in the 13:10:08 edit. Pushed The revised test preserves grouped HDR weighting by comparing the aggregate against count-weighted individual HDR means, allowing only their printing error. Totals and per-line rows retain the independent accumulated-latency/count oracle. The rebuilt source passes all 17 units and all four weighted/retry fixture functions; an independent paired baseline/fixed check of the revised test is running. The single-run integer-microsecond truncation remains a separate issue. The two remaining conversions retain the existing aggregate/summarize convention of microseconds divided by 1000.0; no unit or histogram geometry changes are introduced. Fresh final-head review/CI gates remain pending. |
|
The description and release note were rewritten after the last code commit; both now explicitly preserve grouped HDR means. The final test has also been independently paired against current master: all five affected rows still fail on the baseline, while its already-correct grouped HDR rows pass. Both final layouts pass. For the compatibility question, I inspected the in-tree JSON integrity, weighted-latency and merge-unit assertions. The single-run Accumulated/Count tolerance helper explicitly excludes independently rounded aggregate counters; the new unequal-count test covers those aggregate means directly. Existing fixed-request mean checks retain their equal-count premise, and grouped HDR output is now unchanged. This is an in-tree assessment, not validation of arbitrary downstream consumers: I cannot guarantee that an external script did not depend on the old wrong mean. The changed aggregate-value contract is stated in README and the release note without changing keys or types. The historical #703 test commentary does not define an additional production invariant for latency. |
Problem
With unequal sample counts across --run-count runs, aggregate JSON averages run means instead of completed samples. A deterministic 100-at-1ms plus 10-at-9ms series reports 5.000ms instead of 1.727ms; an empty second run incorrectly halves the mean.
Root cause
run_stats::aggregate_average() and totals_cmd::aggregate_average() divide summed per-run means by run count although unrounded latency and operation sums are available. Grouped command rows already use a sample-weighted merged HDR mean and do not have this bug.
Fix
Calculate aggregate Totals, built-in and per-line command means from unrounded latency sums divided by completed samples, with floating division and zero-sample guards. Preserve grouped command HDR means in both individual and aggregate sections. Keep single-run output, count/rate averaging, JSON keys/types, histograms and percentiles unchanged. README describes the corrected weighting and retained histogram precision differences.
The independent built-in WAIT writer defect is tracked by #803 and fixed in #805. This PR fixes its internal aggregate arithmetic without claiming to repair those separate writer arguments.
Tests
Affected versions
Introduced by 833a8df (1.0.0); helper restructuring 58a1bdb first shipped in 1.2.16. Text switched to merged HDR means in fdf704b (1.4.0). Unweighted averaging affects 1.0.0–2.5.2 and current master; text/JSON disagreement dates from 1.4.0. Attribution is from source/tag history, not historical binary executions.
Release note — Bug Fixes
Weight aggregate JSON latency by completed operations instead of averaging per-run means. This corrects unequal and empty-run results for Totals, built-in commands and per-line command rows. Grouped command rows retain their already weighted HDR means; existing schemas and rate/count conventions are preserved.
Fixes #671.
🤖 Generated with Claude Code