Stream: git-wasmtime

Topic: wasmtime / PR #15178 [wasmtime-wasi] add hook for trackin...


view this post on Zulip Wasmtime GitHub notifications bot (Nov 06 2026 at 00:11):

dicej requested pchickey for a review on PR #15178.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 06 2026 at 00:11):

dicej opened PR #15178 from dicej:wasi-hooks-and-permits to bytecodealliance:main:

This adds a new WasiHooks trait, modeled loosely on the existing WasiHttpHooks trait. For now, this new trait has only one interesting method, acquire, which is called any time the guest wants to open a host file descriptor. That method allows the embedder to apply a semaphore-like policy which may approve, delay, or reject the allocation, e.g. to keep the process-wide total under a certain limit and/or ensure equitable allocation across multiple guests. Approval is represented as a Box<dyn WasiPermit>, which wasmtime-wasi will drop immediately after closing the associated file descriptor, thereby notifying the embedder that it was released, possibly unblocking another pending request.

The other WasiHooks method, owned, returns a "clone" of self for use in 'static contexts. This is needed so that e.g. TcpListenStream and TcpSocket are able to acquire additional permits on demand for any accepted sockets, and they must remaing 'static so they can be stored in the resource table.

Note that I haven't added any test coverage for this feature yet; I'd like to get feedback on the overall approach first.

<!--
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 review the Bytecode Alliance's AI tool usage policy at
https://github.com/bytecodealliance/governance/blob/main/AI_TOOL_POLICY.md

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 (Nov 06 2026 at 02:44):

github-actions[bot] added the label wasi on PR #15178.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 06 2026 at 15:05):

dicej updated PR #15178.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 06 2026 at 15:19):

dicej updated PR #15178.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 17:00):

:memo: alexcrichton submitted PR review:

Personally I'm a bit hesitant about this style of design. This feels quite heavyweight and tacked on to me, for example:

I don't have a great fix per se for all of this, but I think it might be worth exploring and/or brainstorming about other possible designs. One example is that having both *Ctx and *Hook is kind of a bummer, pretty much everything you might configure through WasiCtx is more-or-less also suitable through WasiHooks. This is also true for the preexisting HTTP bits as well. In theory it might be reasonable to delete all the *Ctx structures entirely, have per-proposal *Hooks traits, and then the *View types would have the table + dyn *Hooks. Whether or not something like that makes sense I'm not sure, but it would unify the nature of preexisting callbacks we have with this new callback.

Cost-wise one possible alternative would be a trait method for acquisition and a trait method for dropping. That's more difficult to plumb around since ownership can't be used, but I believe it should be feasible nonetheless. Given how few locations we have that create fds, coupled with how few locations we drop fds (basically resource destructors), this seems relatively tractable to me. One downside of such an approach though is that it requires manual annotation of "this is an fd that should get limited", whereas the type-based approach here makes it much harder to forget.

Mostly though I want to highlight how while I can see how this solves the problem I think this is being inserted in such a way that doesn't mesh well with the rest of the system, and I think comes a bit too high of a cost.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2026 at 18:48):

dicej updated PR #15178.


Last updated: Nov 19 2026 at 20:05 UTC