genuinebasil.dev
Cairn Marginal Blog | Systems Depth CVContact
Rust/database internals/distributed systems

Built from the
primitives up.

Three systems on three subdomains. The B+Tree and its latch crabbing, the CRDT and its operation log, the join-order search and its cost model — each one written rather than imported. The frameworks are around the edges.

Read the blog See the systems GitHub
SERVICE TOPOLOGY3 SYSTEMS · 13 CONTAINERS
gb genuinebasil.dev marginal6 services · live cairn7 layers · query engine blogshipped · db-backed cms
NOW BUILDING
Cairn
the query engine, layer 2 of 7
LAST SHIPPED
Marginal
eleven of twenty-two phases, in production
READING
DDIA
Kleppmann, second time through
OPEN TO
Rust work
storage · execution · coordination
THE SYSTEMS design → scaffold → core → ship
BlogLIVE
blog.genuinebasil.dev
A CMS I write in daily, in Rust, with its own markdown rendering parser.
SHIPPED · PHASE 16 OF 16
axum + sqlxnext 16 app routertiptap adminpwa · feeds · analytics
CairnBUILDING
cairn.genuinebasil.dev
A multimodal distributed query engine, with visualisations of what is happening under the hood.
LAYER 2 / 7
lexer + parserjoin-order dpb+tree · buffer pool · walraft · 2pc
MarginalLIVE
marginal.genuinebasil.dev
A collaborative microservice WYSIWYG document editor, drawing on Peritext and Notion. Rust, deployed on GCP.
PHASE 11 OF 22
architecture + 9 ADRscrdt · rope · walwasm editor core
B+Tree/LRU-K/ARIES WAL/Raft/CRDT/Rope/2PC/MVCC/Join-order DP/HNSW/SimHash + LSH/Consistent hashing/Latch crabbing/PageRank/Myers diff/Tantivy/SWIM/
B+Tree/LRU-K/ARIES WAL/Raft/CRDT/Rope/2PC/MVCC/Join-order DP/HNSW/SimHash + LSH/Consistent hashing/Latch crabbing/PageRank/Myers diff/Tantivy/SWIM/
ENGINEERING DEPTH implemented, not imported

The three systems were chosen so their hard parts do not overlap. Between them they cover the trees, the graphs and the dynamic programming that most backend work never reaches for — and in every case the algorithm is written, not pulled from a crate.

CRDTMARGINAL
ins del converged

Concurrent edits from several people merge to one document with nothing to resolve by hand. Written from scratch — importing it would leave nothing learned.

Lexer → parserCAIRN

A hand-written lexer and recursive-descent parser taking SQL text to an AST. No parser generator anywhere in the pipeline.

Join-order DPCAIRN
best[S]O(3ⁿ)

best[S] filled bottom-up over relation subsets with a real cost model, then a genetic fallback once the table stops fitting.

B+Tree & latch crabbingCAIRN

A reader drops the parent latch the moment the child is latched, so descents overlap instead of serialising — the hardest part of a B+Tree to get right.

Buffer poolCAIRN
LRU-K ARC evicthit

LRU-K, ARC and Clock run against the same access trace, side by side — so the difference between them is visible rather than asserted.

ARIES recoveryCAIRN
analysis redo undo crash

Write-ahead logging with the three ARIES passes, and a crash you can inject anywhere on the timeline to watch them run.

RaftCAIRN
L F F F term 4

Leader election, log replication and leases, hand-rolled. Holds cluster metadata only — deliberately kept off the query hot path.

RopeMARGINAL
12

A balanced tree over text, so splicing into the middle of a long document is O(log n) instead of a full copy.

HNSWBOTH
L2L1L0

A navigable small-world graph in layers, traversed by greedy beam search — semantic search in marginal, a vector worker in cairn.

Currently looking for Rust work.

Backend and systems roles — storage engines, query execution, distributed coordination. The kind of problem where the algorithm is the product, not the glue around it.

[email protected]GitHubLinkedInCV
trace complete · 3 systems
© 2026 genuinebasil.dev