Skip to content

Commit c0ce64b

Browse files
zzylolclaude
andcommitted
chore(plan-selection): delete the legacy physical-plan cost model
PhysicalPlanCostModel, PlannerPhysicalPlanProvider and PhysicalEvidenceSnapshot had no caller once dag_export was gone, and Stage 3 never used them. asap_types::cost keeps only CostUnit; the annotation and workload-summary types were dag_export's. cache_hit_ratios moves into analytical_cost's tests, its only caller. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 04e5027 commit c0ce64b

5 files changed

Lines changed: 10 additions & 1820 deletions

File tree

‎crates/plan-selection/src/cost/analytical_cost.rs‎

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ struct ResolvedCacheProfile {
3030
integer_executions: Option<u64>,
3131
cpu_execution_factor: f64,
3232
scan_execution_factor: f64,
33-
result_hit_ratio: f64,
34-
buffer_hit_ratio: f64,
3533
buffer_miss_bytes: u64,
3634
buffer_working_set_bytes: u64,
3735
}
@@ -51,8 +49,6 @@ fn resolve_cache_profile(
5149
integer_executions: Some(evaluation_count),
5250
cpu_execution_factor: evaluation_count as f64,
5351
scan_execution_factor: evaluation_count as f64,
54-
result_hit_ratio: 0.0,
55-
buffer_hit_ratio: 0.0,
5652
buffer_miss_bytes: 1,
5753
buffer_working_set_bytes: 1,
5854
});
@@ -114,8 +110,6 @@ fn resolve_cache_profile(
114110
let result_miss_ratio =
115111
invalidation + miss_fraction(evidence.result_cache)? * (1.0 - invalidation);
116112
let buffer_miss_ratio = miss_fraction(evidence.buffer_cache)?;
117-
let result_hit_ratio = 1.0 - result_miss_ratio;
118-
let buffer_hit_ratio = 1.0 - buffer_miss_ratio;
119113
let cpu_execution_factor = evidence.distinct_evaluations as f64
120114
+ evidence.repeated_identical_evaluations as f64 * result_miss_ratio;
121115
Ok(ResolvedCacheProfile {
@@ -130,8 +124,6 @@ fn resolve_cache_profile(
130124
},
131125
cpu_execution_factor,
132126
scan_execution_factor: cpu_execution_factor * buffer_miss_ratio,
133-
result_hit_ratio,
134-
buffer_hit_ratio,
135127
buffer_miss_bytes: evidence
136128
.buffer_cache
137129
.working_set_bytes
@@ -140,16 +132,6 @@ fn resolve_cache_profile(
140132
})
141133
}
142134

143-
/// Derive cache hit ratios from the shared assumptions for this workload.
144-
pub fn cache_hit_ratios(
145-
profile: &CacheProfile,
146-
evaluation_count: u64,
147-
data_arrival: DataArrival,
148-
) -> Result<(f64, f64), AnalyticalCostError> {
149-
let resolved = resolve_cache_profile(profile, evaluation_count, data_arrival)?;
150-
Ok((resolved.result_hit_ratio, resolved.buffer_hit_ratio))
151-
}
152-
153135
/// Conversion from physical dimensions to one deployment-specific objective.
154136
/// Memory's coefficient means cost units per retained byte over this model's
155137
/// explicit comparison scope; it is not mixed with a rate implicitly.
@@ -3686,10 +3668,6 @@ mod tests {
36863668
fn accepts_shared(_: &asap_types::workload::resources::CacheProfile) {}
36873669
accepts_shared(&legacy);
36883670
assert_eq!(central, legacy);
3689-
assert_eq!(
3690-
cache_hit_ratios(&central, 6, DataArrival::AtRest).unwrap(),
3691-
(1.0, 0.5)
3692-
);
36933671
}
36943672

36953673
#[test]
@@ -3778,13 +3756,13 @@ mod tests {
37783756
};
37793757
evidence.distinct_evaluations = 1;
37803758
assert!(matches!(
3781-
cache_hit_ratios(&profile, 6, DataArrival::AtRest),
3759+
resolve_cache_profile(&profile, 6, DataArrival::AtRest),
37823760
Err(AnalyticalCostError::InvalidCacheEvidence(_))
37833761
));
37843762

37853763
let profile = cache_profile(100, 100);
37863764
assert!(matches!(
3787-
cache_hit_ratios(&profile, 6, DataArrival::ContinuouslyIngesting),
3765+
resolve_cache_profile(&profile, 6, DataArrival::ContinuouslyIngesting),
37883766
Err(AnalyticalCostError::InvalidCacheEvidence(_))
37893767
));
37903768
}
@@ -3837,14 +3815,14 @@ mod tests {
38373815
};
38383816
inputs.distinct_evaluations = 0;
38393817
inputs.repeated_identical_evaluations = 6;
3840-
assert!(cache_hit_ratios(&cache, 6, DataArrival::AtRest).is_err());
3818+
assert!(resolve_cache_profile(&cache, 6, DataArrival::AtRest).is_err());
38413819
for ratio in [f64::NAN, f64::INFINITY, -1.0, 0.5] {
38423820
let mut cache = cache_profile(100, 0);
38433821
let CacheProfile::Evidence(inputs) = &mut cache else {
38443822
unreachable!()
38453823
};
38463824
inputs.result_invalidation_ratio = Some(ratio);
3847-
assert!(cache_hit_ratios(&cache, 6, DataArrival::AtRest).is_err());
3825+
assert!(resolve_cache_profile(&cache, 6, DataArrival::AtRest).is_err());
38483826
}
38493827
}
38503828

@@ -3990,10 +3968,6 @@ mod tests {
39903968
inputs.result_invalidation_ratio = Some(0.5);
39913969
let estimate =
39923970
estimate_physical_dag_with_cache(&nodes, "scan", &scope, &evidence, &profile).unwrap();
3993-
assert_eq!(
3994-
cache_hit_ratios(&profile, 6, scope.data_arrival).unwrap(),
3995-
(0.5, 0.5)
3996-
);
39973971
assert_eq!(estimate.cpu_ops(), 400.0);
39983972
assert_eq!(estimate.scan_bytes(), 2_000);
39993973
}

‎crates/plan-selection/src/cost/mod.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! deployment's cost-based selection plugs into, with the built-in
33
//! [`DefaultCostModel`](cost_model::DefaultCostModel); recurring and one-shot
44
//! cost rates ([`recurrence`]); analytical and evidence-based pricing
5-
//! ([`analytical_cost`], [`physical_plan_cost_model`], [`empirical_cost`]); and
5+
//! ([`analytical_cost`], [`empirical_cost`]); and
66
//! the physical lowering and storage I/O profiles they price
77
//! ([`query_physical_lowering`], [`storage_io`]).
88
@@ -12,7 +12,6 @@ pub mod empirical_cost;
1212
pub mod empirical_resources;
1313
pub mod physical_handoff_cost;
1414
pub mod physical_operator_statistics;
15-
pub mod physical_plan_cost_model;
1615
pub mod query_physical_lowering;
1716
pub mod recurrence;
1817
pub mod storage_io;

0 commit comments

Comments
 (0)