Skip to content

Pigeonhole 0.3.0: Phase 3 latency engine

Choose a tag to compare

@CodingAnarchy CodingAnarchy released this 20 Oct 15:44
· 1020 commits to main since this release
204a9e4

Pigeonhole 0.3.0 completes the Phase 3 latency engine of an embedded, single-file, wide-column store in Rust (BigTable's data model with SQLite's deployment model). It adds io_uring and direct I/O, an async form of every data operation, commits visible once applied with group syncs shared between them, one-I/O cold gets, pinned thread-per-core shards packed by load, and cross-shard commits that stay ordered and cheap under contention. The Phase 3 gate ran on the reference machine, a Hetzner AX102, on 2026-10-20, and the owner judged it passed. The contended gaps it found carry over to Phase 4 and are listed under Known limits.

Experimental 0.x. The on-disk format and the API may change before 1.0 (FORMAT.md). Pigeonhole is not recommended for production use yet. See docs/status.md for the roadmap.

Upgrading from 0.2.x:

  • Stop reader processes before upgrading the writer. The shared-memory layout is version 2: a new writer fails to open with ShmVersionMismatch while readers from an older build are attached. The file format is unchanged, and files written by 0.2.x open as before.
  • Readers see a commit once it is applied, before its fsync (D227). A commit's own call still returns once it is durable. A reader that must not act on a commit a power loss could remove should read from durable_snapshot() and back up with backup_durable.
  • ErrorCode::OutcomeUnknown (28): a commit whose outcome isn't known in this process. Reopen and read it back. Closed now always means not committed, and after any shard's death every new commit fails with Closed until a reopen; Pigeonhole::is_failed() reports it.
  • Conflict on a cross-shard transaction now means a real read-write conflict (D249). Code that retries every Conflict still works and retries less.
  • Defaults that change behavior: threads are pinned to CPUs (pin_threads(false) to opt out), one shard per physical core, io_uring on Linux (IoBackend::Pread keeps 0.2's), a 64 MiB row cache (row_cache(0)), tablet packing (tablet_packing(false)), flush and compaction on one to four threads of their own (compaction_cores(0)), and short spins before parking: 50 µs on the client and 200 µs on engine-owned shards (Duration::ZERO turns either off). The async feature is on by default.
  • Application-owned mode: poll your futures after every Shard::run_once call, not only once it returns false (D237). Wait with Shard::wait or on Shard::io_fd, and call Shard::release() before handing a shard to another thread.
  • No breaking API change: cargo semver-checks against 0.2.2 passes for every published crate. If you read the hidden 0.2 engine_metrics(), its tuple fields are now named (ICR 0044).

The changelog has the full upgrade notes.

What's new

  • Commits visible once applied (D227), with durable snapshots and backup_durable for the old view. Concurrent durable commits share group syncs (D207, D221), and nothing slow sits on the commit path: WAL rollover, spare preparation, file growth and WAL pin passes moved off it (D200, D206, D58).
  • An async form of every data operation (#42, D196): get_async, RowRead::read_async, Scan::stream, commit_async, Transaction::commit_async and more. They run on any executor and on an application-owned shard's own event loop, with no runtime dependency.
  • io_uring and direct I/O (#402, #403). Each shard thread has its own ring, and application-owned mode starts no engine threads (D202), with Shard::wait, Shard::waker and Shard::io_fd for the driving loop.
  • Reads: a cold point get is one I/O (ICR 0039, D215); reads jump over superseded versions in memtables and SSTs (#387, D194, D199, ICR 0041); the row cache works and is on by default (D201, D216); scans read ahead 16 blocks (D222); block-cache hits scale across threads (#18).
  • Pinned thread-per-core shards (D220, D235), and tablet packing (D217): the balancer gathers a lightly loaded store onto as few shards as its commits in flight need (D257, D262) and spreads it again as load grows, with damped, closed-loop placement (D214, D224).
  • Cross-shard commits keep their timestamps in seqno order with their participants' writes (D244, D245, also in 0.2.3). A PREPARE that overlaps an undecided share is retried instead of failing with Conflict (D249), and the flush-time bookkeeping is batched and bounded (D254, #761, #764).
  • Stalls and failures: the L0 stall starts at twice the compaction trigger (D234), the write-stall timeout is each write's own (D240), and room waits freeze the largest memtables (D124). A health check (is_failed, failure) comes with a recovery guide (ICR 0040).
  • engine_metrics() is documented public API (ICR 0044), with per-durability commit latencies and cross-shard counters.

Performance

The Phase 3 gate (D197, #406) ran on a Hetzner AX102 (Ryzen 9 7950X3D, 16 cores, 32 threads, Samsung PM9A3 NVMe, XFS) on 2026-10-20 at 516b59b, in a 320-minute window (summary).

Target Goal Measured
Point get in memory p50 < 2 µs, p99 < 10 µs p50 0.80 µs, p99 5.98 µs
Memtable lookup at 2^18 entries (D230, D239) ≤ 300 ns (accepted to 354) 338 ns (accepted, D239)
Point get on cold data one I/O 1.05 device reads per get
Durable group commit (D213, D226) > 1M cells/s, p99 < 200 µs 10.07M cells/s, p99 133 µs
Ordered scan from cache > 1 GB/s per core 6.75 GB/s
Open to first read < 5 ms 2.94 ms (io_uring), 3.41 ms (pread)
Thread-per-core scaling (D231, D238) ≥ 0.8 × N 1.00, 1.16, 1.02 at N = 1, 4, 8 (0.65 at 16, reported)
Balancer placement (D223, D231) busiest ≤ 1.25/N busiest 29.3%, 15.1%, 7.5% at N = 4, 8, 16
Every workload against RocksDB within 1.5× every workload, in both runs
Contended cross-shard commits (D246) within 1.5× of RocksDB, p99 ≤ 1.5× RocksDB's, and more all and contended GroupSync: met; contended buffered: RocksDB 1.34× throughput, p99 2.95× (accepted, #767)
Contended, 16 threads, default options (D247) within 1.5× of RocksDB and SQLite outside at both durabilities: ycsb-e, cross-shard-contention, counters, and ycsb-f's p99 against SQLite at GroupSync (accepted)
Phase 2 floors (D193, D208); #387 no regression; #387 p99 within 1.5× of SQLite EAV floors hold in both runs; #387 row read 1.28–1.34×, scan 1.12–1.22×
Run-to-run reproducibility (D243, D259) p50 ±20% or ±3 µs, p99 ±40% or ±6 µs group-commit at 16 clients outside (run 1 a fast outlier, accepted, #768)
  • #387 is closed: the wide, overwritten-row read tail that was 0.2.0's one documented gap is within 1.5× of SQLite EAV.
  • Under contention (16 clients on the default options), Pigeonhole is ahead of RocksDB in throughput on ycsb-a, ycsb-b, ycsb-c and time-series-ttl at both durabilities, and level with it on sparse-wide. The rows it trails are under Known limits.

How it was tested

  • Simulation. Deterministic simulation (SimVfs) with fault injection, process crashes and power loss, checked against a reference model with a record-level recovery oracle. Phase 3's model runs cover apply-time visibility, durable snapshots, deferred I/O completions, shard death, and cross-shard commits under tablet changes.
  • Seed sweeps. Every engine change ran four seed sweeps on CI runners before it merged, and a red sweep blocked the merge.
  • Real I/O. Linux CI runs the model check and the real-file engine, WAL and pager tests on io_uring, on pread, and with direct I/O, beside the macOS and Windows test jobs.
  • Other checks: Miri on the unsafe crates (io, memtable), loom models for the memtable, cache, runtime, I/O and engine (the close gate and the cross-shard timestamp protocol), and cargo semver-checks on every published crate.
  • Performance regression checks. CI's instruction counts (Linux callgrind) gate every read-path change against D193's per-change thresholds and absolute ceilings, so Phase 2's results hold.
  • The gate. Every Phase 3 target was measured by one resumable runbook on the reference machine (run-window.sh), against RocksDB and SQLite, with two runs of the full workload set compared for reproducibility and the file system trimmed before each step (D258).

Known limits (tracked)

Each is a Phase 4 issue under #695. Under contention, 16 clients on the default options:

  • Short scans (ycsb-e) trail RocksDB by 3.9× in throughput at buffered and 3.3× at the default durability. #712.
  • Counter reads have a p99 of 10.8 ms at buffered and 17.2 ms at the default durability. #713.
  • Transactions on hot rows (transfer): 4.7–14K ops/s at buffered across gate runs, 38–106× behind RocksDB. #708.
  • Cross-shard commits at the default durability: the mix's p99 is 2.29× SQLite's single-writer transactions. #707.
  • Cross-shard commits after packing regrows a store run at about 0.7× the packing-off throughput, with a p99.9 near 1 ms. Reopening the store, or tablet_packing(false) for such loads, avoids it. #767.
  • Read-modify-write at GroupSync: ycsb-f's p99 is 2.04× SQLite's, since each commit pays its own fsync at under one commit per shard. #755.
  • Reads beside writes: row-read and scan p99 run 1.8–2.2× SQLite's while other clients write. #759.
  • sparse-wide puts at buffered: p99 about 30× RocksDB's (498 against 17 µs). #760.
  • The async API at 16 in flight per client: 0.41× the synchronous throughput at buffered. #749, #709.
  • Application-owned mode on the defaults: 0.20× the pre-split scaling run. #710.
  • time-series-range trails RocksDB slightly (1.07×) where time-series-ttl leads it. #711.
  • Placement: the write-skew mover can stop with tablets still to move (#735); a commit on a just-parked shard pays its wakeup (#738); a store packed by one loader regrows slowly when many clients arrive (#744).
  • Reproducibility: group-commit at 16 clients varied past D243's tolerance between the gate's two runs. #768.
  • pigeonhole-cli (phdb) is a placeholder until Phase 4.

Crates

pigeonhole (start here), plus pigeonhole-engine, -format, -io, -pager, -wal, -memtable, -cache, -runtime, -shm, -sst, -compaction, -sim, -arrow and pigeonhole-cli, all at 0.3.0. Includes the fixes released in 0.2.1, 0.2.2 and 0.2.3.

Docs