Skip to content

Cross-consumer accuracy reconciliation for CSE sharing (near-duplicate AggIntents with different AccuracyTarget) #273

Description

@zzylol

Part of #33.

Gap

ReplacementStrategy candidate generation (SketchAlgorithmStrategy) sizes every sketch candidate from the AccuracyTarget embedded directly on the AggIntent at that one target — see accuracy_target/accuracy_budget/default_size_params in replacement.rs. That's correct and complete at single-target granularity.

At workload granularity, there is no reconciliation of accuracy requirements across consumers of what is conceptually the same computation. SharedSubtreeStrategy/PlanSpace only ever see a shared TargetSubDAG when pre-ASAP's share_common_subtrees has already merged two subtrees onto one Rc — and since AggIntent derives PartialEq over all its fields including accuracy, two otherwise-identical aggregates with different AccuracyTargets are never structurally equal, so they never merge. SharedSubtreeStrategy never gets a chance to propose "share" for them at all.

Concretely: if query A asks for quantile(0.99, x) at epsilon=0.01 and query B asks for the same quantile(0.99, x) at epsilon=0.05, this crate today builds two entirely independent candidate spaces for two entirely independent Rcs — there's no path to "build one sketch sized to the tighter bound (0.01) and let both consumers read from it," even though that would be strictly cheaper than building two.

Why this wasn't done in #259

Doing this correctly needs an accuracy-aware notion of "these two subtrees are close enough to share" that's looser than pre-ASAP CSE's exact structural PartialEq — a real design question (how loose is safe? does sharing at the tighter bound ever violate a looser consumer's own semantics — no, but does it change cost-model tradeoffs it should account for?) that #259 didn't have a driving use case for yet. Flagging as known future work rather than silently leaving it undiscoverable.

Possible shape (not a commitment, just a starting point)

  • A pre-pass (or a ReplacementStrategy-adjacent mechanism) that recognizes two AggIntents equal in everything except accuracy, and represents that relationship without requiring pre-ASAP CSE's stricter equality to change (accuracy still matters for correctness elsewhere; this is additive, not a relaxation of share_common_subtrees itself).
  • SharedSubtreeStrategy (or a new, narrower strategy) proposing "build once at the tightest of the group's accuracy requirements, all consumers read from it" as one more ReplacementSubDAG candidate — still exhaustive, still ranked by CostModel, not a forced choice.

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

    CSEaccuracyAccuracy requirements, guarantees, and propagationcost-modelCost formulas, statistics, ranking, and selectionenhancementNew feature or requestworkloadBatch, repeating, or multi-query workload modeling

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions