Skip to content

refactor(rqe-optimizer): Raqe input model in ms, spatial filter, per-RAQE latency SLA, deployable families - #148

Merged
milindsrivastava1997 merged 7 commits into
mainfrom
rqe-raqe-input
Oct 6, 2026
Merged

milindsrivastava1997 merged 7 commits into
mainfrom
rqe-raqe-input

Conversation

@milindsrivastava1997

@milindsrivastava1997 milindsrivastava1997 commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Finishes the remaining parts of S1 and S6 from #143. #145 already did metric/grouping_labels (S1) and the scrape-interval multiples (S6).

Interface changes later sessions depend on

Rqe → Raqe (rqe-optimizer/src/lib.rs)

  • accuracy_tolerance → accuracy_sla.
  • New spatial_filter: String: canonical PromQL matcher text, "" for none. It is part of stream identity, compared as an opaque string. validate_facts rejects a non-empty filter for now, because facts have no per-filter cardinality and a filtered stream would be costed as the whole metric.
  • New latency_sla_ms: Option<f64>: a hard ceiling on modeled query latency. Only the MILP enforces it. validate_facts rejects values that are non-finite or ≤ 0.
  • Stream identity for grouping, eligibility, sharing and pruning is now (capability, metric, spatial_filter, grouping_labels). Deployment carries spatial_filter too.

Milliseconds everywhere. Seconds → Millis (u64), and *_secs → *_ms for lookback, interval, window, slide and MetricFacts::scrape_interval. Rates (CPU-sec/sec, samples/sec) stay per second. Latency is in ms too: PlanCost::query_latency_secs → query_latency_ms. validate_facts rejects a zero lookback or interval, and any lookback or interval that isn't a multiple of the metric's scrape interval. That catches values left in seconds.

MilpBounds removed. milp::minimize(raqes, deployments, facts, objective) reads each Raqe's latency_sla_ms. In the example, --latency-limit RAQE_ID=SECONDS becomes --latency-sla RAQE_ID=MS.

Allowed families (S6). These are hardcoded, not taken as input: DEPLOYABLE_FAMILIES lists the variants ASAPQuery's engine runs (middle column). The rest of Capability::families() is measured but undeployable:

Capability Deployable (ASAPQuery AggregationType) Undeployable (planned only with --allow-undeployable-families)
SumOrCount exact-sum (MultipleSum) —
Min exact-min (MultipleMinMax, sub_type "min") —
Max exact-max (MultipleMinMax, sub_type "max") —
RateOrIncrease exact-increase (MultipleIncrease) —
Quantile kll-percall (DatasketchesKLL) dd
Cardinality hll (HLL) univmon-cardinality
TopK cms-heap-topk-fastpath-vector2d (CountMinSketchWithHeap) countsketch-heap-topk-fastpath-vector2d, univmon-topk

ASAPQuery engine types not in this table yet: HydraKLL (Quantile) joins families() and DEPLOYABLE_FAMILIES once S5/S4b measure it. SetAggregator and DeltaSetAggregator (exact Cardinality) have no sketch-bench family; DeltaSet is planned only as HydraKLL's key tracker (S5/S4b).

By default, candidate generation and the AutoSketch baseline only use deployable families, so dd, univmon-* and countsketch-heap are measured but not planned.

--allow-undeployable-families. build_all_candidates, build_all_candidates_unpruned, autosketch::plan and autosketch::search take allow_undeployable_families: bool. All of them choose families through one rule, Capability::candidate_families(allow_undeployable_families). When the flag is true, every measured family in Capability::families() is a candidate. Use it for studies only: the resulting plan can't be deployed. The small_problem example exposes it as --allow-undeployable-families. AutoSketch takes the same flag, so the baseline and the MILP always plan with the same sketches. In ASAPQuery, A3/A5 can pass the flag through to print the plan and its cost without writing YAML. hydra-kll joins families() and this list once S5/S4b measure it. ASAPQuery's sketch_bench_key doesn't map CountMinSketchWithHeap yet, so A3 needs to add that mapping.

Notes

  • AutoSketch's cross-variant test runs search(..., allow_undeployable_families: true) over both TopK families. No capability has two deployable variants until hydra-kll.
  • The crate, file and script names keep rqe (rqe-optimizer, export_rqe_optimizer_costs.sh). Only the types and identifiers were renamed.

