Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/integration-tests/tests/memo_enumeration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ fn choices_whose_candidates_read_each_other_are_left_out() {
.expect("a pair of groups whose candidates read each other");
assert!(matches!(
build_logical_asap_dags_from_chosen_candidates(memo, &mutual.into()),
Err(asap_logical_asap_optimization::pass2::memo::enumeration::ErrorBuildingLogicalAsapDagsFromChosenCandidates::Cycle { .. })
Err(asap_logical_asap_optimization::pass2::memo::enumeration::ErrorBuildingLogicalASAPDagsFromChosenCandidates::Cycle { .. })
));
let enumeration = enumerate(memo, 2_000);
assert!(!enumeration.all_chosen_candidates.is_empty());
Expand Down
14 changes: 7 additions & 7 deletions crates/logical-asap-optimization/src/pass2/memo/enumeration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub struct AllChosenCandidatesPerMemoGroup {

/// A choice that does not compose.
#[derive(Debug, thiserror::Error)]
pub enum ErrorBuildingLogicalAsapDagsFromChosenCandidates {
pub enum ErrorBuildingLogicalASAPDagsFromChosenCandidates {
#[error("group {group:?} has no candidate {candidate}")]
NoSuchCandidate {
group: MemoGroupId,
Expand Down Expand Up @@ -133,24 +133,24 @@ pub fn enumerate(memo: &CandidateMemo, limit: usize) -> AllChosenCandidatesPerMe
pub fn build_logical_asap_dags_from_chosen_candidates(
memo: &CandidateMemo,
chosen_candidates: &ChosenCandidatePerMemoGroup,
) -> Result<Vec<(MemoGroupId, Rc<OperatorNode>)>, ErrorBuildingLogicalAsapDagsFromChosenCandidates>
) -> Result<Vec<(MemoGroupId, Rc<OperatorNode>)>, ErrorBuildingLogicalASAPDagsFromChosenCandidates>
{
fn composed(
memo: &CandidateMemo,
group: MemoGroupId,
chosen_candidates: &ChosenCandidatePerMemoGroup,
done: &mut HashMap<MemoGroupId, Rc<OperatorNode>>,
composing: &mut HashSet<MemoGroupId>,
) -> Result<Rc<OperatorNode>, ErrorBuildingLogicalAsapDagsFromChosenCandidates> {
) -> Result<Rc<OperatorNode>, ErrorBuildingLogicalASAPDagsFromChosenCandidates> {
if let Some(found) = done.get(&group) {
return Ok(Rc::clone(found));
}
if !composing.insert(group) {
return Err(ErrorBuildingLogicalAsapDagsFromChosenCandidates::Cycle { group });
return Err(ErrorBuildingLogicalASAPDagsFromChosenCandidates::Cycle { group });
}
let index = chosen_candidates.get(&group).copied().unwrap_or(0);
let candidate = memo.candidates[group.0 as usize].get(index).ok_or(
ErrorBuildingLogicalAsapDagsFromChosenCandidates::NoSuchCandidate {
ErrorBuildingLogicalASAPDagsFromChosenCandidates::NoSuchCandidate {
group,
candidate: index,
},
Expand All @@ -164,7 +164,7 @@ pub fn build_logical_asap_dags_from_chosen_candidates(
let old = &memo.groups[child.0 as usize].logical_node;
if !own_nodes.contains(&Rc::as_ptr(old)) {
return Err(
ErrorBuildingLogicalAsapDagsFromChosenCandidates::ChildNotInCandidate {
ErrorBuildingLogicalASAPDagsFromChosenCandidates::ChildNotInCandidate {
group,
candidate: index,
child,
Expand Down Expand Up @@ -195,7 +195,7 @@ pub fn build_logical_asap_dags_from_chosen_candidates(
)?),
))
})
.collect::<Result<Vec<_>, ErrorBuildingLogicalAsapDagsFromChosenCandidates>>()?
.collect::<Result<Vec<_>, ErrorBuildingLogicalASAPDagsFromChosenCandidates>>()?
.into_iter()
.unzip();
let roots = recompose_guarantees(&roots).map_err(PerComputationCandidateError::from)?;
Expand Down
4 changes: 2 additions & 2 deletions docs/design_docs/proposals/planner-layering.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ that vector.
3. `recompose_guarantees` then runs over the roots, as plan reconstruction
does: every node is rebuilt with the schema and guarantee derived from
the children chosen, not the ones its candidate had alone.
4. `ErrorBuildingLogicalAsapDagsFromChosenCandidates` reports a candidate index the group does not have
4. `ErrorBuildingLogicalASAPDagsFromChosenCandidates` reports a candidate index the group does not have
(`NoSuchCandidate`, bad input), a child group whose node is not in the
candidate (`ChildNotInCandidate`, a memo construction bug), or a
DAG whose schemas or guarantees cannot be re-derived (`Recompose`).
Expand Down Expand Up @@ -529,7 +529,7 @@ is in `crates/plan-selection/src/search/`.
| Pass 1 | `generate_per_computation_candidates_with_memo` and `without_unsupported_summaries` (the inventory); `generate_per_computation_logical_memo_candidates` → `PerComputationLogicalMemoCandidates` (the memo: `try_populate_pass1`, exported from `pass2::memo::candidates`, then the accuracy-scoped candidates) | `pass1/per_computation_candidates.rs`; `pass1/logical_memo_candidates.rs`; `pass2/memo/groups.rs` |
| Memo types | `CandidateMemo`, `CandidateForMemoGroup`, `OriginOfCandidateForMemoGroup`, `LogicalASAPMemoCandidates`, `CandidateGenerationTimeout`, `root_groups`, `queries_rooted_at` | `crates/types/src/stages/` (`asap_types::stages`) |
| Pass 2 | `generate_logical_asap_memo_candidates` → `LogicalASAPMemoCandidates`, one pane-width round over a `Pass2RoundState` (kept between rounds: the memo after step 1 and before the rules, and the widths already generated). It calls in this order: 1. window composition for the round's new widths (`extend_local_window_composition`); 2–9. the rules in `pass2/memo/rules/`: scan widening, summary inputs, top-k reuse, finer aggregate, rollup, window rollup, summary results, state configurations; 10. `add_shared_summary_state_groups`, the shared builds | `pass2/logical_memo_candidates.rs` (`LogicalASAPMemoCandidates` itself: `asap_types::stages`); `pass2/memo/window_candidates.rs`, `pass2/memo/rules/`, `pass2/memo/state_groups.rs`, `pass2/memo/shared_configurations.rs` |
| Memo to candidate DAGs | `enumerate`, `build_logical_asap_dags_from_chosen_candidates`, `ChosenCandidatePerMemoGroup`, `AllChosenCandidatesPerMemoGroup`, `ErrorBuildingLogicalAsapDagsFromChosenCandidates` | `pass2/memo/enumeration.rs` (module `pass2::memo::enumeration`) |
| Memo to candidate DAGs | `enumerate`, `build_logical_asap_dags_from_chosen_candidates`, `ChosenCandidatePerMemoGroup`, `AllChosenCandidatesPerMemoGroup`, `ErrorBuildingLogicalASAPDagsFromChosenCandidates` | `pass2/memo/enumeration.rs` (module `pass2::memo::enumeration`) |
| Production memo build and search | `run_stage1_to_stage3_with` builds the DAG of logical memo groups (`pipeline.rs`); `candidate_connection_search` (`route.rs`) builds the candidate memo for each pane-width round: query pruning (first round), `generate_per_computation_logical_memo_candidates` (first round), `generate_logical_asap_memo_candidates` (the `Pass2RoundState` is kept in `DomainProgress.pass2_round` between rounds); then `candidates/`, `milp/` and `refinement/` | `crates/plan-selection/src/search/` |

## ASAPPlanner Detailed Design: Planning Stages and their decisions/Strategies
Expand Down
Loading