From e6cdf844827afe28b0759ac772a92e90d7163a9e Mon Sep 17 00:00:00 2001 From: zzstoatzz Date: Thu, 9 Apr 2026 22:34:32 -0500 Subject: [PATCH] switch to Io.Threaded backend, shelve Evented MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit the Evented (io_uring fiber) backend has been the source of every major issue since the 0.16 migration: 8 cross-Io crash classes, a ReleaseSafe GPF from a zig codegen bug, and a persistent ~10-15% coverage degradation that nobody could trace. the zig team marks Evented as experimental. Io.Threaded restores thread-per-PDS (~2,800 OS threads instead of ~35 fibers), which was the proven model on 0.15 at 99%+ coverage. the entire cross-Io problem class vanishes. ReleaseSafe works again. DNS works natively. the uring networking patch becomes inert. one-line change: const Backend = Io.Evented → Io.Threaded. all io.concurrent() call sites, Io.Future, Io.Mutex, Io.Condition are backend-agnostic through the std.Io abstraction. pool_io becomes redundant but harmless (both runtimes are now Threaded). builds clean: zig build test, zig fmt, and zig build -Dtarget=x86_64-linux-gnu -Doptimize=ReleaseSafe all pass. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/main.zig | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main.zig b/src/main.zig index 960a725..385c898 100644 --- a/src/main.zig +++ b/src/main.zig @@ -48,17 +48,14 @@ const log = std.log.scoped(.relay); pub const default_stack_size = 8 * 1024 * 1024; // -- Io backend selection -- -// Io.Evented (fibers on io_uring): ~35 threads instead of ~2,800 (one per PDS). -// Networking via patched Uring.zig (patches/uring-networking.patch) — implements -// listen, accept, connect, read, write, send via io_uring opcodes. DNS (netLookup) -// is NOT patched; subscribers resolve hostnames through pool_io (Threaded) instead. +// Io.Threaded: one OS thread per io.concurrent() call (~2,800 for PDS subscribers). +// Higher thread count than Evented (~35) but proven stable at 99%+ coverage on 0.15. // -// History: 28 commits of cross-Io fixes (see docs/evented-attempt.md). The -// production SIGSEGV that prompted a brief Threaded revert turned out to be a -// websocket handshake bug (TCP split mid-CRLF), not a fiber issue. Fixed in -// websocket.zig 9ac64da. Evented + ReleaseSafe GPFs immediately on startup -// (same as repro) — must build with ReleaseFast. -const Backend = Io.Evented; +// Evented (io_uring fibers) shelved: 8 crash classes from cross-Io violations, +// ReleaseSafe GPF from fiber context-switch codegen bug, persistent ~10-15% coverage +// degradation, zig team marks Evented as experimental. See docs/evented-attempt.md. +// Can revisit when zig's Evented runtime matures. +const Backend = Io.Threaded; var backend: Backend = undefined; var debug_threaded_io: Io.Threaded = undefined; -- 2.51.2