feat: size shared summaries for the strictest consumer - #519
Merged
Merged
Conversation
Pass 1 also sizes each sketch candidate for the strictest sibling that reads the same summary input (same child, grouping, filters and intent apart from accuracy and quantile rank), so post-ASAP CSE can share one state across consumers with different accuracy targets (#509 summary- capability rule). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
#509, logical Pass 2, summary-capability rule: when several computations have the same summary input data and window, one summary should serve all of them, sized for the strictest accuracy requirement. After #515 and #516, identical states are already shared, including p50 and p99 at equal accuracy. Queries whose accuracy targets differ still produce different sketch parameters, so they never share. Example: p50 at ε=0.01 and p99 at ε=0.001 over
lat[5m].What
All in
crates/asap-aware-mapping/src/replacement.rs, about +110 lines.strictest_sibling_accuracyfinds sibling targets: single-measure aggregates with the same child, grouping and filters, and the same intent apart from accuracy. A quantile's rank may also differ, since it is only a readout parameter. It returns the tightest ε/δ across them when that is stricter than the target's own.search_cse_workload_withpasses the result throughTargetSubDAG.strictest_sibling_accuracy.SketchAlgorithmStrategythen adds one extra candidate per sketch, re-sized with the existingsize_params, but only if the parameters actually change. Each reader's guarantee is recomputed from the new parameters and its own readout.share_common_summary_subtreesnow documents that sharing identical states is the summary-capability rule.UnivMon sizing is fixed, so it gets no variant. Its distinct, entropy and L2 readouts already share one state when certified.
Not changed: accuracy gates,
capability.rs, andAccuracyReconciliationStrategy. No DDSketch Count candidate is added.Candidate growth
A target gains at most one extra candidate per sketch algorithm, and only when a stricter matching sibling exists.
Tests
New or updated in
crates/planner/tests/summary_sharing.rs:quantiles_share_one_producer_sized_for_the_strictest_consumer: p50 at ε=0.01 and p99 at ε=0.001 share one KLL. Its k is the ε=0.001 sizing, and both guarantees meet their own ε. Planned alone, the ε=0.01 query keeps its own sizing. The test fails when the new sibling field is forced toNone.different_producers_are_not_shared: dropped the old "different accuracy is not shared" case, because that sharing is now intended. Added stricter-accuracy cases with a different window or selector, which still don't share.certified_frequency_readouts_share_one_univmon_state: distinct, entropy and L2 share one UnivMon state under a test accuracy model that certifies them. This test reproduces the MajorPass steps directly instead of going throughe2e_plan, because MajorPass gives its accuracy model only to the final root check, not to the Pass 1 strategies. That will be tracked separately.Notes
When siblings disagree on which of ε or δ is tighter, the variant takes the tightest of each. The result satisfies every sibling, though no single query asked for exactly that pair.
Validation
On Rust 1.99, all of these pass:
cargo fmt --check, clippy with-D warnings, the vendored MetricsQL baseline, andcargo test --workspace.🤖 Generated with Claude Code