Expand description
Fixed-capacity latency statistics — REQ-CLK-006.
LatencyRing is a sliding window of u64 nanos: record is O(1)
and evicts the oldest sample when capacity is exceeded; stats is
exact over the current window with zero heap allocation — it sorts
a stack-resident copy (CAP × 8 B scratch; default 4096 → 32 KiB, chosen
for ≥ 64 KiB stacks) and reports min/max/mean/p50/p99/p99.9.
Percentiles use the nearest-rank algorithm, re-implemented lean from the percentile-kit pattern: percentile-kit is L2, and an L1 crate must not depend upward (estate layers.md rule 1) — so the algorithm is copied, not linked. No recursion anywhere (guaranteed for constrained stacks): the sort is an iterative heapsort.
Structs§
- Interval
Stats - Exact interval statistics over the current window (nanosecond resolution). All zeros for an empty ring. REQ-CLK-006.
- Latency
Ring - Fixed-capacity (const-generic) ring of
u64nanos — a sliding window, not an accumulator. Allocation-free on every path:stats()works from a stack-resident scratch copy sized byCAP(default 4096 → 32 KiB — document your stack when embedding with larger capacities). REQ-CLK-006.