Repository navigation
Description
Problem, by example
quantile_over_time(0.9, latency[5m]) planned with a DDSketch. Take a state over the two samples [20, 40] at α = 0.01 (summary_kernels::dd_sketch::tests::quantile_interpolates_between_adjacent_order_statistics):
| readout the executor declares | readout the executor computes | answer | |
|---|---|---|---|
| today | StatisticKind::Quantile (nearest rank) |
DdSketch::quantile_interpolated (rank q·(n−1)) |
≈ 38 |
nearest rank, which Quantile names |
DdSketch::get_value_at_quantile |
≈ 40 |
The executor computes the interpolated readout, as PromQL and SQL percentile_cont require. But EVALUATED_READOUTS and the capability check say it answers the nearest-rank Quantile. asap_sketchlib's capability row for DDSketch lists the two separately: (Quantile, AsIfBuiltOverUnion) and (QuantileInterpolated, AsIfBuiltOverUnion). So the declaration names a different readout from the one served.
Why it happens
crates/executor/src/summary_kernels/dd_sketch.rs(estimate) andcrates/executor/src/values/mapped_states.rsanswerSketchStatistic::Quantile { q }withquantile_interpolated.crates/executor/src/capability/mod.rs(EVALUATED_READOUTS) lists(SketchAlgorithm::DDSketch, &[StatisticKind::Quantile]).SketchStatistic::kind()(crates/types/src/summary_type/capability.rs) maps every quantile toStatisticKind::Quantile.QuantileInterpolatedwas added to sketchlib's table in the bump of chore(deps): bump asap_sketchlib to main a05b35c (+ #267, #270, #271 views); plan wire version 16 #1539.
The accuracy claim is still sound. Each order statistic is within α relative of the true one, so the interpolation is within α relative when both neighbours have the same sign. The mismatch is in what the capability tables say.
Proposal
Make the declared readout match the computed one:
- Declare
StatisticKind::QuantileInterpolatedfor DDSketch inEVALUATED_READOUTS. - Map the planner's quantile statistic to the readout each family actually serves: interpolated for DDSketch, nearest rank or rank for KLL.
Alternative: have the executor answer Quantile with get_value_at_quantile. This changes answers, and PromQL compatibility needs the interpolated value, so it is not preferred.
Scope and acceptance
- In scope: the executor's declaration and the planner's kind mapping.
- Out of scope: KLL's quantile convention.
- Test: a capability test showing that DDSketch is validated against
QuantileInterpolated, and that a deployment declaring only{"summary_type": "DDSketch", "readouts": ["Quantile"]}does not admit a DDSketch quantile plan, or else the documented policy.
Related
- chore(deps): bump asap_sketchlib to main a05b35c (+ #267, #270, #271 views); plan wire version 16 #1539: asap_sketchlib bump that added
StatisticKind::QuantileInterpolated.
Activity