-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Only create ConcurrentState in a Store when CM async is enabled
#12377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only create ConcurrentState in a Store when CM async is enabled
#12377
Conversation
e580461 to
617ebec
Compare
Creating the default `ConcurrentState` will create a `FuturesUnordered` which will allocate. By making this state optional, we can keep making progress on bytecodealliance#12069, and put off dealing with `FuturesUnordered` until when we are ready to try and make CM async code handle OOMs.
617ebec to
3ce619b
Compare
|
So I got things working, but I had to effectively turn |
Label Messager: wasmtime:configIt looks like you are changing Wasmtime's configuration options. Make sure to
DetailsTo modify this label's message, edit the To add new label messages or remove existing label messages, edit the |
dicej
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks.
Regarding the WAST test failures: now that the component model combines resource, task, thread, future, stream, and error-context handles all into a single table, tests involving those handles can be sensitive to whether or not e.g. a thread handle has been implicitly allocated as part of a call. For example, the first resource handle created by a guest will have a value of 1 if a thread handle was not allocated (i.e. because CM concurrency is disabled), but it will have a value of 2 if a thread handle was allocated. Also, Wasmtime makes the distinction between "not a valid handle at all" and "a valid handle, but not of the expected kind (e.g. a thread handle being used as a resource handle)".
I made this update as part of #12379; I suspect we'll need to do the same here. In some cases, that might mean explicitly enabling CM async for a given WAST (assuming it's been written with the assumption that a thread handle is allocated for each guest call). In other cases, it might mean changing the expected trap message and/or expected handle values. I can tackle that, if you'd like.
|
Thanks! Flagging the two offending wast tests as requiring CM async was straightforward and resolved the issues |
| .common | ||
| .config(use_pooling_allocator_by_default().unwrap_or(None))?; | ||
| config.wasm_component_model(true); | ||
| config.wasm_component_model_async(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come this was enabled? For debugging, or intentional?
As an unstable feature this is something I'd ideally like to keep turned off until component-model-async is ready
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wasmtime serve and wasi-http unconditionally use the concurrency machinery today. We don't have a separate switch for the internal concurrency machinery vs the Wasm-facing component model async feature. Probably we need something like GC_TYPES, I suppose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm ok yeah I think we'll definitely want something disconnected from wasm feature validation for this. I'll work on that.
This commit is an extension/refactor of bytecodealliance#12377 and bytecodealliance#12379. Notably this decouples the runtime behavior of Wasmtime from enabled/disabled WebAssembly proposals. This enables the `wasmtime serve` subcommand, for example, to continue to disallow component-model-async by default but continue to use `*_concurrent` under the hood. Specifically a new `Config::concurrency_support` knob is added. This is plumbed directly through to `Tunables` and takes over the preexisting `component_model_concurrency` field. This field configures whether tasks/etc are enabled at runtime for component-y things. The default value of this configuration option is the same as `cfg!(feature = "component-model-async")`, and this field is required if component-model-async wasm proposals are enabled. It's intended that eventually this'll affect on-by-default wasm features in Wasmtime depending if the support is compiled in. This results in a subtle shift in behavior where component-model-async concurrency is used by default now because the feature is turned on by default, even though the wasm features are off-by-default. This required adjusting a few indices expected in runtime tests due to tasks/threads being allocated in index spaces. Finally, this additionally denies access at runtime to `Linker::*_concurrent` when concurrent support is disabled as otherwise the various runtime data structures won't be initialized and panics will happen. Closes bytecodealliance#12393
* Document panics from using CM async machinery when CM async is not enabled * Refactor how concurrency support is enabled in a `Store` This commit is an extension/refactor of #12377 and #12379. Notably this decouples the runtime behavior of Wasmtime from enabled/disabled WebAssembly proposals. This enables the `wasmtime serve` subcommand, for example, to continue to disallow component-model-async by default but continue to use `*_concurrent` under the hood. Specifically a new `Config::concurrency_support` knob is added. This is plumbed directly through to `Tunables` and takes over the preexisting `component_model_concurrency` field. This field configures whether tasks/etc are enabled at runtime for component-y things. The default value of this configuration option is the same as `cfg!(feature = "component-model-async")`, and this field is required if component-model-async wasm proposals are enabled. It's intended that eventually this'll affect on-by-default wasm features in Wasmtime depending if the support is compiled in. This results in a subtle shift in behavior where component-model-async concurrency is used by default now because the feature is turned on by default, even though the wasm features are off-by-default. This required adjusting a few indices expected in runtime tests due to tasks/threads being allocated in index spaces. Finally, this additionally denies access at runtime to `Linker::*_concurrent` when concurrent support is disabled as otherwise the various runtime data structures won't be initialized and panics will happen. Closes #12393 * Add a `-Wconcurrency-support` CLI flag Used to update disas tests to show that, when disabled, old codegen quality is preserved * Ungate `Config` flag * Review comments --------- Co-authored-by: Nick Fitzgerald <fitzgen@gmail.com>
Creating the default
ConcurrentStatewill create aFuturesUnorderedwhich will allocate. By making this state optional, we can keep making progress on #12069, and put off dealing withFuturesUnordereduntil when we are ready to try and make CM async code handle OOMs.