Test plan

  • cargo test -p rqe-optimizer (39 pass): new tests for spatial-filter separation, undeployable families being candidates only with the flag, each deployable family being in some families() (iterating Capability::ALL), and validate_facts rejecting bad SLAs, spatial filters, zero times, and times that aren't multiples of the scrape interval.
  • Workspace fmt, clippy and test via pre-commit.
  • small_problem --milp --latency-sla … builds candidates. A full solve needs a fresh S5 export: the local cost table predates rqe-optimizer: exact sum/min-max/increase accumulators, CountSketch+heap and UnivMon top-k #144 and has no exact-* rows.

🤖 Generated with Claude Code

milindsrivastava1997 and others added 4 commits October 6, 2026 11:40
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lookback, interval, window, slide and scrape interval are Millis. Rates
(CPU-sec/sec, samples/sec) stay per second via secs().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…unds

Stream identity is now (capability, metric, spatial_filter, grouping_labels).
spatial_filter is opaque matcher text used for identity only. The latency
limit moves from MilpBounds onto each Raqe; the example's --latency-limit
RAQE_ID=SECONDS becomes --latency-sla RAQE_ID=MS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DEPLOYABLE_FAMILIES lists the variants ASAPQuery's engine runs, each with
its AggregationType. Candidate generation and the AutoSketch baseline both
go through Capability::deployable_families(), so dd, univmon-* and
countsketch-heap are measured but never planned.

AutoSketch's chooses_the_cheaper_variant test is removed: no capability has
two deployable variants until hydra-kll is measured.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@milindsrivastava1997 milindsrivastava1997 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review findings (10). Nine are inline below. One is on a file this PR doesn't touch:

scripts/export_rqe_optimizer_costs.sh: the export script still benchmarks dd, univmon-cardinality, univmon-topk and countsketch-heap-topk, which can no longer become candidates (deployable_families() discards their rows). Its header still says it measures what Capability::families() names. That makes every cost-table regeneration slower than needed, and the header is misleading.

Comment thread rqe-optimizer/examples/small_problem.rs
Comment thread rqe-optimizer/src/lib.rs
Comment thread rqe-optimizer/src/lib.rs
Comment thread rqe-optimizer/src/milp.rs Outdated
Comment thread rqe-optimizer/src/lib.rs Outdated
Comment thread rqe-optimizer/src/lib.rs
Comment thread rqe-optimizer/src/autosketch.rs
Comment thread rqe-optimizer/examples/small_problem.rs Outdated
Comment thread rqe-optimizer/src/lib.rs Outdated
milindsrivastava1997 and others added 2 commits October 6, 2026 13:03
- Latency is modeled in ms end to end (PlanCost::query_latency_ms), so the
  SLA compares without a unit conversion and the example prints ms.
- validate_facts rejects non-finite or non-positive latency SLAs, and
  non-empty spatial filters until facts carry per-filter cardinality.
- small_problem rejects --latency-sla without --milp.
- Deployable-family test checks each entry is in some families().
- Restore AutoSketch's cross-variant test via search_variants().
- Fix the families() and export-script comments; drop redundant
  spatial_filter fields in tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
build_all_candidates(_unpruned) take allow_undeployable_families; when set,
every measured family in Capability::families() becomes a candidate. The
small_problem example exposes it as --allow-undeployable-families.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread rqe-optimizer/src/autosketch.rs Outdated
Comment thread rqe-optimizer/examples/small_problem.rs Outdated
Comment thread rqe-optimizer/examples/small_problem.rs Outdated
Comment thread rqe-optimizer/src/lib.rs
Comment thread rqe-optimizer/src/candidates.rs Outdated
Comment thread rqe-optimizer/src/candidates.rs Outdated
Comment thread rqe-optimizer/src/candidates.rs Outdated
Comment thread rqe-optimizer/src/lib.rs
- Capability::candidate_families(allow_undeployable_families) is the one
  family rule; candidate generation and AutoSketch's plan/search both take
  the flag, so the baseline sees the same sketches as the MILP.
- validate_facts rejects zero lookback/interval and ones that aren't
  multiples of the scrape interval.
- Candidate windows come from divisors(L / scrape) × scrape.
- small_problem rejects --latency-sla with --candidates-only or
  --sample-mappings, and non-finite SLAs.
- Capability::ALL for the deployable-family test; spatial_filter in the
  pruning comment and the TODO doc.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant