Skip to content

Report empty latency histograms consistently in final output - #793

Merged
fcostaoliveira merged 1 commit into
masterfrom
codex/fix638-empty-histograms-20261023
Oct 23, 2026
Merged

fcostaoliveira merged 1 commit into
masterfrom
codex/fix638-empty-histograms-20261023

Conversation

@fcostaoliveira

@fcostaoliveira fcostaoliveira commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

An empty arbitrary-command or Totals histogram prints nan for its text average and nonzero percentile placeholders. JSON also reports 0.007 ms for percentiles of an empty distribution.

Root cause

Final output calls HDR mean/percentile queries without consistently checking histogram sample count. HDR scalar empty-bin values are implementation results, not measured latency.

Fix

Print --- for every empty final text average/percentile row. Keep JSON latency fields and percentile keys, writing numeric zero when the histogram is empty. Preserve rows, encoded HDR distributions, populated values, configured percentile order, and existing live/per-second behavior. Document the empty-output convention.

Tests

  • Three new regression tests pass on the fix and each fails with unchanged base production sources (4bade818): the old empty values include 0.007 ms; fixed values are zero. Cover built-in/arbitrary rows, per-line/per-command breakdown, empty Totals, monitor placeholders, and multi-run averages.
  • Nine focused tests pass, including the existing HDR file/JSON compatibility suite. Independently decoded bucket counts and percentile ranks verify populated distributions; empty compressed histograms remain empty.
  • All 16 unit executables, formatting and whitespace checks pass.
  • Validation uses authenticated private endpoints with bounded subprocesses. This changes final rendering only; no throughput improvement or measured throughput comparison is claimed.

Affected versions

The arbitrary-command mean path was introduced by fdf704b6671393c6b7f3dc5b77941c5bc81abe42 (#100), first released in 1.4.0; affected through 2.5.2 and current master before this fix. The monitor placeholder variant dates from 1e7877b (#330), first released in 2.3.0. Release range is source-history evidence; this owner pass executes current-base production sources and the fix, not every historical release.

Fixes #638

🤖 Generated with Claude Code


Note

Low Risk
Output-formatting only in final stats reporting; no change to benchmarking, connection, or latency recording paths.

Overview
Fixes misleading final benchmark output when a command row has no latency samples (e.g. unused GET in a write-only ratio, arbitrary commands with zero ops, or empty Totals).

Text results now show --- for average latency and all configured percentile columns on those rows instead of nan or bogus HDR-derived numbers. JSON keeps the same keys but writes 0 for average/min/max and percentile values when the histogram is empty; the compressed HDR payload stays empty.

Rendering changes are gated on hdr_total_count in result_print_to_json, print_avg_latency_column, and print_quantile_latency_columns (including arbitrary/aggregated and Totals rows). README documents the text vs JSON convention. Regression tests cover built-in/arbitrary breakdowns, multi-run averages, monitor placeholders, and connection failures (#638).

Reviewed by Cursor Bugbot for commit 9ab028c. Bugbot is set up for automated code reviews on this repo. Configure here.

@fcostaoliveira
fcostaoliveira merged commit 43ca076 into master Oct 23, 2026
131 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text output prints -nan Avg. Latency for a --command row with zero ops

1 participant