Conversation
zzylol
force-pushed
the
stack/509-w7a-pass2-sizing
branch
from
October 4, 2026 18:25
63d6468 to
3c07c2d
Compare
This was referenced Oct 4, 2026
zzylol
changed the base branch from
stack/509-e2-keyed-additive-topk
to
stack/509-w2-executor-panes
October 4, 2026 18:25
…riant Targets with the same summary input data and window (same input, grouping and quantile column) are re-sized for their strictest consumer, all or nothing per key (#580 W5), reusing the legacy reconciliation's accuracy_budget/dominates argument. Stage 1 adds this inventory as a third variant (Sharing::SummaryCapability) next to the independent and identical-expression ones; composition then builds identical summary producers, which are merged, and Stage 3 chooses. Also: - the tree DP now checks coupling between targets that read a common (or equal) input; it skipped those pairs, so it missed merged producers; - a composed summary evaluation keeps the measure's explicit output name (SQL), instead of the derived one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zzylol
force-pushed
the
stack/509-w7a-pass2-sizing
branch
from
October 5, 2026 06:21
3c07c2d to
cf0df8a
Compare
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.
Rebased on main d4869a7 (DF 54).
Wave 1 chain: #594 → #593 → #592 → #591 → #595 → #596 → #597 → #598 → #599 (on #589)
Part of #509 (Pass 2), #580 item D, decision W5.
Why
Stage 1 only planned Pass 2's identical-expression rule. Two queries that read the same input with different accuracy requirements, or different quantiles at the same requirement over an unkeyed SQL scan, never shared a summary. #509's summary-capability rule allows one summary sized for the strictest consumer.
What
pass2::summary_capability: targets with the same summary input data and window (same input sub-DAG includingTimeRange/WHERE, same grouping, same quantile column, approximate requirement) form a key. Every target of a key is re-sized for the strictest requirement (smallest ε and δ), all or nothing per key (W5). Sizing reuses the legacy reconciliation's argument (accuracy_budget;dominatesis checked): requirements resolve to(ε, δ)and the sizing formulas are monotonic. First family: quantiles (KLL, DDSketch), so one KLL serves p50 and p99.Sharing::{Independent, IdenticalExpressions, SummaryCapability}.SharingVariant.shared: boolis replaced bysharing: Sharing. The capability variant is built on the identical-expression inventory and merges identical producers after composition. It is skipped when it would repeat that variant. Stage 3 checks each query against its own target and chooses.plan_selection::select_variant): pairs of targets reading a common input were collected but never checked. The loop required one to read the other. Merged producers were therefore missed. The DP now checks those pairs, and compares inputs by value too (SQL scans have no unique key, so CSE does not alias them).Before / After
quantile(0.5, lat)andquantile(0.99, lat), ε = 0.01, through the facade (stage_pipelinenumbers, 15k samples):p50 at ε = 0.01 and p99 at ε = 0.001 over
lat[5m]: Before, the two KLLs differ (k for 0.01 and for 0.001) and never merge. After, the summary-capability variant sizes both for ε = 0.001, and the plan deploys one KLL (stage_pipeline_shares_one_kll_sized_for_the_strictest_consumer).Tests
crates/planner/tests/summary_sharing.rs:cross_series_p50_and_p99_share_one_producer,quantiles_with_equal_params_share_one_producer,identical_sql_percentiles_share_one_producer.quantiles_share_one_producer_sized_for_the_strictest_consumer: the sharing assertions pass. The pipeline attaches no guarantee to plan roots, and Stage 3 ignoresPlanningModels.cost, so alone the looser query selects raw.sql_p50_and_p99_share_one_producer: the shared half now passes, names included. The unshared negative cases select raw, since a query-time summary never costs less until Stage 2 materializes.stage_pipeline_shares_one_kll_sized_for_the_strictest_consumerandstage_pipeline_shares_sql_p50_and_p99cover the passing halves, plus 3 unit tests for the rule and 3 DP-equals-exhaustive tests with sharing (PromQL, PromQL plus an unrelated query, SQL). Two of the DP tests fail without the coupling fix.Gate
fmt and clippy (
-D warnings) are clean.cargo test --workspace: 1,528 passed and 7 ignored, against #589's 1,517 and 10. That is 3 un-ignored plus 8 new tests. The Example 1 fixture regenerates byte-identically throughstage_pipeline, because no capability key applies there.Gaps
🤖 Generated with Claude Code