Commit e6e231a
feat(planner): add basic scaffolding for optimization problem in planner (#407)
* feat(optimizer): scaffold OptimizerSolution type and translator
Adds asap-planner-rs/src/optimizer/ with:
- Aqe: atomic query expression wrapper (QueryRequirements + query strings + f_a)
- QueryMethod: Neither / Merge{num_windows} / Subtract / Exact
- AqeAssignment: maps an AQE to a deployed config + query method + cost estimate
- OptimizerSolution: full planner output (deployed configs + assignments + cost)
with all_exact() constructor for Phase 1 scaffolding
- translator: translate() -> (StreamingConfig, InferenceConfig); Phase 1 stub
with TODO for Phase 2 query config population
Also adds design doc for the optimization formulation (#405).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(optimizer): add AQE extractor with GCD/min/sum frequency tracking
Adds optimizer/aqe_extractor.rs:
- Rqe struct (query_string + t_repeat_secs)
- extract_aqes(): decomposes RQEs into deduplicated AQEs via recursive
binary-op splitting and PromQL pattern matching
- Computes three frequency values per AQE:
- query_frequency_hz: Σ 1/T_r (total query load for MIP objective)
- min_t_repeat_secs: min(T_r) (freshness bound on W ≤ min_t)
- t_repeat_gcd_secs: GCD(T_r) (natural slide interval S for candidate gen)
- Hand-rolled Euclidean GCD (num-integer not in workspace)
- TODO noting duplication with build_query_requirements_promql in query-engine
Updates Aqe struct in solution.rs to carry all three frequency fields.
5 unit tests covering single queries, binary splits, scalar arms, dedup.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(optimizer): wire all-EXACT end-to-end pipeline (Phase 1)
Adds optimizer/pipeline.rs with run_all_exact_pipeline():
ControllerConfig + PromQLSchema
→ config_to_rqes() (flatten QueryGroups)
→ extract_aqes()
→ OptimizerSolution::all_exact()
→ translate() → (StreamingConfig, InferenceConfig)
No streaming configs deployed in this path — every AQE falls back to
raw data. Validates end-to-end plumbing before Phase 2 sketch selection.
2 tests: empty streaming config for all-EXACT, group flattening.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(optimizer): add sketch algebraic properties and candidate config generation
Adds sketch_properties.rs (mergeable/subtractable/subpopulation_aware per
AggregationType) and candidate_gen.rs (enumerates candidate streaming configs
per AQE across agg type, param grid, window size, and ingest type). Sliding
candidates sweep slide interval S as well as the forced W=range_a, trading
ingest cost for freshness.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(optimizer): add analytical cost model for ingest and query cost rates
Adds cost_model.rs implementing IngestCost(g) and QueryCost(a,g) from the
design doc's formulas, using stub AtomicCosts (real values come from
sketch-bench in Phase 3). Includes an EXACT fallback query cost so the
greedy/MIP objective has something non-zero to compare sketches against.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(optimizer): wire greedy per-AQE assignment end-to-end (Phase 2)
Adds greedy.rs (picks each AQE's independently-cheapest candidate via the
cost model), run_greedy_pipeline() in pipeline.rs, and populates
InferenceConfig.query_configs in translator.rs for non-Exact assignments.
Rebalances CostWeights::default() so memory and CPU costs are on comparable
scales (RAM-held-over-time is ~1e6x cheaper per unit than CPU-time in real
cloud pricing) — the prior equal weighting made EXACT always win regardless
of workload.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(optimizer): add standalone CLI for offline testing of the greedy pipeline
Adds asap-optimizer-cli (src/bin/optimizer_cli.rs), a second binary that runs
run_greedy_pipeline against a workload YAML and prints the resulting deployed
configs and query configs. Lets the optimizer be exercised against real
configs without touching Controller::generate(), which still goes through
the existing hardcoded generator::generate_plan() path unconditionally.
Also adds a doc comment on generate_plan() flagging that the optimizer
module exists as a not-yet-wired-in alternative, for anyone reading that
file without other context.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fixed some CR comments
* fixed Dockerfile, clarified code comment
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent fefca94 commit e6e231a
16 files changed
Lines changed: 2159 additions & 2 deletions
File tree
- .design_docs
- asap-planner-rs
- src
- bin
- optimizer
- promql
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
0 commit comments