Skip to content

Optimizer MILP: explore memory as a hard bound instead of a weighted cost term #750

Description

@milindsrivastava1997

Context

The planned mip_assign (cross-AQE sharing MILP, #650) minimizes the existing weighted objective from optimizer/cost_model.rs:

w_ingest_mem·mem_active + w_ingest_cpu·cpu_ingest + w_query_mem·mem_query + w_query_cpu·cpu_query

The memory weights convert bytes into the same units as CPU-seconds with an assumed price ratio (~1e6, see CostWeights docs). That ratio is a guess, and it means the solver trades memory against CPU at an exchange rate nobody has calibrated.

sketch-bench PR #129 (rqe-optimizer) takes a different approach: it minimizes CPU only (ingest + query + merge) and treats memory as a hard constraint, adding a continuous variable M ≥ working-set(a,g) for every assignment and an optional M ≤ budget limit.

Proposal to explore

  • Remove the memory terms from the objective, i.e. CostWeights { ingest_mem: 0, query_mem: 0, .. } or remove the fields.
  • Add memory bounds as constraints instead. Candidates:
    • Peak query working set (PR Re-organize code in repo to be more OSS friendly #129's definition): M ≥ groups × n_windows × mem_bytes_per_instance for every selected (a,g); M ≤ max_query_memory_bytes.
    • Total ingest memory: Σ_g u[g] · n_concurrent(g) · groups(g) · mem_bytes_per_instance ≤ max_ingest_memory_bytes. This is linear in u[g] and needs no extra variable; arguably the number an operator budgets for.
  • Decide where the budget(s) come from: asap-planner CLI flag vs. a ControllerConfig field.

Questions to answer

  • Does the CPU-only + memory-bound formulation give materially different plans from the weighted one on real workloads?
  • Which memory quantity (query working set, ingest/active, retained storage) should be bounded?
  • Should greedy follow the same change so the mip_cost ≤ greedy_cost test invariant still holds?

References

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions