Skip to content

[Refactor] Centralize planner and backend accuracy formulas #707

Closed

Description

@milindsrivastava1997

What to build

Centralize the shared CMS, HLL, KLL, and DDSketch accuracy formulas in asap_types, with a small interface over normalized family parameters. The control plane and data plane should retain only their source-specific parameter extraction and any backend-only augmentation, then derive the same AccuracyProfile through the shared formulas.

This removes the current duplicated policy logic while preserving the physical-plan compile, publish, install, and serving behavior.

Acceptance criteria

  • Each shared sketch-family formula has one authoritative implementation in asap_types.
  • Control-plane planning and data-plane serving derive equivalent AccuracyProfile values for identical normalized CMS, HLL, KLL, and DDSketch inputs.
  • Backend-specific behavior remains outside the shared formula module and is covered by focused tests.
  • A cross-crate parity test covers representative parameters for every supported shared family.
  • Existing physical-plan and query-serving tests continue to pass.

Blocked by

None - can start immediately

Activity

  1. milindsrivastava1997 commented on Sep 13, 2026

    @milindsrivastava1997
    ContributorAuthor

    pls check @zzylol if this makes sense

  2. milindsrivastava1997 commented on Sep 13, 2026

    @milindsrivastava1997
    ContributorAuthor

    Implementation references:

    • control_plane/src/accuracy.rs:1-92 owns planner derivation from SketchParams; the module header at lines 3-8 explicitly requires lockstep with the backend. CMS, HLL, KLL, and DDSketch formulas are at lines 52-89.
    • data_plane/src/storage_engines/sketch_db/accuracy.rs:50-259 owns backend derivation from installed AggregationConfig. The shared formula branches are CMS at 103-121, HLL at 199-215, KLL at 218-231, and DDSketch at 233-246. derive adds the backend-only GOS staleness term at 72-83.
    • crates/asap_types/src/accuracy.rs:1-55 already owns the shared AccuracyProfile / AccuracyKind wire contract and is the intended home for normalized formula primitives.
    • crates/asap_types/src/accumulator_spec.rs defines the typed AccumulatorSpec conversion from AggregationConfig; assess whether it can supply normalized family parameters without altering fingerprinted legacy wire fields.

    Keep backend-only aggregation families and the GOS augmentation outside the shared formula module.

  3. self-assigned this
    on Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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