Repository navigation
refactor(stage1): one same_family, boundary_ptrs/nodes_within helpers, dead Pass 2 code (#1096) - #1193
Merged
Conversation
milindsrivastava1997
marked this pull request as ready for review
November 3, 2026 03:45
milindsrivastava1997
left a comment
Collaborator
Author
There was a problem hiding this comment.
Automated code review (Claude Code); findings are unverified.
crates/logical-asap-optimization/src/pass2/memo/shared_configurations.rs:185: Behaviour change:stage0::cse::same_valuereturns false when serialization fails, whereas the oldsame_familycomparedto_string(..).ok() == to_string(..).ok()and returned true when both sides failed. For such a type,serves_size/TumblingWindowConfiguration::servesnow return false and thesizesdedup intumbling_window_configurations_beforecan push duplicates. Not a pure de-duplication.crates/logical-asap-optimization/src/pass2/memo/rules/topk.rs:293:exact_input_groupnow collects every node within the boundaries into a Vec before calling.any(); the old loop short-circuited at the first non-exact summary. That is extra walking and allocation on a deadline-guarded path, repeated on every recursive call. An early-exit walk would keep the old cost.crates/logical-asap-optimization/src/pass2/memo/state_groups.rs:391:nodes_withinhas nocheck_generation_deadline, but the inlined loops it replaces infactor_summary_inputs/factor_summary_resultschecked the deadline on every popped node. On a large DAG the whole traversal now runs before any deadline check.crates/logical-asap-optimization/src/pass2/memo/state_groups.rs:338: Partial de-duplication:boundary_groupsanddirect_input_buildsstill hand-roll the samepending/seenDFS, and boundary-map construction is still inline (~line 183, and in tests ~1531, ~1610). These can drift fromnodes_within; child order already differs (boundary_groupspushes children reversed).
…ss1 → pass2 imports (#1096) `pass2/memo/groups.rs` (`try_populate_pass1`, `NodeToStructuralIdCache`) and `pass2/memo/candidates.rs` (`CandidatePopulationError`) are Pass 1 code. They move into `pass1/memo_population.rs`, so Pass 1's production code imports nothing from Pass 2. `tests/pass_layering.rs` enforces the direction; Pass 2 → Pass 1 remains (#1191). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, dead Pass 2 code (#1096) - The two identical `same_family` copies use `stage0::cse::same_value`; `asap_aware_cse`'s differently-meant one is `same_build_family`. - `boundary_ptrs` and `nodes_within` replace 4 copies of a candidate's boundary set and 3 copies of the walk above it (same visit order). - Delete `Pass2RuleError::InvalidReaderBoundary` (never constructed) and the test-only `may_change_rollup_candidate`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
milindsrivastava1997
force-pushed
the
1096-stage1-layering
branch
from
November 4, 2026 01:46
f46d3c7 to
40ee8d6
Compare
milindsrivastava1997
force-pushed
the
1096-stage1-cleanup
branch
from
November 4, 2026 01:46
6375104 to
c85e82e
Compare
milindsrivastava1997
changed the base branch from
1096-stage1-layering
to
main
November 4, 2026 01:56
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
Part of #1096 (Stage 1 duplicate and dead code). Stacked on #1192; review only the top commit.
What
same_family: two identical copies (pass2/memo/shared_configurations.rs,pass2/memo/rules/shared_configuration_readers.rs) are replaced bystage0::cse::same_value(typed equality plus serialized equality). The third copy, inasap_aware_cse.rs, means "can be one build" (same algorithm and grouping at any size), so it is renamedsame_build_family.pass2/memo/state_groups.rs:boundary_ptrs(memo, candidate): the nodes of a candidate's input groups. Replaces 4 copies (shared_configuration_readers,summary_inputs,summary_results,topk).nodes_within(root, boundaries): the candidate's own nodes, depth-first, each once. Replaces 3 copies of the walk (summary_inputs,summary_results,topk).direct_input_buildskeeps its own walk: it keys boundaries by group.Pass2RuleError::InvalidReaderBoundary(never constructed) and the test-onlymay_change_rollup_candidate, along with the test assertions that exercised only that helper.How
The helpers visit nodes in the same order as the loops they replace, so the candidate order doesn't change.
topk's walk used to stop at the first approximate build; it now collects the nodes and then checks them withany. The result is the same, though the walk is no longer cut short.same_valuereturnsfalseif serialization fails, while the oldsame_familyreturnedtruewhen both sides failed.FieldDataTypealways serializes, so this has no observable effect.Key code interfaces added / modified
Crate-private only:
Pass2RuleErrorlosesInvalidReaderBoundary(public enum; nothing constructed or matched it).Major algorithm changes
None.
Before this PR
Each of
summary_inputs,summary_resultsandtopkhad its own copy of this:After this PR
Snapshot changes
None expected. The corpus snapshots weren't run locally (they're heavy on this machine), so CI is the check.
Verification
cargo test -p asap-logical-asap-optimization --all-targets: 207 passed, 1 ignored;pass_layering1 passed.cargo test -p asap-integration-tests --test integration -- memo_enumeration reuse_rules stage1_logical_asap_optimization sharing_issue_regressions rollup_controlled tumbling_window_merge finer_aggregate_reuse operator_sharing: 76 passed, 21 ignored.cargo clippy -p asap-logical-asap-optimization --all-targets: 0 warnings.cargo fmt: clean.🤖 Generated with Claude Code