Skip to content

Add mergeable streaming latency percentile digest#281

Merged
JE-Chen merged 2 commits into
devfrom
feat/percentiles
Jun 21, 2026
Merged

Add mergeable streaming latency percentile digest#281
JE-Chen merged 2 commits into
devfrom
feat/percentiles

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 21, 2026

Copy link
Copy Markdown
Member

Summary

stats.percentile is exact but needs the full sorted sample list in memory; for a long-running or sharded load/soak run you want an O(1)-per-record, bounded-memory, mergeable structure. This adds it.

  • LatencyDigest(sig_figs=3)record (O(1), buckets to significant figures), percentile / quantiles / summary, and merge for cross-shard aggregation (correct aggregate p99 from per-worker results).
  • exact_percentiles(samples, qs) — exact percentiles for the small-set case (delegates to stats.percentile).

Pure stdlib (math).

Five-layer wiring

  • Headless core: je_auto_control/utils/percentiles/
  • Facade: re-exported from __init__.py + __all__
  • Executor: AC_percentiles (arbitrary quantiles, complements AC_describe_stats' fixed set)
  • MCP: ac_percentiles
  • Script Builder: "Percentiles" under Report

Tests & docs

  • test/unit_test/headless/test_percentiles_batch.py (9 tests: exact, digest accuracy, summary, merge, empty, quantiles)
  • v73 feature docs (EN + Zh) + toctree
  • What's-new in all three READMEs

Lint clean: ruff / pylint (same-class merge protected-access justified) / bandit / radon.

stats.percentile needs the full sorted list in memory; for long-running
or sharded load/soak runs add a HdrHistogram-style LatencyDigest with
O(1) record, bounded memory (significant-figure buckets) and merge for
cross-shard aggregation, plus exact_percentiles for small sets. Wired
through the facade, AC_percentiles executor command, MCP tool and the
Script Builder.
@codacy-production

codacy-production Bot commented Jun 21, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 47 complexity · 0 duplication

Metric Results
Complexity 47
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@JE-Chen JE-Chen merged commit 289409b into dev Jun 21, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/percentiles branch June 21, 2026 12:56
@sonarqubecloud

Copy link
Copy Markdown

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.

1 participant