Skip to content

Commit 0ec1965

Browse files
refactor(planner): hoist subpopulation_count placeholder into a shared constant (#534)
1 parent 1796f2a commit 0ec1965

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

‎asap-planner-rs/src/optimizer/constants.rs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,9 @@ pub const INGEST_MEM_WEIGHT: f64 = 1e-9;
3333
pub const INGEST_CPU_WEIGHT: f64 = 1.0;
3434
pub const QUERY_MEM_WEIGHT: f64 = 1e-9;
3535
pub const QUERY_CPU_WEIGHT: f64 = 1.0;
36+
37+
/// Subpopulation count: 1 if subpopulation_aware else the distinct label-group
38+
/// count for this config. The label-group count isn't profiled yet (needs
39+
/// Prometheus series-count data) — use 1 as a placeholder; both branches
40+
/// collapse to the same value until that lands.
41+
pub const SUBPOPULATION_COUNT: f64 = 1.0;

‎asap-planner-rs/src/optimizer/cost_model.rs‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use super::candidate_gen::CandidateConfig;
44
use super::constants::{
55
EXACT_QUERY_CPU_SECS, INGEST_CPU_WEIGHT, INGEST_MEM_WEIGHT, INSERT_CPU_SECS,
66
MEM_BYTES_PER_INSTANCE, MERGE_CPU_SECS, QUERY_CPU_SECS, QUERY_CPU_WEIGHT, QUERY_MEM_WEIGHT,
7-
SUBTRACT_CPU_SECS,
7+
SUBPOPULATION_COUNT, SUBTRACT_CPU_SECS,
88
};
99
use super::sketch_properties::sketch_properties;
1010
use super::solution::{QueryMethod, AQE};
@@ -75,11 +75,7 @@ pub fn ingest_cost(
7575
return 0.0; // EXACT: no streaming config deployed.
7676
};
7777

78-
// Subpopulation count: 1 if subpopulation_aware else the distinct
79-
// label-group count for this config. The label-group count isn't profiled
80-
// yet (needs Prometheus series-count data) — use 1 as a placeholder; both
81-
// branches collapse to the same value until that lands.
82-
let subpopulation_count = 1.0_f64;
78+
let subpopulation_count = SUBPOPULATION_COUNT;
8379

8480
// Defensive floor: slide_interval_ms is a plain u64 on a widely-shared struct;
8581
// guard against div-by-zero producing `inf` and poisoning cost comparisons.
@@ -112,7 +108,7 @@ pub fn query_cost(
112108
};
113109

114110
// Subpopulation count; see ingest_cost comment.
115-
let subpopulation_count = 1.0_f64;
111+
let subpopulation_count = SUBPOPULATION_COUNT;
116112
let props = sketch_properties(agg_config.aggregation_type);
117113

118114
let (cpu, mem) = match &candidate.query_method {

0 commit comments

Comments
 (0)