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
This commit is contained in:
shoney.arickathil 2026-08-10 14:10:21 +02:00
parent aa442a8d18
commit 6b8b41ce06
14 changed files with 14 additions and 14 deletions

View file

@ -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.
//!

View file

@ -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.

View file

@ -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

View file

@ -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

View file

@ -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<Mutex<Engine>>` — see `crates/rt/src/server.rs`).

View file

@ -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.

View file

@ -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;

View file

@ -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`.

View file

@ -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 —

View file

@ -10,7 +10,7 @@
//! Per plan 09a, **engine state stays globally shared** (`Arc<Mutex<Engine>>`
//! 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

View file

@ -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};

View file

@ -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;

View file

@ -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;

View file

@ -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-<t>.rwal` per worker. Frame format (identical shape to the C
//! prototype): `u32 len | u32 crc32(payload) | payload | u32 COMMIT` — a