-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Feat: Adding a Wasm / WasmEdge target #5331
Comments
Would you be able to elaborate on how supporting wasmedge is different from our existing support for wasm32-wasi? |
Yes. The current tokio support for wasm sockets is based on a draft WASI spec. WasmEdge supports that spec as well. The problem is that the WASI socket draft is too crude and slow evolving. For example, it does not support non-blocking I/O. That makes it difficult to use in many applications. We had hoped that WasmEdge's approach to sockets will eventually become a WASI standard. But that process is slow moving. That's why we forked tokio for WasmEdge users last year to demonstrate that there is a community / market need for more advanced sockets. Cheers |
I'm not sure I understand the point about non-blocking I/O. We already use something called Anyway, I looked over it and tried to understand the differences. Is this list correct?
|
Yes. Tokio MIO is doing it correctly. However, if you use the tokio MIO to write an app and compile it into Wasm -- it will compile successfully but at runtime it will fail since the Wasm runtime does not support WasmEdge provides its own implementation of |
I notice that you go through your To be honest, I am reluctant to go for a solution where Tokio needs to put in work to support every single wasm runtime out there separately. |
Yeah. The WASI socket proposal is still an early draft and misses a lot of things -- it has been like that for a long time now. That's why we forked it. I think what's more likely to happen now is to have the "community" adopt a solution first, and then make that solution into a standard. That is where we are ... |
I'd like to clarify that Again, our hope is that WasmEdge sockets will become part of WASI sockets in the future.
|
Is your feature request related to a problem? Please describe.
Currently, when developers compile their tokio applications to Wasm, the applications are going to fail at runtime due to Wasm's lack of support for standard networking APIs. We would like to implement a feature flag for tokio to support the
wasm32-wasi
compiler target -- specifically for the WasmEdge Runtime.Describe the solution you'd like
We would like to start an effort to merge our fork upstream to tokio's main repo.
Describe alternatives you've considered
Please see the background and our research below.
Additional context
One of the emerging use cases of WebAssembly (Wasm) is a lightweight and secure alternative to Linux containers. Leading container management tools, such as Docker, containerd, Podman / crun, and Kubernetes, have all supported Wasm containers, and in particular WasmEdge, for this reason.
However, to run containerized microservices and serverless functions in Wasm, we need advanced networking sockets in the Wasm runtime. By “advanced”, I mean non-blocking and async sockets. Ideally, we would have a Wasm compiler target in tokio so that when tokio applications are compiled for the
wasm32-wasi
target, it will utilize Wasm socket APIs. Yet, the official Wasm standards have been slow to incorporate sockets.To support users and customers who wish to use tokio and Rust networking apps in Wasm today, the WasmEdge community decided to create its own libc-like socket API in Wasm. WasmEdge is the default Wasm runtime distributed with Docker Desktop and Fedora / Red Hat EPEL. It's networking sockets API can reach a wide developer audience.
We forked tokio to support the WasmEdge socket API when compiling to
wasm32-wasi
. The approach has gained some tractions:Example 1: This is a popular microservice template for an HTTP service backed by a MySQL server. Both the HTTP server (using forked hyper) and MySQL client (using forked mysql_async) in the WasmEdge app are based on the tokio fork.
https://github.com/second-state/microservice-rust-mysql
Example 2: This is a port of the popular Dapr SDK to Wasm. It utilizes (a forked) request on top of the forked tokio to perform HTTP API calls.
https://github.com/second-state/dapr-sdk-wasi
https://github.com/second-state/dapr-wasm
Forking tokio is only a temporary solution to demonstrate demands for this type of application. Now we would like to merge the fork back into tokio so that downstream crates that depend on tokio could also benefit.
Specially, we would like to propose the following:
wasmedge
wasm32-wasi
, tokio will use WasmEdge sockets.Please let me know your thoughts and happy new year!
The text was updated successfully, but these errors were encountered: