Stream: git-wasmtime

Topic: wasmtime / PR #11365 Simplify WASI internal implementations


view this post on Zulip Wasmtime GitHub notifications bot (Jul 31 2025 at 20:24):

alexcrichton opened PR #11365 from alexcrichton:wasi-refactor to bytecodealliance:main:

This commit migrates the WASIp2 implementation to be closer to the upcoming WASIp3 implementation in terms of how things are implemented internally. Previously the way things worked with WASIp2 is:

While this all worked it's a bit complicated for a few reasons:

  1. Dealing with generically named structures like WasiImpl (or IoImpl or WasiHttpImpl) is a bit baroque and not always obvious as to what's going on.
  2. The extra layer of generics in impl<T> Host for WasiImpl<T> adds a layer of conceptual indirection which is non-obvious.
  3. Other WASI proposal implementations do not use this strategy and instead use "view" types or impl Host for TheType for example.
  4. Internal incantations of add_to_linker had to deal with mixtures of IoImpl and WasiImpl and aligning everything just right.
  5. An extra layer of generics on all impls meant that everything was generic meaning that wasmtime-wasi-the-crate didn't generate much code, causing longer codegen times for consumers.

The goal of this commit is to migrate towards the style of what WASIp3 is prototyping for how impls are modeled. This is done to increase the amount of code that can be shared between WASIp2 and WASIp3. This has a number of benefits such as being easier to understand and also being more modular where wasi:clocks implementations of traits don't require filesystem context to be present (as is the case today). This in theory helps a more mix-and-match paradigm of blending together various bits and pieces of wasmtime-wasi implementations.

Concretely the changes made here are:

The immediate goal of this refactoring is to enable more sharing along the lines of #11362. This was not possible prior because WASIp3 requires a simultaneous borrow on the table/ctx while the trait hierarchy previously gave you one-or-the-other. With this new organization it will be possible to get both at the same time meaning more structure/contexts/etc can be shared between implementations.

prtest:full

<!--
Please make sure you include the following information:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (Jul 31 2025 at 20:24):

alexcrichton requested wasmtime-wasi-reviewers for a review on PR #11365.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 31 2025 at 20:24):

alexcrichton requested wasmtime-core-reviewers for a review on PR #11365.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 31 2025 at 20:24):

alexcrichton requested fitzgen for a review on PR #11365.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 31 2025 at 20:25):

alexcrichton commented on PR #11365:

I can sort of preemptively apologize to embedders about this. I feel like every few versions of Wasmtime we rejigger how WASI traits work and how the impls are set up. I feel like we continue to march towards something that fits for all use cases and feels right but this is inevitably an iterative progress where we can't leapfrog to the end.

If anyone runs across this and has difficulty updating I'm happy to help out in updates, feel free to ping me on Zulip or here or an issue.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 31 2025 at 21:27):

pchickey submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 31 2025 at 21:29):

pchickey commented on PR #11365:

There are still some more places to thread through this change (CI found wasi-keyvalue) but the design change looks good. Glad this is possible now that we got rid of get_host for HasData.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 01 2025 at 00:46):

alexcrichton updated PR #11365.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 01 2025 at 00:48):

alexcrichton updated PR #11365.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 01 2025 at 00:48):

alexcrichton has enabled auto merge for PR #11365.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 01 2025 at 01:00):

alexcrichton updated PR #11365.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 01 2025 at 01:48):

alexcrichton merged PR #11365.


Last updated: Dec 06 2025 at 07:03 UTC