Skip to content

perf: cap the cost stage, log what it left, and let continuity run on a split - #177

Merged
andig merged 5 commits into
mainfrom
perf/cost-stage-cap
Oct 4, 2026
Merged

andig merged 5 commits into
mainfrom
perf/cost-stage-cap

Conversation

@andig

@andig andig commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

fixes #170

Ports what the deployed rollup branch still had over main: #154 (cost stage capped at 3 s, CBC gap read from the log as cost_stage_gap, continuity_stage in the request log), #155 (requests with more than one currency unit unproven are dumped too), and the inline c_active read. Cherry-picked with -x, conflicts against #160 resolved by keeping both.

The continuity skip gate from #154 is changed while porting it. It summed probe and cost time, and on the split path the probe alone is PROBE_SHARE of the time limit, so every split request skipped the stage. Replaying the request from #170 under production limits: gate on probe + cost skips at 2.8 s and leaves 5 charge starts, gate on the cost stage runs 1.1 s and merges both cars to one start each at the same cost and peak. The joint path keeps its gate, there the probe is the whole solve. A cost stage faked without a solver log, as in the #160 tests, reports no gap instead of raising.

_solve_continuity was over ruff's return and statement limits on the rollup already, the clock gate moved into _continuity_clock to get under them.

The late import placement and the missing circuits from the same issue are separate changes.

🤖 Generated with Claude Code

andig and others added 5 commits October 4, 2026 15:12
The continuity candidate is the model plus a start variable per step under a
bound on the cost it just optimized, the harder problem of the two. Where the
incumbent took longer than the second this stage may spend, the candidate hits
the cap with nothing to show. Production measured it over five days: 14 % of
joint solves ran the stage, half of those sat on the cap, p90 went from 0.68 s
to 1.32 s in the deploy hour and the replica average rose 18 %. The incumbent's
own clock names those requests before the second is spent, so skip them.

The stage was also invisible: no timer and no outcome, so this had to be found
by subtracting the timed stages from the total. It now leaves stage_seconds
'continuity' and a continuity_stage string the way the tie break does, and the
request log carries both.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit 02a839e)
The cost stage is anytime branch and bound and spends whatever the reserve leaves of the
limit. On the production 10 s limit that is 5.4 s, and with the tie break seated in the
rest, 17 percent of the split solves ended past the limit. An absolute cap of 3 s brings a
split to about 7.5 s. Whether the seconds past 3 bought money is unknown, so the request
log now carries the cost stage value and the gap CBC reported between its schedule and
its bound, in currency, zero when proven.

(cherry picked from commit c07ab08)
The helper pushed _solve_continuity past the return and statement limits once the rollup's
stage reporting is merged in.

(cherry picked from commit f73bdb1)
With the cost stage capped nothing exhausts the time limit any more, so the slow request
dump stopped filling. A request now also lands in it when the cost stage gap is above one
currency unit, and the dump line carries that gap, so the replay corpus holds exactly the
requests where a longer clock might have bought money.

(cherry picked from commit 4c32a65)
The skip gate summed probe and cost time. On the split path the probe
alone is PROBE_SHARE of the time limit, so every split request skipped
the stage. Gate on the cost stage the candidate extends, keep the probe
for the joint path. A cost stage without a solver log reports no gap.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@andig andig added the bug Something isn't working label Oct 4, 2026
@andig
andig merged commit 6ba24fc into main Oct 4, 2026
1 check passed
@andig
andig deleted the perf/cost-stage-cap branch October 4, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flat tariff, two vehicles: late import preference pins charging to the window end and blocks continuity

1 participant