Hi, seems like there's been quite a lot of movement on the wasi-sockets standard. Is there any public facing work done on implementing this in wasmtime? I'm interested in understanding how it's being implemented and /or contributing towards this.
https://github.com/bytecodealliance/preview2-prototyping is where we're working on a host implementation for wasi-sockets. It's early, but it's complete enough to accept and connect and send and receive
In particular, the full socket+bind+listen+accept sequence works.
thank you. I'll start reading through and getting to grips with it. I haven't read through the full spec but given that there's deviations from "native" socket libs (e.g. getaddrinfo not implemented)... do you see a path where rust libraries like tokio, h2, etc. can be ported to wasm32-wasi targets or do you think there'll need to be major changes to add wasm target support?
Yes, the vision is that wasi-sockets should be able to look like "normal" sockets to Rust and other languages. Polling/async will need some special considerations, but that's already the case for all platforms out there.
And while wasi-sockets doesn't have a full getaddrinfo
, it does have name resolution, which should support an implementation of getaddrinfo
which should look pretty normal to applications.
yes, I did read and watch your last youtube video talking through the spec so that makes sense to me just wasn't sure how hard the "adapter" layer would be to implement to support popular crates currently used
I'm working on getting a preview2-enabled libc up and running, and then I plan to add sockets support there, which will mean implementing the actual POSIX APIs on top of wasi-sockets. Once we have that, I expect a lot of stuff will Just Work.
This topic was moved here from #general > wasi-sockets by fitzgen (he/him).
I noticed that APIs such as sock-bind and sock-listen are imported in the preview-2. I thought that the reason why wasmtime use the pre-open sockets is to decrease the Nondeterminism. How is Nondeterminism considered in these APIs?
I'm also curious about the Nondeterminism in the sock-accept API. Is it handled by the wasm runtime or it is unavoidable and we just allow it?
Historically, it turns out that the lack of bind/connect in WASI is more a result of non-technical circumstances than technical constraints. Some host environments don't need or want bind/connect, but others do, so it's desirable to have them as an option for those that do.
The "just accept" API does have less nondeterminism than full bind/connect, though in use cases that want just accept, I'd say it's more about giving the host more control over the listening socket than about nondeterminism per se.
Thanks for the explanation! BTW, I want to add some RDMA APIs to the wasi, they will bring some nondeterminism. Is there a way to verify that the nondeterminism brought by my APIs is unavoidable or acceptable?
The nondeterminism brought by my APIs can be divided into two parts:
For WASI, I think it works best to think about nondeterminism from the perspective of specific use cases.
wasi-sockets has a lot of well-understood use cases which are ok with the nondeterminism inherent to sockets. They can fail, they can take variable amounts of time, they can have varying metadata, and so on, and sockets applications are prepared to accept this.
WASI as a whole has other use cases which are not ok with that kind of nondeterminism, but what we say is, those use cases should avoid using wasi-sockets. The Worlds mechanism lets people define their own virtual environments with just the APIs they need, and exclude those that don't make sense for their use cases.
So if you have a new API, instead of asking "is this level of nondeterminism ok with everyone?", we can ask "do you have enough use cases that are ok with this level of nondeterminism?".
Now, all that said, with any kind of shared memory, the concern I expect WASI as a whole will have is virtualizability, rather than determinism. Shared memory means that messages can be sent via loads and stores which can't be intercepted by an intermediary, so it's not possible to virtualize/wrap/interpose/polyfill/etc. an API that includes exposed shared memory.
Last updated: Dec 23 2024 at 12:05 UTC