-
Notifications
You must be signed in to change notification settings - Fork 256
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
WASI IPC module #49
Comments
On one level, talking to drivers, daemons, window managers, system-wide data buses directly is often non-portable, even if the IPC APIs themselves are relatively portable. It's one thing to expose Unix-domain socket functinonality, but another if what you really want to do is eg. Wayland protocol, because not all hosts have Wayland. So one option here is to look into more abstract interfaces to eg. display services. This is surely a complex task, but it may be preferable if the alternative is eg. emulating Wayland on hosts with non-Wayland display services. On another, some use cases may want wasm primarily for the architecture independence, and less so the OS independence, and may be ok assuming eg. Linux and associated userspace services. With WASI's anticipated modular API design, we could plausibly consider such use cases, though it'll come down to priorities of the Subgroup. |
I think that I might be one of those people, who consider architectural independence more important, over the operating system independence. However, I understand that you cannot neglect all the other user groups that can invent interesting use-cases for WASI! In my particular use-case, I am interested in using ZMQ on WASI (whose IPC interface is the fastest one and can really benefit from something like in-kernel WASI with fast syscalls). Also, another very interesting possibility to me is having a portable pure-rust wayland compositor based on Smithay. However, its implementation requires IPC for communications. I think that the modular design might be very meaningful in such a case. I think that there should definitely be modules covering most of often-used POSIX system calls. |
Just few nitpicks.
ZMQ is arguably not the fastest IPC (you don't have to go far - look at ZMQs successor nanomsg or the nanomsgs successor nng ).
Sure there will be modules, but I'm not convinced that these modules shall be part of WASI. There shall be a WASI-compatible POSIX module, but it wouldn't be part of WASI IMHO. |
@dumblob hey there! I didn't really mean that ZMQ is the fastest one, I meant that IPC is the fastest transfer medium for ZMQ itself. But thanks a lot for the recommendation, a will look into nanomsg! |
What about APIs like the ones seen on the web, quite high level like broadcast channel or something like shared workers to let people decide on how to implement their communication channel or eventually have a D-Bus like API built on top of it? |
It's in scope. The first step is to examine some high-level design questions. What do "browsing context" and "same origin" translate to in a non-Web context? Do the applications that wish to communicate all live in the same WebAssembly store? |
IPC are important for high performance work |
It has been quite a while, looks like WASI has seen some significant progress. Has there been any progress on modules for architecture-independent UNIX-specific APIs? Right now I am having a look at NNG again and documentation for IPC communication describes the need in UNIX domain sockets. Is it possible to use something like NNG via WASI nowadays, what do you think? Again, thanks for the amazing work! |
There hasn't been anyone volunteering to advance Unix-specific APIs so far. That said, I expect it is an area that makes sense in general. |
What do you think is the most performant way for a WASI binary to talk to the outside world right now? It looks like communication over TCP is partially supported, which also means WebSocket? Or maybe UDP? |
Could you say more about what you're looking to do here? You mentioned WebSocket; are you looking for something that can run in a browser? Of course, you also mention UDP or TCP, which aren't available (as such) in browsers :-). |
The idea is to have universal WASI binaries which can communicate with the outside system via a system bus (similar DBUS). So I am looking for a way for those binaries to cross the isolated border. |
Could you be even more specific? 😃 Would these binaries be hardcoded to work with D-Bus specifically, or are you envisioning an abstraction that could be implemented on D-Bus or also on operating systems that don't use D-Bus but have comparable functionality? What would be the sandboxing requirements for these binaries? With access to D-Bus or similar systems, would WASI need to be able to restrict the kinds of messages they can send, or who they can be sent to, to provide additional sandboxing? D-Bus carries a lot of assumptions about desktop-like computing environments. Would these "universal" binaries similarly be limited to desktop-like use cases? |
I think for windows Named PIPE, and for unix, (Unix Sock) is enough. |
Yeah, D-BUS is just a comparison 🙂 My idea of "universal" binaries is more similar to UWP, where it mostly means architecture portability on top of one specific operating system or operating environment. I used D-BUS as an analogy, because I want to discover the most high-bandwidth and low-latency way for this binary to exchange data (binary messages) with the outside system. In my case the bus itself will handle all the access limitations and sandboxing. In theory, each binary needs access to only one socket or even just one TCP/UDP port, whatever is possible with WASI at the moment. And the communication should be both-ways. Those binaries are indeed for a desktop operating system. |
The most straightforward way to get started would be to use stdin/stdout. That works in WASI today, and host environments can arrange for those to be TCP, UDP, or other kinds of sockets, or pipes, or other things. |
But I would guess that using stdin/stdout for communication compromises binary's ability to use it for terminal input/output? If that's true, that will mean that porting applications to this binary format will require rewriting everything that outputs into stdout. |
I have done something similar with Gate. Gate programs can use WASI functions to do I/O through a single file descriptor. The fd number can be discovered via an environment variable (WASI). That fd is used to talk to Gate's custom service bus. See https://github.com/gate-computer/gate/blob/master/ABI.md for more details. |
@tsavola, thanks for an interesting idea! I need to look into communicating via simple file descriptors. I wonder if nng can use that for communication... Also, you reminded me that I am still working with WASM modules and I can import functions from the outside environment to use as system calls! |
(@tsavola, it was fun to read about your project!) |
Hey there, everyone!
As I very briefly described in WebAssembly/wasi-sdk#33, WASI at the moment seems to be lacking support for IPC communication. I think that this feature is essential for some applications, including drivers, daemons, window managers as well as applications talking to system-wide data buses.
It looks like there only about a dozen system calls required to make all IPC scenarios run correctly if we decide to follow the POSIX syscalls first.
So, is this possible? What do you think about the amount of effort it will take to implement support for it? The only things that sketch me out are mentions of synchronization primitives.
Thanks!
The text was updated successfully, but these errors were encountered: