alexcrichton opened PR #12371 from alexcrichton:remove-async-support to bytecodealliance:main:
This commit is an attempt to step towards reconciling "old async" and
"new async" in Wasmtime. The old async style is the original async
support in Wasmtime withcall_async,func_wrap_async, etc, where the
main property is that the store is "locked" during an async operation.
Put another way, a store can only execute at most one async operation at
a time. This is in contrast to "new async" support in Wasmtime with the
component-model-async (WASIp3) support, where stores can have more than
one async operation in flight at once.This commit does not fully reconcile these differences, but it does
remove one hurdle along the way:Config::async_support. Since the
beginning of Wasmtime this configuration knob has existed to explicitly
demarcate a config/engine/store as "this thing requiresasyncstuff
internally." This has started to make less and less sense over time
where the line between sync and async has become more murky with WASIp3
where the two worlds comingle. The goal of this commit is to deprecate
Config::async_supportand make the function not actually do anything.In isolation this can't simply be done, however, because there are many
load-bearing aspects of Wasmtime that rely on thisasync_supportknob.
For example once epochs + yielding are enabled it's required that all
Wasm is executed on a fiber lest it hit an epoch and not know how to
yield. That means that this commit is not a simple removal of
async_supportbut instead a refactoring/rearchitecting of how async is
used internally within Wasmtime. The high-level ideas within Wasmtime
now are:
- A
Storehas a "requires async" boolean stored within it.All configuration options which end up requiring async, such as
yielding with epochs, turn this boolean on.Creation of host functions which use async
(e.g.func_wrap_{async,concurrent}) will also turn this option on.Synchronous API entrypoints into Wasmtime ensure that this boolean is
disabled.Asynchronous APIs are usable at any time.
This means that the concept of an async store vs a sync store is now
gone. All stores are equally capable of executing sync/async, and the
change now is that dynamically some stores will require that async is
used with certain configuration. Additionally all panicking conditions
aroundasync_supporthave been converted to errors instead. All
relevant APIs already returned an error and things are murky enough now
that it's not necessarily trivial to get this right at the embedder
level. In the interest of avoiding panics all detected async mismatches
are now first-classwasmtime::Errorvalues.The end result of this commit is that
Config::async_supportis a
deprecated#[doc(hidden)]function that does nothing. While many
internal changes happened as well as having new tests for all this sort
of behavior this is not expected to have a great impact on external
consumers. In general a deletion ofasync_support(true)is in theory
all that's required. This is intended to make it easier to think about
async/sync/etc in the future with WASIp3 and eventually reconcile
func_wrap_asyncandfunc_wrap_concurrentfor example. That's left
for future refactorings however.
alexcrichton commented on PR #12371:
This is currently built on https://github.com/bytecodealliance/wasmtime/pull/12366, so draft for now.
One other motivation for this I'm now remembering too -- I find it a bit odd that one of the more common ways of using Wasmtime, with async, requires explicit opt-in. This makes Wasmtime work "by default" in more situations and is a nice small win for that too.
alexcrichton updated PR #12371.
alexcrichton updated PR #12371.
alexcrichton updated PR #12371.
alexcrichton updated PR #12371.
github-actions[bot] added the label fuzzing on PR #12371.
github-actions[bot] added the label wasmtime:c-api on PR #12371.
github-actions[bot] added the label wasi on PR #12371.
github-actions[bot] commented on PR #12371:
Subscribe to Label Action
cc @fitzgen
<details>
This issue or pull request has been labeled: "fuzzing", "wasi", "wasmtime:c-api"Thus the following users have been cc'd because of the following labels:
- fitzgen: fuzzing
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
alexcrichton updated PR #12371.
alexcrichton has marked PR #12371 as ready for review.
alexcrichton requested fitzgen for a review on PR #12371.
alexcrichton requested wasmtime-fuzz-reviewers for a review on PR #12371.
alexcrichton requested wasmtime-core-reviewers for a review on PR #12371.
alexcrichton requested wasmtime-wasi-reviewers for a review on PR #12371.
alexcrichton requested wasmtime-default-reviewers for a review on PR #12371.
fitzgen submitted PR review:
Only looked at the second commit b/c I think the first is part of a different PR, right?
LGTM, just a nitpick and a question below.
fitzgen created PR review comment:
Other functions in this commit have
requires_async: bool-- can they switch to usingAsyncnessas well?
fitzgen created PR review comment:
Does this need to be an
unsafefunction now? What is the worst that can happen if a caller passesrequires_async = falsewhenFactually does need to be async? Will that result in safe panics onblock_on/with_blocking?
alexcrichton submitted PR review.
alexcrichton created PR review comment:
Good point yeah, I'll document that. Should be safe panicking though, so no new
unsafeneeded
alexcrichton submitted PR review.
alexcrichton created PR review comment:
Good point, I like that!
alexcrichton updated PR #12371.
alexcrichton updated PR #12371.
alexcrichton has enabled auto merge for PR #12371.
alexcrichton added PR #12371 Remove need for explicit Config::async_support knob to the merge queue.
alexcrichton merged PR #12371.
alexcrichton removed PR #12371 Remove need for explicit Config::async_support knob from the merge queue.
Last updated: Jan 29 2026 at 13:25 UTC