Repository navigation
Add sliding-window RQE deployment optimizer - #129
Merged
Merged
Conversation
This was referenced Sep 29, 2026
milindsrivastava1997
marked this pull request as ready for review
October 4, 2026 14:22
This was referenced Oct 26, 2026
Closed
This was referenced Oct 27, 2026
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.
Summary
This PR adds a sketch-deployment optimizer for a workload of repeating query
expressions (RQEs). Given measured sketch-bench data and a workload, it
generates legal sliding-window deployments and selects a low-CPU plan without
eagerly enumerating every RQE-to-deployment mapping.
The main addition is a HiGHS-backed mixed-integer linear program (MILP). It
supports overlapping deployments (
x > y), deployment sharing acrosscompatible RQEs, and optional query-latency limits.
Examples
First export the measured cost table:
Inspect candidates without enumerating mappings:
Print a few feasible mappings, then exit:
Solve for minimum steady-state CPU:
Solve with a 3 ms limit on the 1-day p99 query:
Safety
Do not run
cargo run -p rqe-optimizer --example small_problemwith nomode flag on a large workload. Eager mode retains every feasible mapping and
can exhaust memory.
--streamingavoids retaining all mappings, but can stillrun for a long time as its Pareto frontier grows. Use
--candidates-only,--sample-mappings N, or--milpfor bounded inspection and optimization.Candidate model
A deployment is:
x > yis supported. Each arriving item updatesx / yactive overlappinginstances.
For an RQE with lookback
Sand intervalT, a deployment is eligible whenits capability, labels, and measured accuracy match, and:
A query merges exactly
S / xnon-overlapping instances. Candidate dominancepruning removes a candidate only when another candidate can serve every same
RQE with no worse query memory, ingest CPU, or per-RQE latency.
MILP
Inputs
S, intervalT, accuracy metric,and accuracy tolerance.
items/sec.
and query; plus measured accuracy metrics.
limits.
Decision variables and constraints
For each eligible RQE/deployment pair,
z[i,d]is binary and means RQEiuses deployment
d.u[d]is binary and means deploymentdis active.Mis continuous peak query memory.The model requires every RQE to choose one eligible deployment, makes every
selected deployment active, prevents unused active deployments, and ensures
Mcovers every selected query working set. Optional memory and latencylimits are hard constraints.
Objective
The current solve minimizes steady-state CPU:
Ingest is charged once per active deployment:
Query and merge CPU are charged per RQE at that RQE's interval.
Outputs
A solve returns one deployment for each RQE, including sketch configuration,
x, andy, plus peak query working memory; ingest, merge, query, and totalsteady-state CPU; and estimated latency for every RQE.
Current modeling boundaries
not yet validate final accuracy after merging
S / xinstances.groups × bytes per instance. Itexcludes retained storage, merge buffers, and concurrent queries.
Next work
Correctness and measurement
an accuracy profile keyed by configuration, logical data volume, and merge
depth.
Optimization
weighted objectives.
Deferred scope
enough to prove reuse safe.
Validation
cargo test -p rqe-optimizer(12 tests)cargo clippy -p rqe-optimizer --all-targets -- -D warningsa small workload with shared deployment activation costs.
enumeration.