TartanLlama opened PR #12123 from TartanLlama:sy/sync-multithreading to bytecodealliance:main:
<!--
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
-->
TartanLlama edited PR #12123:
Threads are currently not created on sync->sync export calls, sync host->guest calls, and module-level start function calls. This PR adds support to this for all of these.
Fixes #11954
TartanLlama updated PR #12123.
TartanLlama updated PR #12123.
TartanLlama updated PR #12123.
TartanLlama updated PR #12123.
TartanLlama updated PR #12123.
TartanLlama edited PR #12123:
Threads are currently not created on sync->sync export calls, sync host->guest calls, and module-level start function calls. This PR adds support to this for all of these.
I added a component-model-async feature to wasmtime-environ so that sync->sync adapters are compiled as they were originally for wasip2 code, avoiding changing performance characteristics.
Fixes #11954
TartanLlama edited PR #12123:
Threads are currently not created on sync->sync export calls, sync host->guest calls, and module-level start function calls. This PR adds support to this for all of these.
I added a component-model-async feature to wasmtime-environ so that sync->sync adapters are compiled as they were originally for wasip2 code, avoiding changing performance characteristics.
Rather than use the existing prepare_call + start_call machinery, I introduced sync_to_sync_enter/exit_call intrinsics to avoid adding additional host frames to the stack for sync calls
Fixes #11954
TartanLlama updated PR #12123.
TartanLlama updated PR #12123.
TartanLlama updated PR #12123.
TartanLlama updated PR #12123.
TartanLlama updated PR #12123.
TartanLlama updated PR #12123.
TartanLlama updated PR #12123.
TartanLlama updated PR #12123.
TartanLlama updated PR #12123.
TartanLlama updated PR #12123.
TartanLlama updated PR #12123.
TartanLlama updated PR #12123.
TartanLlama edited PR #12123:
Threads are currently not created on sync->sync export calls, sync host->guest calls, and module-level start function calls. This PR adds support to this for all of these.
I added a component-model-async feature to wasmtime-environ so that sync->sync adapters are compiled as they were originally for wasip2 code, avoiding changing performance characteristics.
Rather than use the existing prepare_call + start_call machinery, I introduced sync_to_sync_enter/exit_call intrinsics to avoid adding additional host frames to the stack for sync calls.
Currently, doing operations that require thread state inside
post_returnfunctions is unsupported. If we're happy merging this as-is and creating an issue to resolve this later, we can do so, or I can try and address it prior to merging.Fixes #11954
TartanLlama has marked PR #12123 as ready for review.
TartanLlama requested abrown for a review on PR #12123.
TartanLlama requested wasmtime-compiler-reviewers for a review on PR #12123.
TartanLlama requested pchickey for a review on PR #12123.
TartanLlama requested wasmtime-core-reviewers for a review on PR #12123.
dicej requested alexcrichton for a review on PR #12123.
dicej requested dicej for a review on PR #12123.
I've only skimmed this so far; it looks generally reasonable, but I expect it will conflict with https://github.com/bytecodealliance/wasmtime/pull/12153, which I'm about to split into smaller PRs per @alexcrichton's request.
Given that the
component-model-asyncfeature is now enabled by default, we'll need to be conscious of the overhead of e.g. callingsync_to_sync_enter_callandsync_to_sync_exit_callper this Zulip topic. In https://github.com/bytecodealliance/wasmtime/pull/12153, I had to get creative and sometimes lazily pushGuestTasks andGuestThreads as necessary to avoid pessimizing sync-to-sync adapters. @TartanLlama we should chat sometime about if (and if so, how) we could do a similar optimization here.
Last updated: Jan 09 2026 at 13:15 UTC