Zio - async I/O framework based on libxev

9 posts were split to a new topic: Thoughts on AI Coding

I’ve refactored the coroutine code to be completely standalone, not depending on anything else inside zio, in case anybody wants to use it. Could even turn it into a library on its own. Also added RISC V support. And had a little fun implementing tiny channel for ping-pong test. Stack reservation on virtual memory will be a part of this standalone lib soon.

3 Likes

This took a bit of refactoring, to satisfy the way std.Io wants to do closures, but I have the first version of async/concurrent/await/cancel working. Now that I have this done, I/O operations should go much quicker. The zig-0.16 branch has a long way to go though, as std.posix is being removed and the code in libxev depends on it.

2 Likes

I spun off this project, my effort to replace libxev in zio. There are many reasons for which I’d prefer something slightly different from libxev: consistency of cancelations, immediate timer changes on all backends, wasted stack space, better handling of vectord reads/writes. What got me working on this is actually Zig 0.16 migration, as std.posix is being dismantled, it would be very difficult to upgrade libxev, so I decided to take it a step further and completely replace it, while making the new design a better fit for zio. It supports Linux, Windows, macOS, FreeBSD and NetBSD. Currently missing IOCP backend for Windows, but I don’t think that’s a huge problem, as I expect Windows will be used only as platform for development, not deployment. I’m also planning to make it multi-threading aware, to help with thread pinning in the zio runtime, because that depends on backend specifics.

This is the project:

The code it needs you to write is very verbose, it should not be used directly:

4 Likes

Extracted another library from the code. It’s beneficial to have more extensive CI testing here, so I moved it out of zio. Could be also used by someone else if they want to experiment.

1 Like

To add, apparently glibc has getaddrinfo_a.

FreeBSD has the getdns library, even if that’s not part of their libc.

OpenBSD has getaddrinfo_async, but it seems like andrewrk has already found it since searching openbsd getaddrinfo_async shows an issue in Zig about it as top result on my end.

Windows has DnsQueryEx.