dicej opened PR #13563 from dicej:p1-adapter-pause-monotonic-clock to bytecodealliance:main:
This adds a new
adapter_monotonic_clock_set_pausedexport to the adapter which toggles whetherclock_time_getwill callmonotonic_clock::nowwhen called withCLOCKID_MONOTONICversus returning a cached value instead.This is a workaround for guest language runtimes whose
cabi_reallocimplementations may callclock_time_get. Since calling imports fromcabi_reallocis disallowed, this will trap if the adapter callsmonotonic_clock::now. We can avoid the trap by using a cached value instead.This helps us address
https://github.com/bytecodealliance/componentize-go/issues/56. In that case,cabi_reallocis implemented by calling
unsafe.SliceData to allocate a segment of the appropriate size and alignment from the GC-managed heap and then pinning it using pinner.Pin until it is no longer needed. However, such an allocation may trigger a GC under memory pressure, and as of this writing the Go collector callsclock_time_getto measure time spent in various stages of the GC process.An alternative fix for the
componentize-goissue would be to modify the Go runtime to avoid such calls on WASI during GC, but getting that upstream is likely to be significantly more difficult than working around it in the adapter. If and when Go supports WASIp3 or later natively, the adapter will no longer be used, in which case we will certainly address this upstream.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
dicej requested pchickey for a review on PR #13563.
dicej requested wasmtime-wasi-reviewers for a review on PR #13563.
:thumbs_up: alexcrichton submitted PR review:
I'm not thrilled about it, but I suspect you aren't either, and so long as Go is an unchangable monolith I don't think there are many other realistic options on the table.
alexcrichton added PR #13563 add monotonic clock "pause" feature to p1->p2 adapter to the merge queue.
:check: alexcrichton merged PR #13563.
alexcrichton removed PR #13563 add monotonic clock "pause" feature to p1->p2 adapter from the merge queue.
Last updated: Jul 29 2026 at 05:03 UTC