fix(optimizer): bound queued solves to one deadline - #893
Merged
Conversation
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.
Stack
This PR is based on #890 because it needs the same optimizer solve files. Review only the incremental diff. Retarget it to
masterafter #890 lands.What
time_limit_sbudgetkTimeLimitas deadline expiry while keeping other non-optimal statuses as solver errorsWhy
The worker could spend the full time limit on the service solve and then reset it for the economic solve. Requests abandoned by Core could also wait behind the global lock and run later, delaying fresh plans.
This bounds useful work to one budget and keeps expired queue entries out of the solver.
Part of #885.
Tests
go vet ./internal/mpcgo test -race ./internal/mpcmake verifymake verify-all, including linux/arm64, linux/amd64 and windows/amd64 buildsLimits
The deadline is cooperative; this PR does not kill a native solver thread while it is running. Solver-native time limits bound active work.
The Unix worker counts its own queue wait in the worker budget.
ProcessTransportdrops context-expired waiters before write and Core's outer context still bounds the whole call, but its pre-write gate time is not encoded into the JSON budget. A transport-independent absolute timestamp needs a later contract field or payload stamping in the Core files currently owned by #734–#736.