Skip to content

Avoid realtime clock and immediate-timer imports while the preview1 adapter is paused - #14319

Open
carsonfarmer wants to merge 1 commit into
bytecodealliance:mainfrom
carsonfarmer:cf/adapter-gc-clocks-timers
Open

carsonfarmer wants to merge 1 commit into
bytecodealliance:mainfrom
carsonfarmer:cf/adapter-gc-clocks-timers

Conversation

@carsonfarmer

@carsonfarmer carsonfarmer commented Sep 11, 2026

Copy link
Copy Markdown

Go GC can read wall time and poll timers during cabi_realloc, where host calls are forbidden. Extend the pause added in #13563 to cache realtime reads and answer a single immediate timer poll without calling the host. Other paused polls return NOTSUP.

Adds clock and timer tests; the Go regression passes with the fix on Go 1.26.3 and 1.27.1.

Fixes #14318.

…pter

Extend the existing allocation-time clock pause to realtime reads and a single immediate relative-clock poll. Preserve normal unpaused calls and reject other paused polls. Verify clock pause/resume and immediate-event behavior with deterministic host clocks.

Co-authored-by: Codex <noreply@openai.com>

@dicej dicej left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @carsonfarmer !

Like Alex mentioned on the previous PR, I don't love that we're bending over backwards to accommodate the Go runtime in an otherwise general-purpose tool, plus this tool was meant to be a temporary thing from the beginning, so it doesn't feel great to be adding new features to it. Eventually, I expect we'll want to move this kind of thing to componentize-go, but for now this is probably the path of least resistance.

@asteurer

asteurer commented Sep 12, 2026

Copy link
Copy Markdown

@dicej Definitely open to hosting a custom adapter for componentize-go. At what point would it make sense for us to do this?

@carsonfarmer

Copy link
Copy Markdown
Author

I don't love that we're bending over backwards to accommodate the Go runtime in an otherwise general-purpose tool

Totally fair @dicej, I did try to avoid patching at the wasmtime layer, but couldn't find a cleaner solution. To be honest, there is a lot more clock reading in normal Go runtime than I would have imagined 🫤!

I have a working solution on my end, so there is no actual rush here for me. Happy to defer to a broader discussion about where something like this should ultimately live?

@dicej

dicej commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

@ricochet pursued an alternative approach that would avoid any accommodations in the adapter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wasi Issues pertaining to WASI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preview1 adapter still imports realtime clocks and timer polls during Go canonical allocation

3 participants