Postgres over the ring

ioxide.pg is a hand-rolled Postgres driver where everything - TCP connect, startup handshake, every query - is an io_uring op on the host reactor's ring, resumed inline. No Npgsql, no socket engine, no thread pool.

The pool

var options = new PgOptions
{
    Host = "127.0.0.1",      // IPv4 literal - resolve DNS up front
    User = "bench",
    Database = "bench",
    PoolSize = 8,            // connections per reactor
};

// At startup, on the reactor thread.
reactor.OnStart = r => PgPool.Start(r, options);

// In the handler: rent → query → return, in one call.
var pool   = reactor.GetService<PgPool>();
var result = await pool.QueryAsync("SELECT 42");

// result.Value: "42" · result.Rows: 1 · result.CommandTag: "SELECT 1"

One PgConnection is one conversation - one query in flight. The pool is the concurrency: QueryAsync rents a connection, runs the query, returns it; when all are busy, requests queue and resume inline as connections free up. For multi-statement work (transactions), RentAsync/Return directly.

Warmup is concurrent and non-blocking: Start fires PoolSize ring-native connects; a request that arrives first simply waits in the rent queue until the first connection lands. Total server-side connections = PoolSize × ReactorCount.

Failure semantics

FailureBehavior
Server error (bad SQL, missing table)PgException with severity + SQLSTATE, thrown after the stream resyncs at ReadyForQuery - the connection stays usable
Transport failure (reset, EOF, malformed framing)connection marked IsBroken; the pool discards it on return and opens a replacement in the background
Database restartbroken connections get replaced as they're returned - the server heals without a restart
try
{
    var result = await pool.QueryAsync(sql);
}
catch (PgException e) when (e.SqlState == "42P01")
{
    // Relation does not exist - the connection is already back in rotation.
}

Wire details

Parallel requests overlap their queries across the pool instead of serializing on one connection - see it directly with the Playground's /sleep route and a few concurrent curls.