Repository navigation
refactor: remove dead Pass 2 / choice candidate metadata and labels (#997) - #1063
Merged
milindsrivastava1997 merged 4 commits intoOct 30, 2026
Conversation
…997) Production never set LogicalCandidate.choice or .pass2, and the one test helper that did had no reader. Remove them with everything that only fed them: Pass2Candidate, Stage1Candidate, the internal Rules bookkeeping in workload_candidates, the rollup/top-k fields of RollupPass2Candidate and TopKReusePass2Candidate, and the devtools choice/pass2 labels with their helpers. stage1_candidates_of_choice now returns roots only. The rollup-over-panes unit test now checks roots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The pre-commit hook also trims trailing whitespace in planner-layering.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test now checks the plan shape (the fine sum's one build is a pane chain the coarse sum also reads) instead of recomputing it with the rule functions under test. Also: borrow the chosen rollup and top-k reuse candidates instead of cloning them, and name the alone-check loop variable `candidate`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…2-choice-candidate-metadata-and-labels # Conflicts: # docs/design_docs/proposals/planner-layering.md
zzylol
approved these changes
Oct 30, 2026
milindsrivastava1997
deleted the
997-remove-dead-pass-2-choice-candidate-metadata-and-labels
branch
October 30, 2026 01:37
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.
Closes #997.
Why
Production planning (the memo / joint search) always builds
LogicalCandidatewithchoice: Vec::new()andpass2: None. Only the test helperexplicit_assignment_plansfilled them, and its one caller never read them. Every type, field, and label that existed to carry or display that metadata was dead weight that each refactor still had to keep compiling.What
Removes the dead Pass 1 choice / Pass 2 metadata and everything that only fed it. No planner output changes: the same roots are produced in the same order, and production labels already took the roots-only branch.
How
LogicalCandidatekeeps onlyidandroots.stage1_candidates_of_choicereturns the roots directly. Its internal Pass 2 enumeration (Pass2List) no longer threads aRulesrecord through every rule; deduplication and ordering already depended only on roots.Rulesgone,RollupPass2Candidate.rollup_candidatesandTopKReusePass2Candidate.topk_reuse_candidateshad no readers, so they are removed too. The structs stay because many tests read their.roots.candidate_labelskeeps only the connected-DAG label.choice_label,pass2_label, and six helpers they alone used are deleted.Pass2Candidate.Key code interfaces added / modified
crates/plan-selection/src/search/pipeline.rscrates/logical-asap-optimization/src/pass2/workload_candidates.rscrates/logical-asap-optimization/src/pass2/asap_aware_cse.rscrates/devtools/src/candidate_labels.rs,planning_stages.rsEnd-to-end usage (unchanged for users):
stage_pipeline --promql 'sum(a)' --promql 'max(a)'→run_stage1_to_stage3_witharchivesLogicalCandidate { id, roots }→candidate_labelslabels each from its roots → the viewer JSON'sdisplay_name. Internally,alone_violationcallsstage1_candidates_of_choiceand plans each returnedroots. No numbers change.Major algorithm changes
None. The Pass 2 enumeration in
workload_candidatesvisits the same rules in the same order and deduplicates on the same flattened roots; it just stops recording which rules produced each candidate.Before this PR
LogicalCandidatecarriedchoiceandpass2: Option<Pass2Candidate>. Production always left them empty.stage1_candidates_of_choicebuilt aStage1Candidatewith a fullPass2Candidaterecord that only the test helper copied, and nothing read it. devtools had about 370 lines of labelling code for those fields that production never reached.After this PR
Logical candidates are
{ id, roots }everywhere, andstage1_candidates_of_choicereturns roots. A new Pass 2 rule no longer needs aPass2Candidatefield or a devtools label (extend-asap-aware-mapping.mdupdated). Net −548 lines.Evidence
Architecture-only removal; no behavior or performance change to measure. Evidence is the test suite below and
git grepshowing no remaining readers.Verification
cargo test -p asap-logical-asap-optimization -p asap-plan-selection -p asap-devtools -p asap-frontend-promqlpass.a_rollup_is_also_built_over_tumbling_panesis rewritten to check roots instead ofpass2metadata: it verifies that some Stage 1 candidate builds the fine sum as a singlePaneChainthat the coarse sum also reads (the coarse sum rolls up from it). Checked by mutation: it fails when the rollup branch no longer applies window composition.cargo test -p asap-integration-testspasses. In one full run,memo_covers_whole_workload_pass2::topk_reusefailed (memo cost above whole-workload). It then passed 3/3 when rerun alone. That test compares a time-limited MILP search against a 0.02% margin, so it is timing-sensitive under load, and this PR doesn't touch the memo search. Tracked in Planner tests depend on wall-clock search budgets and flake under load #1067.stage_pipeline::scans_projecting_different_labels_are_sharedflaked the same way in one pre-commit run (passed 2/2 alone).cargo fmt,cargo clippy --workspace --all-targetsclean; pre-commitcargo testpassed.Snapshot changes
None.
Architectural decisions
RollupPass2Candidate/TopKReusePass2Candidateas one-field structs rather than returning bare roots. Unwrapping them would touch many tests that read.rootsand buy nothing.stage1_candidates_of_choicereturnsVec<Result<..>>rather than a one-fieldStage1Candidate, since all its callers want only roots.Limitations and follow-up
SummaryCapabilityPass2Candidate.shared_builds,WindowCompositionPass2Candidate.pane_candidates) are kept..agents/skills/asap-code-review/SKILL.mdstill citesPass2Candidateas a historical refactor example. Left as is.planner-layering.md, which is most of that file's diff.Human review — do not complete with an agent
🤖 Generated with Claude Code