Skip to content
Draft
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
48 changes: 48 additions & 0 deletions crates/asap-aware-mapping/src/cost_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,54 @@ pub trait CostModel {
false
}

/// Price one complete multi-root workload assignment. Deployments shared
/// by `Rc` identity carry costs for the union of their consumers. The
/// additive default charges such a producer once, retaining each root's
/// remaining complete-DAG cost. Models with interactions between roots
/// override this hook; unknown evidence never becomes a zero estimate.
fn complete_workload_candidate_cost(
&self,
plans: &[crate::summary_maintenance_lifecycle::SummaryMaintenanceLifecyclePlan],
scalar_roots: &[(usize, asap_types::ir::ScalarExpr)],
) -> Option<Cost> {
// The additive legacy hooks price operator DAGs only. A workload model
// must supply scalar/subquery execution evidence rather than omit it.
if !scalar_roots.is_empty() {
return None;
}
let mut total = 0.0;
let mut seen = std::collections::HashSet::new();
for plan in plans {
let root_cost = if plan.selected_raw_recompute {
plan.raw_recompute_total_cost?
} else {
plan.summary_total_cost?
};
if !root_cost.0.is_finite() || root_cost.0 < 0.0 {
return None;
}
total += root_cost.0;
for deployment in &plan.deployments {
if seen.insert(std::rc::Rc::as_ptr(&deployment.summary)) {
continue;
}
let guarantee = deployment
.summary_maintenance_lifecycle_guarantee
.as_ref()?;
let cost = deployment
.alternatives
.iter()
.find(|alternative| {
alternative.summary_maintenance_lifecycle
== guarantee.summary_maintenance_lifecycle
})?
.total_cost?;
total -= cost.0;
}
}
(total.is_finite() && total >= 0.0).then_some(Cost(total))
}

/// Cost of evaluating `target` directly from its logical/raw inputs once.
/// When known, lifecycle-aware materialization compares this fallback with
/// the aggregate cost of the selected summary deployments.
Expand Down
4 changes: 4 additions & 0 deletions crates/asap-aware-mapping/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
//! values containing DAG roots and maintenance decisions; callers do not need
//! to run ordinary selection/assembly first.
//!
//! - Choose [`pass::CompletePass`] for bounded exhaustive workload search,
//! including exact pane composition, partial sharing and lifecycle assignments.
//! It requires complete workload costs and never falls back to a heuristic.
//!
//! Models and evidence determine which choices the helpers can justify.
//! Physical operator binding, placement, storage, deployment, and execution
//! remain downstream responsibilities. Neither taking the first candidate nor
Expand Down
Loading
Loading