From 6b8b41ce069c13aea355f15e4cd9eb6936c5c6c0 Mon Sep 17 00:00:00 2001 From: "shoney.arickathil" Date: Mon, 10 Aug 2026 14:10:21 +0200 Subject: [PATCH] refactor(crates/rt): Stage 2 runtime improvements - http: connection, listener, request, response, route updates - pg: protocol improvements - runtime: eventfd, netpoll (epoll/io_uring), scheduler, signalfd, timerfd - shard: cross-shard job improvements - wal: replay and recovery fixes --- crates/rt/src/http/connection.rs | 2 +- crates/rt/src/http/listener.rs | 2 +- crates/rt/src/http/request.rs | 2 +- crates/rt/src/http/response.rs | 2 +- crates/rt/src/http/route.rs | 2 +- crates/rt/src/pg.rs | 2 +- crates/rt/src/runtime/eventfd.rs | 2 +- crates/rt/src/runtime/netpoll_epoll.rs | 2 +- crates/rt/src/runtime/netpoll_io_uring.rs | 2 +- crates/rt/src/runtime/scheduler.rs | 2 +- crates/rt/src/runtime/signalfd.rs | 2 +- crates/rt/src/runtime/timerfd.rs | 2 +- crates/rt/src/shard.rs | 2 +- crates/rt/src/wal.rs | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/crates/rt/src/http/connection.rs b/crates/rt/src/http/connection.rs index 246245b..f034c49 100644 --- a/crates/rt/src/http/connection.rs +++ b/crates/rt/src/http/connection.rs @@ -10,7 +10,7 @@ //! any buffered pipelined request); `Connection: close` goes to Done. //! Done → loop closes the fd. //! -//! Adapted from `reference/crates/wo-http/src/connection.rs`. The owning +//! Adapted from `.dev/reference/crates/wo-http/src/connection.rs`. The owning //! [`EventLoop`] supplies `read`/`write` readiness via edge-triggered //! `epoll`; this struct is the per-fd part of the state. //! diff --git a/crates/rt/src/http/listener.rs b/crates/rt/src/http/listener.rs index 1ce6359..29fdf49 100644 --- a/crates/rt/src/http/listener.rs +++ b/crates/rt/src/http/listener.rs @@ -1,6 +1,6 @@ //! Non-blocking TCP listener — `socket(2)` + `bind(2)` + `listen(2)` + `accept4(2)`. //! -//! Adapted from `reference/crates/wo-http/src/listener.rs`. The v1 hand-rolled +//! Adapted from `.dev/reference/crates/wo-http/src/listener.rs`. The v1 hand-rolled //! IPv4 parser had a byte-order bug for non-localhost addresses; here we //! defer to `std::net::SocketAddr` (stdlib, no extra crate) and convert the //! resulting octets to a `sockaddr_in` correctly. diff --git a/crates/rt/src/http/request.rs b/crates/rt/src/http/request.rs index 1e595f7..cee07b0 100644 --- a/crates/rt/src/http/request.rs +++ b/crates/rt/src/http/request.rs @@ -1,6 +1,6 @@ //! Incremental HTTP/1.1 request parser. //! -//! Adapted from `reference/crates/wo-http/src/request.rs`. v1 only parsed +//! Adapted from `.dev/reference/crates/wo-http/src/request.rs`. v1 only parsed //! request headers (the v1 blog is read-only HTML). The phase-04 cutover //! needs JSON request bodies, so this parser also drains a //! `Content-Length`-delimited body. Chunked transfer encoding is not diff --git a/crates/rt/src/http/response.rs b/crates/rt/src/http/response.rs index 21eed05..101771e 100644 --- a/crates/rt/src/http/response.rs +++ b/crates/rt/src/http/response.rs @@ -1,6 +1,6 @@ //! HTTP/1.1 response builder + serializer. //! -//! Adapted from `reference/crates/wo-http/src/response.rs`. Adds: +//! Adapted from `.dev/reference/crates/wo-http/src/response.rs`. Adds: //! * `Status` constants for the codes the REST samples assert on //! (200/201/204/400/404/405/500/501). //! * `Response::json(&serde_json::Value)` matching the cutover-handler diff --git a/crates/rt/src/http/route.rs b/crates/rt/src/http/route.rs index 0799630..a13a902 100644 --- a/crates/rt/src/http/route.rs +++ b/crates/rt/src/http/route.rs @@ -1,6 +1,6 @@ //! Method + URL pattern → handler dispatch. //! -//! Combined adaptation of `reference/crates/wo-route/src/{router,pattern}.rs`. +//! Combined adaptation of `.dev/reference/crates/wo-route/src/{router,pattern}.rs`. //! Handler shape is `Fn(&Request, &RouteParams) -> Response`, captured as a //! boxed closure so each route closes over its own state (typically an //! `Arc>` — see `crates/rt/src/server.rs`). diff --git a/crates/rt/src/pg.rs b/crates/rt/src/pg.rs index 4b094ea..c40cc4b 100644 --- a/crates/rt/src/pg.rs +++ b/crates/rt/src/pg.rs @@ -14,7 +14,7 @@ //! * literal/identifier escaping for SQL the mirror generates //! //! Protocol reference: PostgreSQL docs “Frontend/Backend Protocol” and -//! `reference/postgresql/src/include/libpq/` (research symlink). +//! `.dev/reference/postgresql/src/include/libpq/` (research symlink). //! //! Blocking I/O is deliberate: the only caller is the dedicated `wo-pg` //! mirror thread (plan 16b) — never a shard worker. diff --git a/crates/rt/src/runtime/eventfd.rs b/crates/rt/src/runtime/eventfd.rs index 642a0b5..e15deb4 100644 --- a/crates/rt/src/runtime/eventfd.rs +++ b/crates/rt/src/runtime/eventfd.rs @@ -4,7 +4,7 @@ //! event loop to come back and run something writes a `1` to the eventfd, //! which becomes readable on the loop's next `wait_once`. //! -//! Ported from `reference/crates/wo-event/src/eventfd.rs` with an added +//! Ported from `.dev/reference/crates/wo-event/src/eventfd.rs` with an added //! `AsRawFd` impl so callers can drop the fd straight into `EventLoop`. use std::io; diff --git a/crates/rt/src/runtime/netpoll_epoll.rs b/crates/rt/src/runtime/netpoll_epoll.rs index e251130..bdd691e 100644 --- a/crates/rt/src/runtime/netpoll_epoll.rs +++ b/crates/rt/src/runtime/netpoll_epoll.rs @@ -1,6 +1,6 @@ //! `epoll`-backed event loop. Single-threaded, edge-triggered. //! -//! Ported from `reference/crates/wo-event/src/epoll.rs`. Differences: +//! Ported from `.dev/reference/crates/wo-event/src/epoll.rs`. Differences: //! * `Token` is a newtype rather than a `u64` alias. //! * `Interest` is a struct exposing `READABLE`, `WRITABLE`, `READ_WRITE` //! constants, matching the API in `docs/plan/02-event-loop-epoll.md`. diff --git a/crates/rt/src/runtime/netpoll_io_uring.rs b/crates/rt/src/runtime/netpoll_io_uring.rs index b891017..24a1f8e 100644 --- a/crates/rt/src/runtime/netpoll_io_uring.rs +++ b/crates/rt/src/runtime/netpoll_io_uring.rs @@ -1,5 +1,5 @@ //! Raw io_uring — no liburing, kernel ABI structs defined by hand, exactly -//! the sequence proven in C (`prototypes/wo-rt-c/wo-rt.c` ring_init/enter; +//! the sequence proven in C (`runtime/wo-rt.c` ring_init/enter; //! card: `docs/plan/exploration/linux/07-io_uring.md`). //! //! Scope (this phase): the **storage ring** for per-shard group commit — diff --git a/crates/rt/src/runtime/scheduler.rs b/crates/rt/src/runtime/scheduler.rs index 89992bf..9888481 100644 --- a/crates/rt/src/runtime/scheduler.rs +++ b/crates/rt/src/runtime/scheduler.rs @@ -10,7 +10,7 @@ //! Per plan 09a, **engine state stays globally shared** (`Arc>` //! inside the per-thread `Router`s) — one thing at a time; the sharded engine //! is 09b. The C proving ground for this exact sequence is -//! `prototypes/wo-rt-c` phase A (see `docs/plan/exploration/c-runtime/`). +//! `runtime` phase A (see `docs/plan/exploration/c-runtime/`). //! //! Shutdown: signals are blocked in `main` before any worker spawns (the //! mask is inherited), so only worker 0 — which owns the `signalfd` — ever diff --git a/crates/rt/src/runtime/signalfd.rs b/crates/rt/src/runtime/signalfd.rs index a9ef929..3923fac 100644 --- a/crates/rt/src/runtime/signalfd.rs +++ b/crates/rt/src/runtime/signalfd.rs @@ -5,7 +5,7 @@ //! //! Blocks the captured signals in the calling thread's mask, so the //! kernel routes them to the signalfd instead of running default handlers. -//! Ported from `reference/crates/wo-event/src/signalfd.rs`. +//! Ported from `.dev/reference/crates/wo-event/src/signalfd.rs`. use std::io; use std::os::unix::io::{AsRawFd, RawFd}; diff --git a/crates/rt/src/runtime/timerfd.rs b/crates/rt/src/runtime/timerfd.rs index bf8f8f0..942e7a0 100644 --- a/crates/rt/src/runtime/timerfd.rs +++ b/crates/rt/src/runtime/timerfd.rs @@ -4,7 +4,7 @@ //! fd becomes readable when the timer expires; reading drains the //! expiration count. //! -//! Ported from `reference/crates/wo-event/src/timerfd.rs`. Adds `oneshot` +//! Ported from `.dev/reference/crates/wo-event/src/timerfd.rs`. Adds `oneshot` //! and `periodic` constructors that match the API in the phase-02 plan. use std::io; diff --git a/crates/rt/src/shard.rs b/crates/rt/src/shard.rs index 2edb8be..a1b988a 100644 --- a/crates/rt/src/shard.rs +++ b/crates/rt/src/shard.rs @@ -16,7 +16,7 @@ //! coordination. Creates are always local (the receiving shard mints from //! its own stride); reads/updates/deletes hop at most once; lists fan out //! to every shard and merge. The C proving ground for the wake mechanism is -//! `prototypes/wo-rt-c` (eventfd broadcast); the mailbox-per-thread design +//! `runtime` (eventfd broadcast); the mailbox-per-thread design //! is plan 09 decision 2 and 09d's one-message-per-thread fan-out shape. use std::cell::RefCell; diff --git a/crates/rt/src/wal.rs b/crates/rt/src/wal.rs index e166523..091905e 100644 --- a/crates/rt/src/wal.rs +++ b/crates/rt/src/wal.rs @@ -1,6 +1,6 @@ //! Per-shard write-ahead log — plan 09c (`docs/plan/09-concurrency-scaleout.md`) //! + the durability core of plan 11, ported from the proven C sequence -//! (`prototypes/wo-rt-c` phases D/E, `docs/plan/exploration/c-runtime/00-plan.md`). +//! (`runtime` phases D/E, `docs/plan/exploration/c-runtime/00-plan.md`). //! //! One `shard-.rwal` per worker. Frame format (identical shape to the C //! prototype): `u32 len | u32 crc32(payload) | payload | u32 COMMIT` — a