Repository navigation
Description
Problem, by example
Planning the paper n100 workload twice, once before and once after #1564 (Stage 3 solves independent MILP blocks separately), gives two plans with the same MILP objective but different reported plan cost.
Command (same for both binaries; measured today on the local machine, binaries built from the base and head of #1564):
asap_planner --workload paper.n100.promql.json --workload paper.n100.sql.json \
--sql-catalog-table <http> --sql-catalog-table <flows> \
--run-until stage3 --format text --verbose
| before #1564 (b9c7fdf) | after #1564 (70830b0) | |
|---|---|---|
selection MILP: objective |
6.732615e5/s | 6.732615e5/s |
cost_per_second (plan_cost of the selected plan) |
6.528505e5 | 6.732607e5 |
| solve time | 24.2 s | 9.7 s |
- The MILP objective is identical, so both selections are optimal.
- plan_cost differs by +3.1% (6.528505e5 -> 6.732607e5). The two plans differ in 21 selected-candidate lines of the verbose output, i.e. they pick different members of an equal-objective tie.
- After perf(stage3,pass2): solve the selection MILP's independent blocks apart (exact); frontier dead-candidate elimination #1564, plan_cost equals the objective up to about 3e-6 relative. Before perf(stage3,pass2): solve the selection MILP's independent blocks apart (exact); frontier dead-candidate elimination #1564, plan_cost was 3.0% below the objective for the plan the old solve happened to return.
Expected: for any optimal selection, the reported plan_cost equals the MILP objective (up to float rounding), so that which optimal selection HiGHS returns cannot change the reported cost.
Not measured here: which cost terms account for the 3% (the verbose output prints per-node costs, but this issue does not attribute the difference to specific terms). Finding them is the first step of the fix.
Why it happens
Stage 3 selects a plan by minimizing the MILP objective, then computes plan_cost separately from the selected nodes. The two are meant to be the same quantity (a debug assert in lib.rs compares them), but for some cost terms the MILP charges something different from what plan_cost charges for the same selection. For plans where the terms agree, tie-breaking cannot matter; for the n100 tie, one optimal selection has a 3% lower plan_cost than another, so the MILP treats as equal two plans that plan_cost does not.
#1564 changed which optimal selection is returned: each independent block is solved as its own HiGHS problem, so the search path (and so the tie-break) differs from the single whole-model solve. The change is correct, since the optimum is the same, and it was accepted as is. It only exposed the gap. The review of #1564 noted this: plans with equal-cost ties may differ from earlier plans at the same cost.
The same gap is already visible elsewhere: eval workloads that declare a service Zipf skew show the Stage 3 objective and plan_cost differing by about 3e-6 relative.
Proposal
Preferred: make the objective equal plan_cost for every term, so the MILP is minimizing exactly the reported number. Find the terms where the MILP coefficient differs from the plan_cost computation for the same selected node (compare the per-node cost breakdown of the two n100 selections), and make both use one definition.
Alternative, if some term cannot be linearized exactly: break ties by plan_cost, for example a second solve with the objective fixed at its optimum and plan_cost minimized, or a tiny secondary objective term. This is a fallback, since it hides the gap instead of removing it.
Scope and acceptance
In scope: the Stage 3 MILP objective and the plan_cost computation. Out of scope: solve speed, block splitting, HiGHS settings.
Done when:
- A regression test builds a small model with two equal-objective selections that have different plan_cost under today's code (found from the n100 tie), and asserts plan_cost equals the objective for both. It fails today.
- On n100, the
selection MILPobjective andcost_per_secondagree to float rounding, for the plan from the pre-perf(stage3,pass2): solve the selection MILP's independent blocks apart (exact); frontier dead-candidate elimination #1564 and the post-perf(stage3,pass2): solve the selection MILP's independent blocks apart (exact); frontier dead-candidate elimination #1564 solve. - Plans for the other paper workloads (m8u, b100) keep their objective; any change in selected plans is listed in the PR.
Status and related work
- Found while accepting perf(stage3,pass2): solve the selection MILP's independent blocks apart (exact); frontier dead-candidate elimination #1564 (Stage 3 independent-block solve, n100 solve 25 s -> 11 s). Maintainers accepted perf(stage3,pass2): solve the selection MILP's independent blocks apart (exact); frontier dead-candidate elimination #1564 unchanged; this issue tracks the underlying objective vs plan_cost gap.
- The numbers above were measured from the two perf(stage3,pass2): solve the selection MILP's independent blocks apart (exact); frontier dead-candidate elimination #1564 binaries on 2026-12-04. Per-term attribution is not done yet.
Activity