Skip to content

interp: make the timeout recoverable, per package initializer - #5587

Open
0pcom wants to merge 1 commit into
tinygo-org:devfrom
0magnet:interp-recoverable-timeout
Open

interp: make the timeout recoverable, per package initializer#5587
0pcom wants to merge 1 commit into
tinygo-org:devfrom
0magnet:interp-recoverable-timeout

Conversation

@0pcom

@0pcom 0pcom commented Aug 14, 2026

Copy link
Copy Markdown

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:

interp: running for more than 3m0s, timing out (executed calls: ...)

The only recourse today is raising -interp-timeout for 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. errTimeout joins 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 -debug it 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.

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.
@dgryski

dgryski commented Aug 14, 2026

Copy link
Copy Markdown
Member

Previously #2384

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.

2 participants