I watched "Live Coding a Basic Chat Server in Zig with Evented I/O" again today and at https://youtu.be/aDd0BexKWps?t=2991 (49:51 into the stream) there is a discussion on how using evented I/O can also make your control plane (and not only your I/O data plane) multithreaded and introduce data races.
I found this surprising behavior because evented I/O as an abstract concept does not in itself force the control plane to also be multithreaded, and most evented I/O systems use a single-threaded control plane for safety.
There's a subtle difference but I would prefer keeping the event loop control plane single-threaded, while handing off to the threadpool only for I/O that could block.
The reason this matters is because Zig's async/await (which is awesome) is supposed to enable the same code to work in different I/O modes, however multithreading in the control plane introduces a "color" in the form of H.B.D. data race safety.
Of course, if the user wants to run their own functions in the threadpool then that introduces multithreading, but it should be possible to opt-in to evented I/O without introducing data races?
I watched "Live Coding a Basic Chat Server in Zig with Evented I/O" again today and at https://youtu.be/aDd0BexKWps?t=2991 (49:51 into the stream) there is a discussion on how using evented I/O can also make your control plane (and not only your I/O data plane) multithreaded and introduce data races.
I found this surprising behavior because evented I/O as an abstract concept does not in itself force the control plane to also be multithreaded, and most evented I/O systems use a single-threaded control plane for safety.
There's a subtle difference but I would prefer keeping the event loop control plane single-threaded, while handing off to the threadpool only for I/O that could block.
The reason this matters is because Zig's async/await (which is awesome) is supposed to enable the same code to work in different I/O modes, however multithreading in the control plane introduces a "color" in the form of H.B.D. data race safety.
Of course, if the user wants to run their own functions in the threadpool then that introduces multithreading, but it should be possible to opt-in to evented I/O without introducing data races?