feat(planner): add basic scaffolding for optimization problem in planner#407
Merged
milindsrivastava1997 merged 9 commits intoJun 23, 2026
Merged
Conversation
milindsrivastava1997
commented
Jun 21, 2026
Contributor
- feat(optimizer): scaffold OptimizerSolution type and translator
- feat(optimizer): add AQE extractor with GCD/min/sum frequency tracking
- feat(optimizer): wire all-EXACT end-to-end pipeline (Phase 1)
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>
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>
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>
… 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>
…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>
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>
… 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>
Contributor
Author
Code review findings (ranked, verified against source)Correctness — all confirmed by reading the actual code:
Reuse/cleanup (lower severity, all confirmed):
Skipped as non-findings: the Findings from manual code review (we need to prioritize these)Some of these may be big enough that we need to solve them in different issues after merging this. Some of these may be big enough to warrant an entire session/discussion. solution.rs:
sketch_properties.rs:
candidate_gen.rs:
aqe_extractor.rs:
translator.rs:
cost_model.rs:
|
This was referenced Jun 23, 2026
Closed
Open
planner/optimizer: set range_a_secs to scrape_interval for spatial-only queries instead of None
#421
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.