Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f72b9f1
refactor(stage3): baseline selection MILP and the plan it builds; nat…
zzylol Nov 9, 2026
8807b74
test(integration): SQL avg from its sum and count states executes as …
zzylol Nov 12, 2026
78ec24c
test: move the inline tests of the files PR 6 touches into sibling fi…
zzylol Nov 12, 2026
2c6abd1
fix(stage3,cost): the selection objective equals plan_cost: an ingest…
zzylol Nov 12, 2026
18aa65c
fix(stage3): leave out candidates dearer than a feasible plan before …
zzylol Nov 12, 2026
70a45cf
fix(accuracy): an exact query reads every group below its root only e…
zzylol Nov 12, 2026
dc52d51
fix(executor): query-time tumbling-window chains are built at each ev…
zzylol Nov 12, 2026
d665fb8
refactor(types,cost,stage3,executor): one time-window walk and `TimeW…
zzylol Nov 12, 2026
397c914
refactor(cost,stage3): Stage 3 costs candidates with asap-cost's rule…
zzylol Nov 12, 2026
6304894
perf(stage3): build the selection MILP in one pass over each structur…
zzylol Nov 12, 2026
3e23663
refactor(stage3): files by scope: selectable edges, cost, retention, …
zzylol Nov 12, 2026
fefab36
refactor(types,executor): split the files this PR grew by scope; inli…
zzylol Nov 12, 2026
0409f74
refactor(planner,cost,devtools): installable_plan_of takes the plan b…
zzylol Nov 12, 2026
08691da
docs: Stage 3's files and the shared cost rules in the architecture d…
zzylol Nov 12, 2026
33c9bc6
docs(cost): a doc comment on every field of ProducerOutput and NodeRe…
zzylol Nov 12, 2026
cc180aa
docs(devtools,planner): the planner fuzz and the Usage test say "cost…
zzylol Nov 12, 2026
9ec3847
fix(cost): an ingestion-time view keeps the outputs its retention cov…
zzylol Nov 13, 2026
eba55f7
perf(stage3): leave out MILP rows implied by the one-consumer equalit…
zzylol Nov 13, 2026
be4ef05
test(integration): the topk-over-ratio test checks that both operands…
zzylol Nov 13, 2026
ee55c56
fix(cost,types): a TimeShift view's retention holds its offset; a vie…
zzylol Nov 13, 2026
2b67906
refactor(cost): inline plan_cost's one-caller node loop and fix its d…
zzylol Nov 13, 2026
a174073
feat(devtools): print the selection MILP's objective in asap_planner …
zzylol Nov 13, 2026
7b2ed26
refactor(stage3,cost): one selected-plan cost, one window rule for ch…
zzylol Nov 13, 2026
6035803
fix(cost): a view without retention is not costed (#1207 PR 6)
zzylol Nov 13, 2026
619df78
fix(types,cost): a stored ingestion-time TimeShift keeps its offset, …
zzylol Nov 13, 2026
a02a3f2
test(integration): raw data on disk costing less than the solver tole…
zzylol Nov 13, 2026
dcfd694
fix(executor): a stored TimeShift's own refresh stays refused (#1207 …
zzylol Nov 13, 2026
62339bc
fix(types,executor): a stored TimeShift over raw data reads it unboun…
zzylol Nov 13, 2026
2e0e9ff
refactor(types,cost): one PhysicalASAPDAGNode::is_view (#1207 PR 6)
zzylol Nov 13, 2026
75c29a2
refactor(types,cost,stage3,executor): time windows in four layers, wa…
zzylol Nov 14, 2026
ea48d5c
refactor(types,stage3,executor): current_time_read_needs_every_row; t…
zzylol Nov 14, 2026
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
10 changes: 8 additions & 2 deletions crates/accuracy/src/metric_rule/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl ErrorMetricsOfMemo {
/// metric rule per query where the edges apply it per group. Walking
/// down the live candidates (not in `dead`) from each root with a
/// target, which allows its target's metrics
/// ([`query_roots_with_target`]), a candidate passes to its inputs the
/// ([`query_roots_with_target`]; an exact target none), a candidate passes to its inputs the
/// metrics its error contract passes; a group keeps, per query, the
/// metrics every path to it passes. A group is exact-only for a query
/// when no metric reaches it (one path through a consumer without a
Expand Down Expand Up @@ -184,7 +184,13 @@ impl ErrorMetricsOfMemo {
.and_modify(|known| known.retain(|metric| metrics.contains(metric)))
.or_insert(metrics);
}
for (query, root, _, metrics) in query_roots_with_target(memo) {
for (query, root, target, metrics) in query_roots_with_target(memo) {
// An exact target allows no error: the query reads every group
// below its root exactly.
let metrics = match target.is_exact() {
true => Vec::new(),
false => metrics,
};
keep_common(&mut allowed, root, query, metrics);
}
let mut exact_only = vec![BTreeSet::new(); memo.queries().len()];
Expand Down
32 changes: 18 additions & 14 deletions crates/cost/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! `asap-cost` — the cost model the planning stages share: how much of each
//! resource a plan uses and what that usage costs. It depends only on
//! `asap-types`, so any stage can price with it.
//! `asap-types`, so any stage can cost with it.
//!
//! - Resource-usage estimation of one node ([`node`]):
//! [`node::analytical`] and `node::operator_statistics` (the analytical
Expand All @@ -9,17 +9,20 @@
//! their lookup) and `resources` (resource dimensions with explicit CPU
//! units).
//! - The whole plan ([`plan`]): [`plan::execution_demand`] (how often each
//! node of a physical DAG is computed), its cost, retention and ranking.
//! node of a physical DAG is computed), its cost, how far back its
//! time-indexed nodes are read and how plans rank.
//! - Cost models (`model`): [`ResourceUsage`], [`ResourceUnitCost`],
//! [`ResourceSpeed`], [`CostModel`] ([`ClusterLimits`],
//! [`ClusterObjective`]) and the deployment's [`CostInputs`], with the
//! per-node and per-plan costs ([`NodeCost`], [`PlanCost`]).
//! - Costing a physical plan DAG: [`node_usage`] gives one node's
//! [`NodeUsage`]; [`plan_cost`] the whole plan's [`PlanCost`]. Stage 3
//! computes no cost of its own.
//!
//! Plan selection (Stage 3, `asap-stage3-plan-selection`) documents how it prices
//! a candidate with these.
//! - Costing a physical plan DAG: [`node_resource_usage_and_cost`] gives one node's
//! [`NodeResourceUsageAndCost`]; [`plan_cost`] the whole plan's [`PlanCost`].
//! Stage 3 (`asap-stage3-plan-selection`) costs each candidate as one node
//! with the same function and the rules `plan_cost` applies:
//! [`plan::execution_demand::executions_per_second`],
//! [`maintained_window_ms`], [`read_back_ms`],
//! [`raw_data_disk_cost_per_second`] and
//! [`request_overhead_cost_per_second`].
mod measured;
mod model;
pub mod node;
Expand All @@ -37,12 +40,13 @@ pub use model::{
};
pub use node::operator_statistics::EdgeStatistics;
pub use node::usage::{
node_map, node_usage, summary_type_name, NodeCost, NodeMap, NodeUsage, ProducerOutput,
maintained_window_ms, node_resource_usage_and_cost, summary_type_name, NodeCost,
NodeResourceUsageAndCost, ProducerOutput,
};
pub use plan::cost::{plan_cost, PlanCost, QueryLatency};
pub use plan::ranking::{cheaper, worst_latency_ms, PlanRanking};
pub use plan::retention::{
maintained_window_ms, query_reach, retained_tumbling_windows, tumbling_window_retention_ms,
tumbling_window_retention_ms_of_plan, tumbling_windows_of,
pub use plan::cost::{
plan_cost, raw_data_disk_cost_per_second, request_overhead_cost_per_second, PlanCost,
QueryLatency,
};
pub use plan::ranking::{cheaper, worst_latency_ms, PlanRanking};
pub use plan::read_back::read_back_ms;
pub use resources::ResourceUsage;
23 changes: 15 additions & 8 deletions crates/cost/src/node/state_bytes/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! The bytes one summary or exact state holds and its update operations
//! per input row, from its parameters and the rows it folds.

use crate::node::analytical::AnalyticalCostError;
use asap_types::ir::operator::AggIntent;
use asap_types::ir::schema::{DataType, FieldDataType, Schema};
use asap_types::summary_type::KLL_MAX_K;
Expand Down Expand Up @@ -57,15 +58,21 @@ pub fn keeps_every_value(measure: &AggIntent) -> bool {
/// Count-Min and Count-Sketch, plus one heap update for their top-k variants;
/// for UnivMon, the same per layer it updates (`univmon_expected_layers`);
/// 1 for every other sketch.
pub fn summary_shape(family: &FieldDataType, input_rows: StateInputRows) -> (f64, u64) {
match family {
FieldDataType::Sketch(..) => {
let _ = input_rows;
todo!("#1207 PR 6: the state shape of θ from the candidate's LogicalProperties::parameters")
}
FieldDataType::ExactAggregate(..) => (1.0, EXACT_ACCUMULATOR_STATE_BYTES),
///
/// `parameters` is the build's θ (`PhysicalASAPDAGNode::parameters`). Err
/// [`AnalyticalCostError::UnsupportedCandidate`] for a sketch without θ: a
/// planner bug, since every sketch build carries its θ.
pub fn summary_shape(
family: &FieldDataType,
parameters: Option<&SketchParams>,
input_rows: StateInputRows,
) -> Result<(f64, u64), AnalyticalCostError> {
Ok(match (family, parameters) {
(FieldDataType::Sketch(..), Some(parameters)) => sketch_shape(parameters, input_rows),
(FieldDataType::Sketch(..), None) => return Err(AnalyticalCostError::UnsupportedCandidate),
(FieldDataType::ExactAggregate(..), _) => (1.0, EXACT_ACCUMULATOR_STATE_BYTES),
_ => (1.0, 8),
}
})
}

/// What one summary state's bytes depend on besides its parameters (only
Expand Down
3 changes: 2 additions & 1 deletion crates/cost/src/node/state_bytes/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ fn exact_state_is_priced_at_the_executors_state_size() {
assert_eq!(
summary_shape(
&FieldDataType::ExactAggregate(kind, params),
None,
StateInputRows::UNKNOWN
),
(1.0, 56)
Ok((1.0, 56))
);
}
assert_eq!(asap_types::summary_type::EXACT_ACCUMULATOR_STATE_BYTES, 56);
Expand Down
Loading
Loading