Skip to content

Commit c0fee40

Browse files
authored
Merge pull request #336 from ProjectASAP/feat/cost-streaming-planner-integration
feat(cost): rank complete streaming deployments
2 parents 8909ea1 + 0c779e7 commit c0fee40

8 files changed

Lines changed: 624 additions & 108 deletions

File tree

‎crates/asap-aware-mapping/src/cost_model.rs‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,16 @@ pub struct CostedSummaryDeployment<'a> {
108108
pub selected_cost: Cost,
109109
}
110110

111+
/// Complete physical-plan result for one lifecycle combination. Models that
112+
/// enumerate multiple deployment implementations can expose the stable
113+
/// provider-owned identity of the winning alternative without adding a
114+
/// closed window-framework enum to the planner.
115+
#[derive(Debug, Clone, PartialEq)]
116+
pub struct CompleteSummaryCandidateEstimate {
117+
pub cost: Cost,
118+
pub physical_plan_id: Option<String>,
119+
}
120+
111121
impl Cost {
112122
/// The cost of an operation that costs nothing at all.
113123
pub const ZERO: Cost = Cost(0.0);
@@ -592,6 +602,23 @@ pub trait CostModel {
592602
))
593603
}
594604

605+
/// Complete-plan estimate plus the identity of the selected physical
606+
/// implementation, when the model searched more than one implementation.
607+
fn complete_summary_candidate_estimate(
608+
&self,
609+
root: &SummaryNode,
610+
target: Option<&QueryExpr>,
611+
deployments: &[CostedSummaryDeployment<'_>],
612+
horizon: Option<Horizon>,
613+
expected_reads: Option<f64>,
614+
) -> Option<CompleteSummaryCandidateEstimate> {
615+
self.complete_summary_candidate_cost(root, target, deployments, horizon, expected_reads)
616+
.map(|cost| CompleteSummaryCandidateEstimate {
617+
cost,
618+
physical_plan_id: None,
619+
})
620+
}
621+
595622
/// Cost of evaluating `target` directly from its logical/raw inputs once.
596623
/// When known, lifecycle-aware materialization compares this fallback with
597624
/// the aggregate cost of the selected summary deployments.

‎crates/asap-aware-mapping/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ pub use accuracy::{
205205
PropagationStats, WorkloadAccuracyEvidence,
206206
};
207207
pub use accuracy_reconciliation::AccuracyReconciliationStrategy;
208-
pub use cost_model::{CostModel, DefaultCostModel};
208+
pub use cost_model::{CompleteSummaryCandidateEstimate, CostModel, DefaultCostModel};
209209
pub use explanation::{
210210
explain_replacements, explain_replacements_with, ExplanationKind, ReplacementExplanation,
211211
};

‎crates/asap-aware-mapping/src/summary_maintenance_cost/evidence.rs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,3 +329,12 @@ pub struct StreamingRawInputEvidence {
329329
pub ingestion_rate_per_second: f64,
330330
pub physical_dag: EvidenceBackedPhysicalDag,
331331
}
332+
333+
/// One complete provider-enumerated physical implementation of the selected
334+
/// streaming summary DAG. The identifier is stable provenance; concrete
335+
/// framework selection is performed by ranking these complete alternatives.
336+
#[derive(Debug, Clone)]
337+
pub struct StreamingPhysicalPlanAlternative {
338+
pub physical_plan_id: String,
339+
pub node_evidence: StreamingNodeEvidence,
340+
}

‎crates/asap-aware-mapping/src/summary_maintenance_cost/mod.rs‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::rc::Rc;
99

1010
use asap_types::post_asap::{
1111
SketchAlgorithm, SummaryExpr, SummaryMaintenanceLifecycle,
12-
SummaryMaintenanceLifecycleGuarantee, SummaryMaintenanceMode, SummaryNode,
12+
SummaryMaintenanceLifecycleGuarantee, SummaryNode,
1313
};
1414
use asap_types::pre_asap::{
1515
agg_intent::AggIntent, CompareOpKind, InfoMatcher, Predicate, QueryExpr, Source,
@@ -18,14 +18,15 @@ use asap_types::workload::{DataArrival, DataWorkload, QueryRecurrence, RepeatedD
1818
use serde::{Deserialize, Serialize};
1919

2020
use crate::analytical_cost::ExecutionMultiplicity;
21+
#[cfg(test)]
22+
use crate::analytical_cost::PhysicalNodeEvidence;
2123
use crate::analytical_cost::{
22-
estimate_physical_dag, AnalyticalCostError, EvidenceBackedPhysicalDag, PhysicalOperator,
23-
ResourceCalibration, ResourceEstimate,
24+
estimate_physical_dag, AnalyticalCostError, EvidenceBackedPhysicalDag, PhysicalDagNode,
25+
PhysicalOperator, ResourceCalibration, ResourceEstimate,
26+
};
27+
use crate::cost_model::{
28+
CompleteSummaryCandidateEstimate, Cost, CostModel, CostedSummaryDeployment, DefaultCostModel,
2429
};
25-
#[cfg(test)]
26-
use crate::analytical_cost::{PhysicalDagNode, PhysicalNodeEvidence};
27-
use crate::cost_model::CostedSummaryDeployment;
28-
use crate::cost_model::{Cost, CostModel, DefaultCostModel};
2930
#[cfg(test)]
3031
use crate::physical_operator_statistics::UnaryEdgeStatistics;
3132
use crate::physical_operator_statistics::{ComparisonScope, EdgeStatistics, OperatorStatistics};

0 commit comments

Comments
 (0)