Skip to content

Bound the UpgradeRoots pass in solver steps - #105

Merged
jonyoder merged 2 commits into
mainfrom
upgrade-round-budget
Nov 18, 2026
Merged

jonyoder merged 2 commits into
mainfrom
upgrade-round-budget

Conversation

@jonyoder

@jonyoder jonyoder commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Adds a step budget for the UpgradeRoots pass so its pins no longer depend on host load. New Options.UpgradeStepFactor (× the first solve's steps) and Options.UpgradeMaxSteps (absolute) bound all re-solves together; zero keeps today's behaviour, so this is a minor release.


How it works. A step is one call of the solver's Interrupt hook: one main-loop round or one conflict-resolution step. The resolver already set Interrupt; it now counts calls too. Each re-solve gets the steps the pass has left and is stopped when they run out; the pass then ends with the best answer so far. The time options still work and can be set alongside as a backstop, documented as non-repeatable.

Determinism. The solver runs on one goroutine and calls Interrupt from its loop, so the count depends only on inputs. New tests run 12 random fixtures with a budget that cuts the pass partway, 20 runs each at GOMAXPROCS 1 and 8, with 4 busy goroutines and a fake clock that jumps randomly on every read: same pins and same per-solve step counts every run. Also passes under -race. A control test shows the same jumping clock does move a time-bounded pass.

Charging. Tests pin exact step counts per re-solve: a budget one step short of the first two re-solves cuts the second (base answer); the exact budget keeps its gain and starts no third. Mutations checked: not charging, or giving each re-solve the full budget, fails 3 tests; a clock-dependent budget fails the determinism test.

Cost (Nov PyPI snapshot, UpgradeRoots=40, 3 runs per mode, idle laptop):

input base steps full pass time×2 step×1 step×2 / ×4
tf 2.13 + 17 roots 143 3 re-solves, 251 steps full pass 1 re-solve (143), cut full pass
20-root mix (airflow, tf, numpy<2, ...) 5655 (~16 s) 1 re-solve, 5853 steps (~16 s) full pass cut, base kept not measured

On an idle machine time per step is about the same for the base solve and the re-solves, so a step factor of about 2 matches UpgradeTimeFactor 2 without load. Pins were the same in all 3 runs in every mode here, because the machine was idle.

🤖 Generated with Claude Code

Time bounds make pins depend on host load. A step budget gives the same
pins for the same inputs on every run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jonyoder
jonyoder merged commit 07efd41 into main Nov 18, 2026
2 checks passed
@jonyoder
jonyoder deleted the upgrade-round-budget branch November 18, 2026 16:06
@jonyoder jonyoder mentioned this pull request Nov 18, 2026
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