Repository navigation
Conversation
sipsma
force-pushed
the
sipsma/inmem-metadata-store
branch
from
October 30, 2026 19:02
ebb1711 to
59d1246
Compare
containerd's metadata database and the overlay snapshotter's store both run on go.etcd.io/bbolt. The engine runs them without fsync, so bolt's cost is its page work: rereading and rewriting B+tree pages, copying them for every write transaction, and holding a single write lock while it does. This package is a store with the subset of bbolt's API that containerd and the engine use, built for speed instead of durability. Each bucket is a persistent treap. A write transaction copies only the path to what it changes and publishes the new root with one atomic store, so readers take no lock and see the state as of their start, as in bbolt. Read transactions share one handle per bucket version; a key and its value are one allocation. Nothing is durable while it runs. Close writes the whole store to its file (a temporary file renamed over it, with a checksum), and Open reads it back and marks the file in use, so a file whose process never closed it, or a damaged one, is refused at the next Open. Signed-off-by: Erik Sipsma <[email protected]>
containerd's metadata database, the overlay snapshotter's store and the engine's own bolt code reach bolt only through go.etcd.io/bbolt, so one replace moves them all onto the in-memory store. No containerd fork is needed. On a cold first build of dagger's CLI the engine spends about half as long in containerd's snapshot and lease calls, uses about 3 CPU-s less, allocates about 0.7 GiB and 6 M objects less, and the build finishes 0.2-0.4 s sooner. Edits and unchanged rebuilds don't change. The store is saved when the engine stops gracefully and loaded when it starts. After a crash or kill its file is still marked in use, so it is refused, and the engine resets its local cache, as it does today when a bolt database fails to open. The overlay snapshotter opens its store on first use, so the engine now opens it at start (making its directory first), to send a refused file through that same reset. The store's own tests run in CI with the other nested modules, and it is linted like them. Signed-off-by: Erik Sipsma <[email protected]>
sipsma
force-pushed
the
sipsma/inmem-metadata-store
branch
from
October 30, 2026 20:53
59d1246 to
a3d3e5c
Compare
Contributor
Author
|
Its commits moved into #15007, which now combines the engine's pending performance changes, to save CI runs. |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
containerd's metadata database and the overlay snapshotter's store run on bbolt. The engine already runs both without fsync, so what bolt costs is its page work: decoding and rewriting B+tree pages, copying them for each write transaction, and holding one write lock while it does. Every snapshot prepare, view and commit, and every lease change, pays it.
This replaces bbolt, for containerd and for the engine's own bolt code, with
internal/fastbolt: a store with the part of bbolt's API they use, built for speed instead of durability. Onego.modreplace swaps it in; containerd isn't forked.What it does for users
Measured on a cold first build of dagger's CLI with the dagger/go module, on c8gd.4xlarge machines, each round running the engine with and without the store on one machine, 12 rounds:
How it works
Bucket.Tx()returns nil on a bucket opened in a read transaction. Nothing in containerd or the engine calls it.How it persists and recovers
Closewrites the whole store to its file, as a temporary file renamed over it, with a checksum. The engine already closes both databases at the end of its graceful stop.Openloads the file and marks it in use untilClose. A missing or empty file starts an empty store, as bbolt does.Openrefuses it, and the engine resets its local cache: the same path it takes today when a bolt database fails to open. A damaged file is refused the same way.Testing
internal/fastbolt's tests, now in CI with the other nested modules (and linted like them): persistence round trips, refusal of unclean and damaged files, several handles to one bucket across writes, shared read handles. They also pass under the race detector.core/metadata(also under the race detector) andcore/snapshots/storagetest suites, run on the store.