# handoff: lalinsky/zio to prod (2026-10-29) prod runs `-Dbackend=zio` against the fork at `zzstoatzz.io/zio` (73b3e09): one scheduler thread, fibers over `Io.Threaded`. the branch `backend/lalinsky-zio-0.17` replaces that with lalinsky's zio, a complete std.Io runtime: N executor threads with work stealing, io_uring with an epoll fallback chosen at runtime. this handoff is the state of that branch, the evidence gathered today on a throwaway box, and the steps left to ship it. ## branch state `backend/lalinsky-zio-0.17`, rebased today onto main `f3e8d52`: | commit | what | |---|---| | `77d39e8` | swap `zzstoatzz.io/zio` for `lalinsky/zio` at `3bbd74d` (his main of 2026-10-07, zig 0.17); `RELAY_IO_EXECUTORS` (default 4, 0 = one per usable cpu); `/metrics` zio block replaced with lalinsky's scheduler counters | | `7c37ceb` | never close a socket another fiber is parked on: shutdown cancels the accept task before `listener.deinit`, and a kicked consumer's writeLoop half-closes via `util.net.interrupt` instead of `conn.close` so readLoop wakes with EOF and owns the close. lalinsky's epoll/kqueue backends assert this; under io_uring the parked fiber would simply never wake. regression test in `src/internal/util/net.zig`, runs on whichever backend the suite is built with | | `ff9bb0c` | port the `ingest_ack` canceled-reader test from the fork's `ZioBackend` to a two-executor `Runtime`; skips under threaded | the rebase had two conflicts, both resolved in favour of main's newer behaviour plus the branch's ordering rule: shutdown keeps main's `dp.flush` + `producers_done` + `broadcast_future.await` drain (the branch had `cancel`), with metrics cancelled before its listener is closed; the consumer writeLoop keeps main's `abortStaging` and the kicked `ConsumerTooSlow` frame (2026-10-18), then half-closes instead of closing. **the rebased branch is local only.** origin still has the pre-rebase branch (`b2d2554`). it needs `git push --force-with-lease origin backend/lalinsky-zio-0.17` from `zat.dev/zlay.lalinsky-zio`; the harness refused to force-push from the session that did the rebase. verified locally on the rebased branch: - `zig build test -Dbackend=zio`: 147 passed, 20 skipped. - `zig build test` (threaded): 146 passed, 21 skipped. - `zig build -Doptimize=ReleaseSafe -Dbackend=zio -Dtarget=x86_64-linux-gnu`: ok. CI has never run for zlay: the repo record has no spindle bound (`tg repo edit zat.dev/zlay --spindle spindle.tangled.sh`; zat and zds use that spindle). bind it before pushing so the rewritten workflow from `f3e8d52` actually runs on the branch. ## evidence throwaway fly machine `zlay-ab` (performance-8x, 8 vCPU / 16 GB, ord, kernel 6.12), both binaries built locally for x86_64-linux-gnu ReleaseSafe, same postgres and event log, seeded with 1,941 hosts from `bsky.network` and then slurping the whole fleet. each run is `timeout 1500` (or 600) so it ends on SIGTERM, which also exercises shutdown. samples every 30 s from `/metrics` and `/proc/`; delivery measured by an on-box websocket consumer. steady state is the second half of each run. ### A/B: one consumer, 25 minutes each | | fork zio (main `f3e8d52`) | lalinsky zio (branch, 4 executors) | |---|---|---| | upstream connections | 1,925 .. 1,941 | 1,920 .. 1,925 | | threads | 75 | 48 | | RSS | 1.07 .. 1.14 GiB | 1.11 .. 1.20 GiB | | cpu, steady | 0.41 cores | 0.44 cores | | `/metrics` latency | 22 .. 71 ms | 19 .. 81 ms | | consumer rate | median 459 fps, min 407 | median 462 fps, min 418 | | consumer max gap | 154 ms | 200 ms | | upstream reconnect errors (25 min) | 3,290 | 2,162 | | shutdown on SIGTERM | clean | clean (~20 s) | | panics / asserts | none | none | at the live firehose rate the two are within noise on every axis that matters. that is the expected result: the fork already took the relay from ~2,800 threads to ~75, and the box sits at 0.4 of 8 cores, nowhere near a regime where the I/O runtime is the bottleneck. ### C/D: 100 local consumers, 10 minutes each the fan-out path (broadcaster → 100 websocket writers) is where executor count and io_uring should show. four python processes of 25 consumers each, connected 30 s after start, no cursor. each run began with a catch-up burst (the backlog from the gap since the previous run: ~2 minutes before C, ~12 minutes before D), then settled at the live rate. steady state is the second half of the windows in which consumers were connected. | | fork zio (C) | lalinsky zio (D) | |---|---|---| | consumers connected, steady | 100 .. 100 | 100 .. 100 | | slowest consumer, steady | median 453 fps, min 440 | median 458 fps, min 420 | | fastest consumer, steady | median 456 fps | median 464 fps | | delivered, steady | 244 MB/s | 248 MB/s | | catch-up burst per consumer | ~1,170 fps for ~1 min | ~1,380 fps for ~6 min (~750 MB/s total) | | `ConsumerTooSlow` evictions | 0 | 0 | | consumer errors while the relay was up | 0 | 0 | | threads | 74 | 48 | | RSS | 1.11 .. 1.15 GiB | 1.28 .. 1.32 GiB | | cpu, steady half | 0.76 cores | 1.01 cores (includes 2 min of the burst) | | `/metrics` latency | 40 .. 71 ms | 22 .. 50 ms | both backends fan the full stream out to 100 consumers with no evictions and no gaps, and neither is near its ceiling: the lalinsky build pushed ~750 MB/s through the broadcaster during its catch-up at about one core. the runs are not matched on backlog, so the cpu and RSS columns are not a like-for-like cost comparison; what they do show is that the lalinsky build has no fan-out regression and a clearly lower `/metrics` latency while 100 writers are busy, which is the accept-path starvation the fork was patched for in August. ### observations that are not backend differences - **warm-start chain-break flood.** run A started on an empty database and logged 477 `chain break` lines. every later run started on the state the previous run left, with a ~2 minute gap between them, and logged 141k (B, lalinsky) and 152k (C, fork) chain-break lines in 25 and 10 minutes, about 10% of commits received. both backends do it, so it is relay behaviour: after a gap, the first commit from each account that moved during the gap is reported as a chain break rather than filled by resync (resync processed ~430, failed ~200 per run). worth its own look; it is not a blocker for this change. - `relay_ingest_rate_fps` reads 0 for the first ~15 minutes of every run on both backends and then settles at ~450; the consumer sees frames from the first seconds. the metric's window, not ingest, is what starts late. - io_uring was the backend actually used on the box: lalinsky's `.auto` resolved to one ring per executor (4 `anon_inode:[io_uring]` fds, 0 eventpoll). prod's node is kernel 6.8 with containerd 2.2.3 and the pod has no seccomp profile, so it will pick io_uring there too; the fallback to epoll is automatic if it cannot. ## what the change touches in operations - `/metrics`: the `zio_sched_switches_total`, `zio_sched_*`, `zio_poller_*` and `zio_dns_*` series are gone. the new block is `zio_sched_executors`, `zio_sched_parks_total{kind}`, `zio_sched_park_elections_total`, `zio_sched_steals_total{result}`, `zio_sched_drain_batches_total`, `zio_sched_drain_woken_total`, `zio_sched_batch_wake_claims_total`. `deploy/zlay-dashboard.json` and `deploy/zlay-prometheusrules.yaml` in the relay repo reference none of the old series (checked by grep), and neither does `scripts/zlay-forensics.sh`. two docs do: `docs/operations/deployment.md` "zio triage and forensics" (lines 40-42) tells the operator to read `zio_sched_switches_total`, `zio_poller_registrations` and `zio_poller_arm_failures_total`, and `docs/architecture/design.md:352` lists the old families. rewrite that triage order around the new counters before the deploy, not after. - `RELAY_IO_EXECUTORS` is new. the deployment sets no value, so prod gets 4 executors on an 8 vCPU node whose pod requests 1 cpu. 4 is what the evidence above was gathered with; `0` (one per usable cpu, cgroup aware) is the other sane setting. do not change it in the same deploy as the backend swap. - the zio pin is `lalinsky/zio@3bbd74d` (2026-10-07). upstream main has moved since (`c9cc793` on 2026-10-27, tags to v0.19.1, still zig 0.16 for the tags). either ship the pinned sha and repin later as its own change, or repin first and rerun the two fleet-scale runs. do not do both in one step. - the fork's 25 fork-only commits (sub-ms sleep parking, poller starvation, arm failures, 0.17 port) are not carried over and do not need to be: they fix the fork's single-loop scheduler. the 25-minute fleet run shows no accept starvation or `/metrics` stall, which was the fork's failure signature in August. ## how to ship it 1. bind the spindle, push the rebased branch, let CI run the zio build. 2. decide the pin question above. 3. deploy from the relay repo with the branch's commit sha (the branch name contains a `/`, and `publish-remote` checks out whatever ref it is given, so give it the sha): ```bash just zlay publish-remote ReleaseSafe zio ``` that builds on the node, imports the image into containerd pinned, and sets it on the prod deployment. there is no build-only recipe, and `deploy/zlay-canary.yaml` is the mimalloc canary from June (own postgres and PVCs, no ingress), so a true canary means either splitting `publish-remote` before its `kubectl set image` step or re-pointing that manifest at the new image. given the evidence here and that prod is one pod either way, the existing pattern (deploy, forensics before rollback) is reasonable; do it off-peak. 4. rollback is one `kubectl set image` back to the current prod image `atcr.io/zzstoatzz.io/zlay:ReleaseSafe-zio-28f893b`, which stays pinned in containerd. data formats are unchanged. if it misbehaves, run `scripts/zlay-forensics.sh` in-pod and dump `/metrics` first, as `docs/operations/deployment.md` says; rolling back deletes the evidence. 5. verify after rollout: `relay_seq` advancing, `zio_sched_executors 4`, `relay_connected_inbound` back at fleet size within a couple of minutes, RSS inside the 1.1 .. 1.5 GiB band, consumers on `zlay.waow.tech` reconnected, lightrail's cursor contiguous, relay-eval coverage for `zlay.waow.tech` unchanged over the next hour. 6. afterwards: update `docs/operations/deployment.md` (build flags, triage order), `docs/architecture/design.md` (the zio paragraph), `AGENTS.md` and the relay repo's `docs/ops-changelog.md`; then decide whether the fork repo stays as the rollback target or is archived. ## box cleanup the fly app `zlay-ab` (machine, 40 GB volume) is destroyed once this handoff is delivered; the run data (`proc.log`, `consumer.log`, `fanout-*.log`, `metrics-*.txt`, `zlay.log` per run) was pulled down first. the sources for the box (Dockerfile, entrypoint, sampler, consumers) lived in the session scratchpad and are small enough to recreate from this description. ## shipped (2026-10-30) landed on main as `9d322d5`, `20a672b`, `36b0051` (the branch's three commits replayed onto `e0b0dc4`) plus `0afa14e` (docs: triage order around the new counters). the branch is retired. zlay's CI runs on `did:web:spindle.zzstoatzz.io`, named by the repo's `org.tangled.repo.manifest` on knot1 (the old `sh.tangled.repo` record no longer selects anything). the first CI run zlay has ever had passed on `0afa14e`, dispatched by hand; pushes trigger it from `c3ba993`'s successor on. deployed `atcr.io/zzstoatzz.io/zlay:ReleaseSafe-zio-0afa14e`, pin and executor count unchanged (`3bbd74d`, 4). first minutes in prod: 47 threads, 4 io_uring rings and no eventpoll, `zio_sched_executors 4`, 3,103 inbound (the same as before the rollout), consumers back, lightrail resumed at `cursor + 1`. prod's fleet is 3.1k hosts, larger than the box's 1,941, so its RSS band is its own: the fork image sat at 2.36 GiB after 8 days up. rollback target `ReleaseSafe-zio-28f893b` stays pinned.