Skip to content

Research notes / Measurement

p99 accuracy: rank error is not latency error

/ Source review and exact constructed example

A small error in a percentile's rank need not mean a small error in milliseconds. Here, moving one position among 10,000 observations changes 10 ms into 1000 ms. Both the denominator and the error dimension matter.

On this page6 sections

Two different promises

A KLL sketch summarizes ordered observations using randomized compaction. Its error contract concerns rank. The original paper distinguishes single-query and all-query guarantees, and separates mergeable and non-mergeable constructions. Do not silently combine their strongest properties. [Definitions 1-2 and Table 1]

DDSketch instead targets relative error in the selected value: for positive quantile value x, an alpha-relative guarantee limits absolute value error to alpha times x. Bounded stores can lose that accuracy for quantiles affected by collapsed bins. This is not relative rank error or a universal preference for one sketch. [Sections 1-2]

Apache's KLL example explains the difficulty: a narrow rank interval can cross a large gap between values. Translating it into milliseconds needs information about the distribution near that percentile. [Understanding KLL Bounds]

One position, a hundred-fold value

Constructed data, not an SSD benchmark. Generate integer microsecond durations 101 through 10,000, then 1,000,000 through 1,000,099, inclusive. There are 9,900 values in the first block and 100 in the second. All are distinct and equally weighted.

Define p99 as sorted observation ceil(0.99 x 10,000), position 9900: 10,000 microseconds, or 10 ms. Define normalized rank as the fraction of observations less than or equal to a value. Choose an absolute rank allowance of 1/10,000, or 0.01 percentage points.

Candidate observations within one position of p99
Sorted positionRank, %Latency, msDistance from rank 99%, percentage points
989998.999.9990.01
990099.0010.0000.00
990199.011000.0000.01

The upper candidate has value 1000/10 = 100 times the exact p99. Relative value error is (1000 - 10)/10 = 99, or 9900%. Normalized rank error is only 0.0001. Percent, percentage points and ratios are different units.

These are candidates permitted by the declared constraint, not outputs from an executed KLL implementation. The chosen budget implies neither a library's k setting nor a failure probability.

The missing bound is structural

Move only the slow block farther right, keeping it above the first block. Position 9901 still differs from p99 by one position, but its ratio to 10 ms grows without a fixed upper bound in this mathematical construction. Order alone cannot constrain the gap.

This explains a known limitation; it is not a new theorem or a library defect. Real devices have physical limits and particular latency distributions. A rank-only promise does not supply those additional assumptions.

Duplicate values add another boundary: several sorted positions can share a value. Apache distinguishes inclusive and exclusive rank conventions. Our distinct values avoid that ambiguity; the tests check duplicate handling separately. [Rank conventions]

Ask the SLO question directly

Exactly 9900/10000 = 99% of these invented observations are at or below 10 ms. An estimated fraction of 99% with an absolute allowance of 0.01 percentage points permits 98.99% through 99.01%. That interval crosses a requirement of at least 99%; the approximation alone cannot certify it.

For a fixed latency threshold, retain the count meeting it and the total count over the same eligible requests and window. This answers the threshold question without reconstructing a percentile. It still does not fix missing demand, censoring or coordinated omission.

Separate approximation of the recorded stream, statistical inference about a wider population, and which requests were recorded at all. A randomized sketch's failure probability concerns its algorithmic contract, not automatically a confidence interval for tomorrow's traffic.

Reproduce and inspect

Download the method and commands, Python model, tests and result JSON. Python 3.10+ and its standard library suffice. The JSON records the input rule and SHA-256 fingerprint of all generated observations.

Tests cover rational boundaries, input-order independence, an independent counting oracle, duplicates, invalid inputs and growing gaps. There is no random seed, device cohort or empirical confidence interval. This original teaching artifact does not reproduce a source paper's experiments.

For aggregation, see why merging sketches does not resolve duplicated or revised windows. Error dimensions and observation provenance are separate obligations.

Primary sources

  1. Karnin, Lang and Liberty. Optimal Quantile Approximation in Streams (2016), definitions 1-2, sections 2 and 4, Table 1. arXiv:1603.05346. Accessed 2026-11-28.
  2. Masson, Rim and Lee. DDSketch. PVLDB 12(12), 2195-2205 (2019), section 1 and definition 1. DOI 10.14778/3352063.3352135. Accessed 2026-11-28.
  3. Apache DataSketches: Understanding KLL Bounds, discontinuities and error dimensions. Accessed 2026-11-28.
  4. Apache DataSketches: Sketching Quantiles and Ranks Tutorial, duplicates and inclusive/exclusive ranks. Accessed 2026-11-28.

Published by Hesela team · Published · Updated

Report a correction · Editorial standards · Reuse guidance

Change history

: first published.

: latest recorded update. A detailed change note is not available for this revision.

New-publication RSS · Correction RSS

Cite this page
Hesela team. p99 accuracy: rank error is not latency error. Hesela. 2026-11-28. https://hesela.com/analyses/quantile-rank-error-latency-gap/