Skip to content

fix(data_plane): stop conflating CountSketch with CMS on ingest - #416

Merged
zzylol merged 1 commit into
mainfrom
feat/countsketch-write-side-accumulators
Jul 27, 2026
Merged

zzylol merged 1 commit into
mainfrom
feat/countsketch-write-side-accumulators

Conversation

@zzylol

@zzylol zzylol commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • accumulator_factory.rs's raw-metric dispatch collapsed SummaryKind::{Cms,CountSketch} and {CmsWithHeap,CountSketchWithHeap} into shared match arms, silently building CMS (min-of-rows) accumulators for CountSketch-family sids. Split into dedicated arms + new CountSketchAccumulatorUpdater/CountSketchWithHeapAccumulatorUpdater.
  • otel.rs's modified-OTLP decode / delta-bootstrap / delta-apply for heap-bearing SketchKind::CountSketch frames used CountMinSketchWithHeap(Accumulator) — the two families share a byte-identical wire envelope (heap is the distinguishing payload) so this compiled and round-tripped, but read a real CountSketch matrix through CMS's min-of-rows estimator. Fixed all four call sites.
  • CountSketchAccumulator gained MultipleSubpopulationAggregate/MergeableAccumulator impls (previously missing) and its keyed query_statistic lookup — previously a hand-rolled, non-hash-spec-compatible hasher — now routes through the real asap_sketchlib::CountSketch::estimate.
  • New CountSketchWithHeapAccumulator (structural port of CountMinSketchWithHeapAccumulator) wrapping the real asap_sketchlib::CountSketchWithHeap.

Test plan

  • cargo build --workspace — clean
  • cargo test -p data_plane --lib — 929 passed (0 failed)
  • cargo test -p data_plane --test e2e_controller_plans_and_backend_serves — 9/11 pass; the 2 known pre-existing failures (controller_plan_to_query_full_roundtrip_{cms,count_sketch}_with_heap_topk) reproduce identically on origin/main before this change, confirming they're an unrelated pre-existing routing issue
  • cargo clippy -p data_plane --lib — no new warnings vs. baseline (one pre-existing warning fixed as a side effect of deleting the dead hand-rolled hasher)
  • rustfmt on touched files only

🤖 Generated with Claude Code

`SummaryKind::CountSketch`/`CountSketchWithHeap` silently reused the CMS
accumulators on both ingest paths:

- `accumulator_factory.rs`'s raw-metric dispatch collapsed
  `(Cms|CountSketch)` and `(CmsWithHeap|CountSketchWithHeap)` into shared
  match arms, building `CmsAccumulatorUpdater`/`CmsHeapAccumulatorUpdater`
  (min-of-rows CMS math) for CountSketch-family sids.
- `otel.rs`'s modified-OTLP decode/delta-bootstrap/delta-apply for
  heap-bearing `SketchKind::CountSketch` frames used
  `CountMinSketchWithHeap`/`CountMinSketchWithHeapAccumulator` — the two
  families share a byte-identical wire envelope (heap is the
  distinguishing payload), which let this compile and round-trip, but
  reads a real CountSketch matrix through CMS's min-of-rows estimator.

Adds `CountSketchAccumulator::{query_key, MultipleSubpopulationAggregate,
MergeableAccumulator}` (previously missing; its `query_statistic`'s
keyed lookup also used a hand-rolled, non-hash-spec-compatible hasher —
now routes through the real `asap_sketchlib::CountSketch::estimate`) and
a new `CountSketchWithHeapAccumulator` (structural port of
`CountMinSketchWithHeapAccumulator` wrapping the real
`asap_sketchlib::CountSketchWithHeap`), then wires both through
dedicated `CountSketchAccumulatorUpdater`/`CountSketchWithHeapAccumulatorUpdater`
and fixes all four otel.rs call sites to use them.

The two known pre-existing e2e failures
(`controller_plan_to_query_full_roundtrip_{cms,count_sketch}_with_heap_topk`)
are unaffected — confirmed identical on origin/main before this change,
so they're a separate routing issue, not this bug.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@zzylol
zzylol merged commit 80ffbc1 into main Jul 27, 2026
zzylol added a commit that referenced this pull request Jul 27, 2026
…t plan

Rebased onto current main (was 27 commits behind, predating #416/#417/#418)
and updated the doc's content to match:

- Status note: SummaryExecutor now covers the Frequency family and
  ExactAgg(Sum/Increase) candidate matching + coverage tracking, not just
  quantile/cardinality -- these landed since the doc was last synced.
- "Today"/gap list: gap 2 (merge only existed for ExactAgg) and gap 3
  (nothing checked param agreement) are now resolved on the new path,
  marked accordingly rather than left as open problems.
- SidHandle/GroupState table entries: updated to describe the actual
  enum shape (Sketch/ExactAgg variants), not the original sketch-only
  struct design.
- New "Architecture reference" section citing ASAPController design.md's
  "Serving-time execution" section directly -- the planning-vs-serving
  split this doc's Rollout section builds on.
- "Rollout" section: replaces "still open" with an actual plan. Corrects
  a real error in the previous version -- it named
  `implement_promql_for_asap_tier` as "the seam" for tree construction,
  but that function uses the naive DefaultCostModel and has a documented,
  tracked gap where it can't realize the Frequency intent at all. The
  correct seam is `sketch_algebra::lower::bind_query_expr`
  (ControlPlaneCostModel, what main.rs's real production pipeline uses).
  Also documents why rate()/topk-over-rate/outer-agg-fold must be
  excluded from the shadow comparison entirely (not just deprioritized)
  and why shadow mode -- not a cutover -- is this phase's actual scope.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@zzylol
zzylol deleted the feat/countsketch-write-side-accumulators branch September 12, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant