Repository navigation
Conversation
zzylol
force-pushed
the
refactor/1203-2a-3-topk-finer-aggregate
branch
from
November 5, 2026 16:01
c4f1267 to
9fbfc54
Compare
zzylol
force-pushed
the
refactor/1203-2a-4-rollup
branch
from
November 5, 2026 16:21
a2f8f18 to
0373b2e
Compare
zzylol
force-pushed
the
refactor/1203-2a-3-topk-finer-aggregate
branch
from
November 5, 2026 17:23
9fbfc54 to
7e3d360
Compare
zzylol
force-pushed
the
refactor/1203-2a-4-rollup
branch
from
November 5, 2026 17:38
0373b2e to
280a6d4
Compare
zzylol
force-pushed
the
refactor/1203-2a-3-topk-finer-aggregate
branch
from
November 5, 2026 20:19
7e3d360 to
e8f39e8
Compare
zzylol
force-pushed
the
refactor/1203-2a-4-rollup
branch
from
November 5, 2026 20:25
280a6d4 to
e707a43
Compare
zzylol
force-pushed
the
refactor/1203-2a-3-topk-finer-aggregate
branch
from
November 5, 2026 21:13
e8f39e8 to
c418afa
Compare
zzylol
force-pushed
the
refactor/1203-2a-4-rollup
branch
from
November 5, 2026 21:13
e707a43 to
ac7fffd
Compare
Rules 6 (rollup) and 7 (window rollup) add their reader copies through `add_candidate_over_groups`, and rule 6's exact value producer through `find_or_add_producer`, so a rollup's regrouping merge and finalization are groups. Their rewritten nodes find the groups they repeat by Stage 0's equality, so the rule's own rebinding (`restore_inputs`, `reuse::same_node`, `combined_inputs`) is deleted, and with the last users gone, `append_reader` and `append_producer`. Second review fixes, folded in on the rebase: the rewritten roots are taken out of the rule's result by value (no Rc::clone rebinding), owners are MemoGroupId, and find_or_add_producer has no budget-parts argument. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6br9PL4SDeVS1XpezKJ
…wn to the shared state select_rollup chooses, for each query, its own summary candidate and the candidates on a path of groups from it to the shared build (a rollup's regrouping merge is now a group of its own), instead of one reader group found through groups_read_through_added_groups. Its test_support re-export, now unused, is deleted; the interim helpers are crate-private. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1M6br9PL4SDeVS1XpezKJ
zzylol
force-pushed
the
refactor/1203-2a-3-topk-finer-aggregate
branch
from
November 5, 2026 21:24
c418afa to
a81ad4e
Compare
zzylol
force-pushed
the
refactor/1203-2a-4-rollup
branch
from
November 5, 2026 21:24
ac7fffd to
947d5b3
Compare
Contributor
Author
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.
Stacked on #1220; part of #1203, tracked in #1207 (PR 2a-4).
Merge unit. This PR merges into main only together with the rest of #1207's merge unit (steps 1a–6, #1207 "Order"): interim items below are deleted by a later PR in the unit.
Why
#1203 decided one operator per candidate, every intermediate result its own memo group. After #1220, rollups (rules 6 and 7) are the last users of the old chain-adding helpers: they still add consumer chains such as
SummaryEstimate ← SummaryMerge(regroup)and rebind rewritten nodes to group nodes with their own equality.What
add_rollup_candidates) and 7 (add_window_rollup_candidates) add their consumer copies as one operator over groups (add_candidate_over_groups): the regroupingSummaryMerge, and for an exact rollup the finalization and its value producer, are groups. Rule 6's exact value producer is found or added with Stage 0's equality (find_or_add_producer).restore_inputs,reuse::same_node,combined_inputs), and with their last users gone,append_readerandappend_producer.New abstractions not in #1207 or the doc: decisions (2026-11-05)
Per #1207's interface policy, these names are not defined by #1207, #1203 or section 3 of
memo-groups-properties-requirements.md. #1207's steps 1a–6 merge into main as one merge unit (#1207, Order), so an interim abstraction may stay in this PR only when a later PR of the unit deletes it; none reaches main. Rows marked Pending approval are not deleted by any PR in the unit and need the user's decision.append_reader,append_producer,combined_inputs,restore_inputs,reuse::same_nodepath_to_state(private test helper,integration-tests/src/lib.rs)How
reuse::add_candidate_over_groups(refactor(stage1): summary readouts and inputs as one operator over groups; Memo::add_candidate; one node equality in Pass 1 (#1203 2a-2) #1218) with the rewritten coarse / fine roots, where they calledrestore_inputsand thenappend_reader.reuse::find_or_add_producerfor the finalized value it shares, where it calledappend_producer.integration-tests'select_rollup(the fixed plans the rollup tests price) now follows each query's path of groups from its own summary candidate down to the shared build, since the regrouping merge sits one group lower than before; it no longer needsgroups_read_through_added_groups, whosetest_supportre-export is deleted.Representation / rules / enumeration
find_or_add_group. Their matching is unchanged: rule 6 still takes a Pass 1 or widened-scan candidate's private build or its build input group (build_of, placesPrivate/InputGroup); rule 7 still reads tumbling-window candidates' private chains (Private).Key code interfaces added / modified
crates/logical-asap-optimization/src/pass2/memo/rules/reuse.rs(crate-internal)crates/logical-asap-optimization/src/added_groups.rsUsage. No rollup fires on the KLL example;
asap_planner --workload kll.json --run-until stage1_pass2 --format text(and the scan-widening workload) print byte-identical output before and after. A workload where rule 6 fires:quantile by (host, job) (0.5, data)andquantile by (job) (0.5, data), rankmax_error 0.01, failure probability 0.001, every 10 s,data10,000 gauge series every 15 s.asap_planner --run-until stage1_pass2 --format text, Pass 2 output:Major algorithm changes
None.
Before this PR
Rollups rebuilt their rewritten roots over group nodes with their own equality (
restore_inputs/reuse::same_node, guarantees compared only for states) and added consumer chains (append_reader) and producer groups (append_producer).After this PR
Rollups add one operator over groups; Stage 0's equality is the only one the Pass 2 reuse rules use to find groups.
Deleted
reuse.rs:restore_inputs,same_node,append_producer,append_reader,combined_inputs.test_support's re-export ofgroups_read_through_added_groups(no user left);added_groupsitems are nowpub(crate).select_rollup's one-level consumer lookup throughgroups_read_through_added_groups(nowpath_to_state).state_groups::tests::sketch_rollup_exposes_shared_finer_stateandgrouped_window_rollup_exposes_one_finer_chainnow look for the rollup's regrouping-merge group over the finer build (they looked for aSharedBuildconsumer of a private rollup chain);rollup::tests::a_rollup_reads_the_finer_query_result_itselfchecks that the coarse rollup reaches the finer query's group through its own groups;state_groups::tests::same_capacity_readers_retain_distinct_failure_probability_contractstestsadd_candidate_over_groups(and that an equal candidate is not added twice).Plan cost, Stage 2 candidates and planning time
UPDATE_SNAPSHOTS=1left every snapshot file unchanged. Stage 2 physical candidates and--run-until stage3wall time per snapshot input, #1220 vs this PR, release builds on one host:Second review fixes (folded into
bb7d4a8)Rc::clonerebinding inrollup.rs. Both rules take the two rewritten roots out of the rule's result by value (<[QueryRoot; 2]>::try_from), not as borrowed slices that were then cloned.build_of:PrivateorInputGroup, assimple_build/input_group_builddid (a widened consumer whose build is beneath groups after refactor(stage1): scan widening as one operator over groups; one exact-guarantee strip (#1203 2a-5) #1222 is checked there: no rollup is lost);Privatechains, assimple_builddid;MemoGroupId;find_or_add_producerhas no budget-parts argument;added_groupshas noworkload_groups: Stage 0's group count is onMemo.Notation (formulation → code)
MemoGroup, idMemoGroupId(rollup ownerscoarse_group,fine_group)add_candidate_over_groupsSummaryMergegroup (and, for an exact rollup, the finalization and value groups)Concepts not in the formulation
build_of,BuildPlace), Stage 0 groups, added groups, producer, accuracy budget parts: see refactor(stage1): Pass 1 adds a memo group for every intermediate result (#1203 PR 2a-1) #1215 / refactor(stage1): summary readouts and inputs as one operator over groups; Memo::add_candidate; one node equality in Pass 1 (#1203 2a-2) #1218.Second review verification (
bb7d4a8)cargo test -p asap-types --lib: 146 passed.cargo test -p asap-logical-asap-optimization --lib: 198 passed.cargo test -p asap-integration-tests --test integration -- memo_enumeration reuse_rules operator_sharing sharing_issue_regressions finer_aggregate_reuse planner_layering_example having_shared_aggregate stage1_logical_asap_optimization joint_search_equivalence sketch_rollup rollup_controlled production_rollup_workloads: 154 passed, 23 ignored (pre-existing).cargo test -p asap-devtools --lib: 18 passed.--test devtools -- asap_planner:: asap_planner_acceptance:: memo_pricing::: 56 passed, 1 ignored.UPDATE_SNAPSHOTS=1 cargo test --release -p asap-devtools --test corpus_snapshots -- --include-ignored: 9 passed, no file changed.--run-until stage1_pass2 --format text: byte-identical toa2f8f18.cargo fmt --all;cargo clippy --workspace --all-targets -- -D warnings: clean.asap_planner --run-until stage1_pass2 --format text: byte-identical to the pre-review heada2f8f18on 35 workloads besides the two examples: the reviewer's 20 workloads, six rollup / scan-widening /avgworkloads, five earlier finer-aggregate, rollup, top-k and scan-KLL examples, andrandom-mixed-seed-862workloads 01–04.Restack on #1218 (
b8402c7)Rebased on #1218's interface alignment: the doc's
Memo::add_candidatereplacespush_candidate_if_new(same equality; returns the candidate'sCandidateForMemoGroupId), and #1218's CI fix ofsketch_rollup::quantiles_rolled_up_keep_the_sketch_bound. Plans unchanged.cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings: clean.cargo test -p asap-logical-asap-optimization --lib: 198 passed.cargo test -p asap-integration-tests --test integration -- rollup sketch_rollup production_rollup_workloads reuse_rules: 25 passed.Restack (2026-11-05)
On #1215's consumer naming (
build_of→build_of) and #1218's one node equality in Pass 1.cargo fmt --all -- --check;cargo clippy --workspace --all-targets -- -D warnings: clean;cargo test -p asap-logical-asap-optimization --lib: 197 passed.Viewer
Viewer tests not updated for the group shape (#1203 decision 6);
viewer_contractpasses.Verification
cargo test -p asap-logical-asap-optimization --lib: 198 passed.cargo test -p asap-physical-asap-optimization: 29 passed.cargo test -p asap-plan-selection --lib: 142 passed.cargo test -p asap-devtools --lib: 18 passed.cargo test -p asap-integration-tests --test integration -- memo_enumeration reuse_rules operator_sharing sharing_issue_regressions finer_aggregate_reuse planner_layering_example having_shared_aggregate stage1_logical_asap_optimization joint_search_equivalence sketch_rollup rollup_controlled production_rollup_workloads: 154 passed, 23 ignored (pre-existing).sketch_rollup_planningandrollup_controlled::memo_offers_one_kmv_build_and_a_rollupprice the same build-plus-rollup plans as before (throughpath_to_state);rollup_controlled's production search still selects one KMV build and a rollup.cargo test -p asap-devtools --test devtools -- asap_planner:: asap_planner_acceptance:: memo_pricing:: viewer_contract::: 58 passed, 1 ignored.UPDATE_SNAPSHOTS=1 cargo test --release -p asap-devtools --test corpus_snapshots -- --include-ignored: 9 passed, no file changed.cargo fmt --all;cargo clippy --workspace --all-targets -- -D warnings: clean.--run-until stage1_pass2 --format text: byte-identical to refactor(stage1): top-k reuse and finer-aggregate reads as one operator over groups (#1203 2a-3) #1220's head.Left for 2a-5..k
Scan widening (2), tumbling windows (1), state configurations (9) and step 10, then deleting
direct_input_builds,BuildPlace::Private,same_range_input,SharedBuildandSummaryResult, and the interimadded_groupshelpers.