feat: share identical summary producers across queries after Pass 1 - #515
Merged
Merged
Conversation
Two queries can select structurally identical summary producers that pre-ASAP CSE cannot merge: identical ungrouped expressions (no unique key) and readouts over one producer with equal parameters (p50 and p99 of one window and accuracy reading one KLL). Each was costed and deployed as its own state. Selection now groups finalized summary candidates of different targets whose outermost SummaryAgg interns to the same node, costs that state once against the union of the targets' entries, and offers each member an equal split through CandidateCostOverrides. A class whose shared state has no selectable lifecycle stays independent; if selection leaves any member elsewhere, that class reverts to independent costs and selection runs once more. MajorPass assembles every root, runs share_common_summary_subtrees once across them, and plans each root's lifecycle with the entries of every root that reaches its shared states, so a shared SummaryAgg is one Rc with one lifecycle across QueryLifecyclePlans. PlanOutput is not deduplicated; consumers dedupe deployments by Rc pointer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 2, 2026
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 (ASAP-aware CSE): structurally identical summary producers chosen by different queries should be built and maintained once, and selection should cost them once.
On main, pre-ASAP CSE already shares identical subtrees that have a unique key. Two cases were not shared: different targets whose Pass-1 candidates contain the same
SummaryAgg, and identical ungrouped queries. Each paid full maintenance and was deployed separately.What
This wires the existing
share_common_summary_subtrees(crates/types/src/post_asap/cse.rs) into planning. No new types.It covers the identical-expression rule and the equal-params subset of the summary-capability rule. Example:
quantile_over_time(0.5, lat[5m])andquantile_over_time(0.99, lat[5m])read one KLL.summary_maintenance_lifecycle.rs):SummaryAgginterns to the same node form a class.CandidateCostOverrides. Independent candidates stay.major.rs): MajorPass assembles all roots, runs CSE once, then plans lifecycles. A sharedSummaryAggis thereforeRc::ptr_eqacrossQueryLifecyclePlans.PlanOutputdocuments that consumers dedupe deployments byRcpointer.Tests
New file
crates/planner/tests/summary_sharing.rs, run throughe2e_plan/ MajorPass:lat[10m], an ε that changes the KLL params, and{job="a"}vs{job="b"}.sum(rate(x[5m]))share both their states.approx_percentile_contqueries share.Revert path: unit test
sharing_class_reverts_when_a_member_selects_elsewhere. It fails with the revert step disabled.Known limitations
Validation
Rust 1.99: fmt, clippy
-D warnings, the MetricsQL baseline andcargo test --workspace(1499 passed on the pre-rebase base). The rerun on current main is in progress locally and in CI.🤖 Generated with Claude Code