Zig-aio: lightweight abstraction over io_uring and coroutines

I was curious, and aio has now libc-less wasi support. Every operation is supported apart from aio.ChildExit and all the socket operations. std.os.wasi has some socket functions, which may be able to give partial support for them later. wasix supports posix like sockets fully, but the only wasix runtime wasmer did not like zig stds threading implementation for whatever reason.

I also noticed that running the tests with wasmtime there’s random memory corruption which is why I’m not adding wasi tests to the CI test suite. I’m not yet sure where is the root cause for this.

coro has no wasm support, but might get it in future https://github.com/WebAssembly/stack-switching/blob/main/proposals/continuations/Explainer.md

This also increased posix compatibility of aio, and OpenBSD became supported. OpenBSD was unsupported because it lacked EVFILT_USER for kevent. I implemented pipe based EventSource as the last resort fallback that’s used on both OpenBSD and wasi. Although wasi doesn’t really have pipes outside wasix spec, I emulate them by creating a file and deleting it immediately. This gives me a fd that I can poll, and thus use as a event source.

You can check out the wasi posix glue here:

2 Likes

ChildExit is now implemented for windows. Windows should now cover all the operations. Test coverage is still unclear.

3 Likes

There’s been lots of stability and performance work in zig-aio lately. It has become quite mature. zig-aio can now be used in single threaded programs on all platforms as well, and may work even faster inside single threaded builds depending on the workload. The only caveat to single thread is that on non io_uring backends, some operations may block like fsync and socket.

Next coming up is multi-shot operations, registered files and buffer rings which should improve zig-aio’s performance under io_uring dramatically when these apis are used properly. The other backends may also get some benefits from these apis.

I’d also like to thank the contributors who have been contributing fixes and features to zig-aio.

6 Likes