Skip to content

Top-k precision estimate is optimistic: per-seed CMS collisions miss the target in e2e #211

Open

Description

@zzylol

What we saw

An end-to-end check of the #777 classic plan (ASAPQuery --planner saved, asap method, cpu weights, cheapest plan; paced feeder, CloudLab) measured topk(32, sum_over_time(data[15m])) precision against exact ClickHouse answers. The plan serves it with cms-heap-topk-fastpath-vector2d at rows 3, cols 1024, and the table's estimate is precision 0.96875 against the 0.95 target.

Seed Data Precision per eval time
7 gauge values as generated 0.9375 at all 6
43 as generated 0.9375 at all 4
42 values × 1000 1.0, 1.0, 0.969, 0.969
43 values × 1000 0.9375 at all 4
  • Precision depends on the seed, not the time. Within a seed it is the same at every eval time and window (15m/1h/6h/24h). Across seeds it ranges 0.9375–1.0, mean about 0.95. Two of three seeds miss the target at every evaluation.
  • The false positives are count-min collisions. A light key (true rank about 3,500–4,600) shares a bucket with heavy keys in all three rows, so its estimate rises by 0.4–0.73% of the window total and it enters the top 32. Which key collides depends on the seed. The other miss is benign: rank 33 overestimated by 0.03–0.07% of the total.
  • Not integer rounding. asap_sketchlib rounds each insert to an integer, but scaling values ×1000 left seed 43's false positives, precision and overestimates unchanged.

Suspected cause

The accuracy curves the optimizer reads keep (n, seed_mean_error, seed_se) (rqe-optimizer/src/saturation.rs:84), so a config is accepted on the mean over seeds. For top-k with a small CMS, the per-seed spread is large, so a config whose mean precision clears 0.95 still fails on many seeds.

To check

  1. How many seeds the top-k curves (top-k: k is a per-query variable, not the constant 32 #185, cms-heap at K = 1e4, θ = 1.1) use, and what their per-seed spread is at rows 3 × cols 1024.
  2. Whether the accuracy check should use a pessimistic statistic, such as the worst seed or mean − z·se, as the Hydra columns already do (worst over records and seeds).
  3. Whether the measurement data matches e2e. The curves measure Zipf key counts (each item weight 1); the e2e top-k ranks per-series sums of Zipf-weighted Pareto(2) values with a seeded key shuffle (ASAPQuery#842).

If the check becomes stricter, the plans may pick larger top-k sketches, and the §6.3 costs (#210) change.

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions