Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

FormaKV, the persistence engine

A promise made to a user outlives the session. The bytes that keep that promise must outlive the crash. FormaKV is the part of the platform where the second survival happens: an embedded, durable key-value engine that the platform’s storage capability stands on.

An engine in the process, not beside it

FormaKV is a library. The application links it, hands it a directory, and the engine takes ownership of that directory. There is no socket, no protocol, and no second process to deploy, monitor, or restart; the durability guarantee runs inside the application’s own lifetime.

It is not a database. It keeps keys and values, and it knows nothing about schemas, queries, or meaning. A database layer (FormaDB, in the family’s plans) will sit above it and will inherit its guarantees rather than reimplement them.

From transaction to durable bytes

A write crosses a short path. A transaction buffers changes in memory. Commit appends the transaction to the engine’s write-ahead log and issues one fsync. When the sync returns, the commit is acknowledged; the engine’s visibility boundary is the durable prefix, so a value becomes readable at exactly the point where losing it becomes impossible short of device failure.

Writers do not wait in line for the device one at a time. Everything queued at a durability barrier shares a single sync. Under eight concurrent writers the engine measures four records per sync, which is the difference between a durability mechanism and a durability tax.

The space durability reserves

The log reserves space before using it: 8 MiB per epoch, set aside when the engine opens. An empty scope therefore occupies about 8.4 MB, and that number is a floor, not a leak. A checkpoint folds the log into sealed segments and gives the reservation back: a scope holding 300 claims went from 8.4 MB to 108 KB across one checkpoint, claims intact.

Two cost numbers must not be confused. The reservation is a capacity cost, bounded per scope and returned at checkpoint. Data amplification, bytes written per byte kept, is measured at 1.30 on the steady-state path. Reports that quote much larger factors are quoting the reservation.

What a crash takes

A crash takes the tail and only the tail. On reopen the engine validates the log frame by frame, stops at the first frame it cannot trust, cuts the file there, and reports the cut. The survivor is an exact prefix: every acknowledged write, nothing else. A commit that reached the device but whose acknowledgment never reached the caller recovers as committed, because the engine treats what validated as fact.

So a crash truncates. It never corrupts the prefix, never loses an acknowledged write, and never re-initializes a directory that already holds data.

What it costs and what it delivers

On consumer NVMe with default settings, the engine measures 3,517 durable commits per second for a single writer, with the durability barrier at 253 microseconds median, and roughly nine times the throughput at eight writers. The canonical scale run wrote a 4 GiB corpus under a 2 GiB memory cap in 467 seconds with a stable 306 MiB footprint, then reopened in 7.5 seconds to the exact prefix. On a memory filesystem the coordination alone sustains an order of magnitude more, which is why the device numbers are the honest ones for planning.

These figures come from a stated protocol: release builds, three consecutive runs that must agree, and interleaved before-and-after on the same device. The engine repository keeps the full tables, the knobs, and the rejected alternatives with their measurements.

Where it sits in the platform

Applications reach the engine through the forma-kv-adapter, which realizes the platform’s persistence capability behind the storage provider boundary. The binding is a revision pin of the engine repository, and the pin is the version contract: the pinned revision passed its gate identically across three consecutive runs, and the adapter’s own suite passes against exactly those bytes. When the engine advances, nothing changes for an application until that application moves its pin and reruns its gates.