Add mergeable streaming latency percentile digest#281
Merged
Conversation
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.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 47 |
| Duplication | 0 |
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.
|
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
stats.percentileis 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, andmergefor cross-shard aggregation (correct aggregate p99 from per-worker results).exact_percentiles(samples, qs)— exact percentiles for the small-set case (delegates tostats.percentile).Pure stdlib (
math).Five-layer wiring
je_auto_control/utils/percentiles/__init__.py+__all__AC_percentiles(arbitrary quantiles, complementsAC_describe_stats' fixed set)ac_percentilesTests & docs
test/unit_test/headless/test_percentiles_batch.py(9 tests: exact, digest accuracy, summary, merge, empty, quantiles)Lint clean: ruff / pylint (same-class merge protected-access justified) / bandit / radon.