Skip to content

rqe-optimizer: add AutoSketch's per-query configuration search as a baseline - #135

Merged
zzylol merged 2 commits into
mainfrom
feat/rqe-optimizer-autosketch
Oct 5, 2026
Merged

zzylol merged 2 commits into
mainfrom
feat/rqe-optimizer-autosketch

Conversation

@zzylol

@zzylol zzylol commented Oct 4, 2026 •

Copy link
Copy Markdown
Collaborator

Before this PR

rqe-optimizer had only the batch planner, brute-force enumeration and the HiGHS MILP, with no AutoSketch baseline to compare it against. The only port of AutoSketch's search (NSDI '24, Algorithm 4) was in ASAPQuery-backend (#547, data_plane/examples/autosketch_comparison.rs). It was hardcoded to a CMS width/depth grid.

After this PR

rqe_optimizer::autosketch adds AutoSketch-Adapted: AutoSketch's configuration search, run once per RQE over the measured cost table. This is the AutoSketch baseline in the evaluation plan, ProjectASAP/ASAPQuery#777 (§3).

pub fn window_adapter(rqe: &Rqe) -> (Seconds, Seconds);
pub fn search(rqe: &Rqe, costs: &[AtomicCostEntry], seed: u64,
              accuracy: impl FnMut(&Rqe, &AtomicCostEntry) -> Option<f64>) -> RqeSearch;
pub fn plan(rqes: &[Rqe], costs: &[AtomicCostEntry], seed: u64,
            accuracy: impl FnMut(&Rqe, &AtomicCostEntry) -> Option<f64>)
    -> Result<AutoSketchPlan, Vec<String>>; // Err = IDs of unservable RQEs
  • Search (search): Algorithm 4 for one RQE, over the measured configurations of every sketch variant that serves its capability.
  • Objective: minimize memory per instance, with insert CPU breaking ties. This is AutoSketch's resource score SC with no ALU term.
  • Accuracy: the caller passes the accuracy oracle; the evaluation passes the measured value at the query window's size. A configuration is feasible if its value meets the RQE's target, and a missing measurement is infeasible.
  • Plan (plan): gives each RQE its own deployment, never shared, even when two RQEs pick the same one, so objectives::score charges ingest per RQE. The mapping is the identity. Latency is not considered.
  • Window (window_adapter): one sliding sketch per query. The window is the lookback S; the slide is the repeat interval T, or gcd(S, T) when T does not divide S. A query reads one instance and never merges.
  • Per-RQE output: the selected configuration, the probes (distinct configurations evaluated, in order) and search wall time. The evaluation charges each probe's benchmark time to AutoSketch's planning time.

How it maps to the paper

Paper (Algorithm 4; App. G, H) This PR
LHS initialization (Alg. 5): distinct values on every dimension Same, per variant, over the measured parameter values. A variant with one parameter (KLL k, DDSketch alpha, HLL lg_k) gets one random seed, because the paper's rule would sample every value, which is exhaustive. The cheapest configuration is seeded only if no LHS point was measured.
Evaluate, then generate neighbors toward fewer resources if feasible and more if not Same
CALC_NEIGHBOR (Alg. 6): rows ±1, columns ×2 or ÷2 Move one parameter to its adjacent measured value; direction is judged by measured memory, so alpha (smaller means more memory) works
EXAMINE: (1) skip evaluated configs, (2) skip those over the hardware limit, (3) skip those no cheaper than a known-feasible config (1) and (3) as in the paper. (2) is dropped: software has no stage/page limits.
Stopping: a path from a feasible start stops shrinking at the first failure; one from an infeasible start stops at the first success Same, per path
No feasible config: Algorithm 4 returns the most accurate; §5.2 says it throws an error Follows §5.2: the RQE is reported as unservable
The compiler maps an operator to one sketch, and the search tunes its parameters Extension: searches every variant for the capability and keeps the cheapest, so it chooses from the same sketches as the MILP

Validation

  • cargo test -p rqe-optimizer: 22 passed, including these 10 for this module:
    • picks the smallest feasible configuration;
    • probes fewer configurations than exhaustive search on an 8×8 grid, never the same one twice;
    • two identical RQEs get two deployments, and score charges ingest twice;
    • adapted windows (T | S and the gcd case) pass candidates::is_eligible;
    • an unservable RQE is reported by ID;
    • a missing measurement is infeasible;
    • on a single axis the search stops at the feasibility boundary from either side;
    • it chooses the cheaper of two variants;
    • a higher-is-better metric is treated as a floor;
    • LHS samples take distinct values on every axis.
  • cargo clippy -p rqe-optimizer --all-targets -- -D warnings and cargo fmt --check -p rqe-optimizer are clean.

🤖 Generated with Claude Code

Port of AutoSketch Algorithm 4 (LHS seeds, feasibility-directed neighbor
search, pruning, stopping) from ASAPQuery-backend autosketch_comparison.rs,
generalized to each sketch variant's measured parameter axes. Each RQE is
searched independently and gets a dedicated x=S sliding deployment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Evaluate and expand each configuration once (EXAMINE rule 1); an
  evaluated configuration is never re-queued.
- Seed the cheapest configuration only when LHS hits no measured point,
  as the comment already said.
- Compare resources as (memory, insert CPU) instead of adding bytes and
  seconds.
- Document the cross-variant search as an extension over the paper.
- Test the single-axis stopping rule, the cross-variant choice, a
  higher-is-better floor and LHS distinctness.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zzylol added a commit that referenced this pull request Oct 5, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zzylol zzylol changed the title rqe-optimizer: add AutoSketch-Adapted per-RQE baseline rqe-optimizer: add AutoSketch's per-query configuration search as a baseline Oct 5, 2026
@zzylol
zzylol merged commit 91177ee into main Oct 5, 2026
2 checks passed
@zzylol
zzylol deleted the feat/rqe-optimizer-autosketch branch October 5, 2026 14:41
zzylol added a commit that referenced this pull request Oct 5, 2026
Runner (examples/autosketch_vs_asap.rs) for the traces workloads of
ProjectASAP/ASAPQuery#777: ASAP (joint MILP with one absolute latency SLA
per sweep point), PerQuery-CostAware and AutoSketch-Adapted, scored by
objectives::score and priced per EC2 family, with sanity checks.

Accuracy now depends on the query's merge count m = S/x: a cost entry may
carry "{metric}@m{b}" keys, eligibility reads the smallest measured b >= m,
and a merge larger than every measured b is ineligible.

Results for Alibaba 2022, Google 2011 and BOOM with figures and summary.
The earlier example and scaling workloads are dropped (#777 §6).

Rebased onto main, which now has #137, #135 and #136.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zzylol added a commit that referenced this pull request Oct 5, 2026
Alibaba 2022, Google 2011 and BOOM, every SLA, model A and model B per
family, PerQuery bound by the SLA and AutoSketch with #135's final search.
Sanity checks pass; the peak bound equals the simulated peak everywhere.

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