interp: make the timeout recoverable, per package initializer - #5587
Open
0pcom wants to merge 1 commit into
Open
interp: make the timeout recoverable, per package initializer#55870pcom wants to merge 1 commit into
0pcom wants to merge 1 commit into
Conversation
A package initializer that cannot be computed at compile time — crypto AES key expansion, secp256k1 table setup — would run the interpreter out of its budget and fail the BUILD. The only recourse was to raise the timeout for everything, which just moves the cliff. The timeout is now an ordinary recoverable error: the initializer that exceeded it reverts to a runtime call, exactly as it would on native Go, and the build continues. Each initializer also gets its own budget rather than sharing one, so a single expensive one no longer starves the remaining packages of precomputation they CAN do. Under -debug it says which package timed out and after how long, because "this init is now happening at startup instead of compile time" is a performance fact worth being able to see.
Member
|
Previously #2384 |
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.
A package initializer that cannot be computed at compile time — crypto AES key expansion, secp256k1 table setup — runs the interpreter out of its budget and fails the build:
The only recourse today is raising
-interp-timeoutfor everything, which moves the cliff rather than removing it, and slows every other build to accommodate one package.This makes the timeout an ordinary recoverable error. The initializer that exceeded its budget reverts to a runtime call — exactly what would happen on native Go — and the build continues.
errTimeoutjoins the existing set of recoverable errors (errLoopUnrolled,errLoopTooLong,errInvalidPtrToIntSize), so it takes the same path those already do.Each initializer also gets its own budget rather than sharing one clock across the whole run. Previously a single expensive initializer could consume the budget and leave the packages after it with no time for precomputation they could have done.
Under
-debugit reports which package timed out and after how long, since "this init now happens at startup instead of at compile time" is a performance fact worth being able to see.Verified:
go test ./interp/passes, and a program with an initializer heavy enough to exhaust the budget now builds and runs (printing the value its init computed) where it previously failed the build.