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
383 changes: 7 additions & 376 deletions crates/devtools/src/candidate_labels.rs

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions crates/devtools/src/planning_stages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use asap_frontend_sql::SqlCatalog;
use asap_logical_asap_optimization::pass1::per_computation_candidates::PerComputationCandidates;
pub use asap_logical_asap_optimization::pass2::workload_candidates::Pass2Candidate;
use asap_physical_asap_optimization::PhysicalWorkloadPlan;
use asap_plan_selection::pass::{run_stage1_to_stage3_with, Stage1ToStage3Search};
pub use asap_plan_selection::pass::{LogicalCandidate, MemoSteps, PrunedCandidate};
Expand All @@ -21,8 +20,8 @@ use std::collections::HashSet;
pub struct PlanningStagesRun {
/// The query-language frontends' roots, one per workload entry.
pub stage0_query_language_frontends: Vec<QueryRoot>,
/// Stage 1, Pass 1: the per-computation candidates the logical
/// candidates' `choice` indexes (query `i` has id `i`).
/// Stage 1, Pass 1: the per-computation candidates (query `i` has id
/// `i`).
pub stage1_pass1_per_computation: PerComputationCandidates<usize>,
pub stage1_logical_asap_optimization: Vec<LogicalCandidate>,
/// Evaluated physical plans reference their archived logical source by ID.
Expand Down
2 changes: 0 additions & 2 deletions crates/frontend-promql/tests/count_planning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,7 @@ fn logical_candidates_fails_on_a_candidate_that_does_not_compose() {
support::require_composed_operator_candidates(vec![
asap_plan_selection::search::LogicalCandidate {
id: "invalid-composition".into(),
choice: Vec::new(),
roots: Err(PerComputationCandidateError::InvalidChoice),
pass2: None,
},
]);
}
Expand Down
12 changes: 2 additions & 10 deletions crates/integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,14 +597,10 @@ pub mod planning {
let mut logical = Vec::new();
let mut physical = Vec::new();
for assignment in assignments {
let source_position = logical.len();
for mut candidate in
for candidate in
stage1_candidates_of_choice(&inventory, entries, &assignment, &|_| true)
{
if let Some(pass2) = &mut candidate.pass2 {
pass2.from_pass1_position = source_position;
}
let roots = recompose_guarantees(&candidate.roots.unwrap()).unwrap();
let roots = recompose_guarantees(&candidate.unwrap()).unwrap();
let id = format!("L{}", logical.len() + 1);
physical.extend(
asap_physical_asap_optimization::optimize_physical_asap(
Expand All @@ -620,9 +616,7 @@ pub mod planning {
);
logical.push(LogicalCandidate {
id,
choice: candidate.choice,
roots: Ok(roots),
pass2: candidate.pass2,
});
}
}
Expand All @@ -643,9 +637,7 @@ pub mod planning {
.unwrap();
let selected_logical = LogicalCandidate {
id: source.id.clone(),
choice: source.choice.clone(),
roots: Ok(source.roots.as_ref().unwrap().clone()),
pass2: source.pass2.clone(),
};
Stage1ToStage3Run {
combinations: inventory.combinations(),
Expand Down
2 changes: 0 additions & 2 deletions crates/integration-tests/tests/promql_numeric_regressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,7 @@ fn logical_candidates_fails_on_a_candidate_that_does_not_compose() {
asap_integration_tests::planning::require_composed_operator_candidates(vec![
asap_plan_selection::search::LogicalCandidate {
id: "invalid-composition".into(),
choice: Vec::new(),
roots: Err(PerComputationCandidateError::InvalidChoice),
pass2: None,
},
]);
}
22 changes: 7 additions & 15 deletions crates/logical-asap-optimization/src/pass2/asap_aware_cse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1978,12 +1978,10 @@ pub struct RollupCandidate {
}

/// A Pass 2 candidate of the rollup rule: the candidate's roots with the
/// coarse build of each of `rollup_candidates` answered from its finer
/// coarse build of each chosen rollup candidate answered from its finer
/// build, and every guarantee composed again; the error when that fails.
#[derive(Debug)]
pub struct RollupPass2Candidate {
Comment thread
milindsrivastava1997 marked this conversation as resolved.
Resolved
/// The coarse builds rolled up, in [`rollup_candidates`] order.
pub rollup_candidates: Vec<RollupCandidate>,
/// The candidate's roots with those builds rolled up and every guarantee
/// composed again; `Err` when the rebuilt DAG does not derive or
/// compose, which drops only this candidate.
Expand Down Expand Up @@ -2635,9 +2633,9 @@ pub fn rollup_pass2_candidates(
Ok(subsets(&rollup_choices(candidates), "rollup")?
.into_iter()
.map(|choices| {
let chosen: Vec<RollupCandidate> = choices.iter().flatten().cloned().collect();
let values: HashMap<*const OperatorNode, &RollupCandidate> = chosen
let values: HashMap<*const OperatorNode, &RollupCandidate> = choices
.iter()
.flatten()
.filter(|candidate| !is_sketch_build(&candidate.finer))
.map(|candidate| (Rc::as_ptr(&candidate.coarse), candidate))
.collect();
Expand All @@ -2659,10 +2657,7 @@ pub fn rollup_pass2_candidates(
replaced.extend(sketches);
replace_all(roots, &replaced)
});
RollupPass2Candidate {
roots,
rollup_candidates: chosen,
}
RollupPass2Candidate { roots }
Comment thread
milindsrivastava1997 marked this conversation as resolved.
Resolved
})
.collect())
}
Expand Down Expand Up @@ -2823,13 +2818,10 @@ pub struct TopKReuseCandidate {
}

/// A Pass 2 candidate of the exact top-k reuse rule: the candidate's roots
/// with every member of each of `topk_reuse_candidates` reading its
/// with every member of each chosen top-k reuse candidate reading its
/// ranking, and every guarantee composed again; the error when that fails.
#[derive(Debug)]
pub struct TopKReusePass2Candidate {
/// The top-k reuse candidates applied, in [`topk_reuse_candidates`]
/// order.
pub topk_reuse_candidates: Vec<TopKReuseCandidate>,
/// The candidate's roots with every member of those candidates reading
/// its ranking and every guarantee composed again; `Err` when the
/// rebuilt DAG does not derive or compose, which drops only this
Expand Down Expand Up @@ -2939,7 +2931,8 @@ pub fn topk_reuse_pass2_candidates(
roots: &[QueryRoot],
candidates: &[TopKReuseCandidate],
) -> Result<Vec<TopKReusePass2Candidate>, PerComputationCandidateError> {
Ok(subsets(candidates, "top-k reuse")?
let candidates: Vec<&TopKReuseCandidate> = candidates.iter().collect();
Ok(subsets(&candidates, "top-k reuse")?
.into_iter()
.map(|chosen| {
let mut replaced = HashMap::new();
Expand All @@ -2959,7 +2952,6 @@ pub fn topk_reuse_pass2_candidates(
Some(error) => Err(error),
None => replace_all(roots, &replaced),
},
topk_reuse_candidates: chosen,
}
})
.collect())
Expand Down
Loading
Loading