feat(oci): store OCI layers as content-addressed artifacts (layers survive)#71
Merged
Conversation
…rvive)
Flattening all OCI layers into one merged ext4 destroys cross-image dedup: a
shared base layer lands at different block offsets in each image, so it shares
0 blocks (proven empirically — see the oci_dedup_measure bin: 207 MiB merged
vs 133 MiB layers-survive / 35.7% smaller on debian/python/node). A single
linear ext4 and cross-image layer dedup are fundamentally incompatible, so this
stops merging and stores each layer once.
- ext4: convert_layer_to_ext4 — convert one OCI layer to a deterministic ext4
that is a valid overlayfs lower layer (.wh.<f> -> char-dev 0,0,
.wh..wh..opq -> trusted.overlay.opaque xattr) instead of flattening.
- oci::ext4_store: extract the block->pack->manifest streaming core out of the
feature-gated cli::bless into the always-on lib so bless and the layer store
share it (store_ext4_stream, deterministic_uuid).
- oci::layer_store: store each layer once under a global content-addressed
namespace layers/{digest} (idempotent via HEAD); record an image as an
ordered digest list at images/{name}.
- cli::bless: run_bless_oci_layered + `bless --oci --layered`.
- cli::gc: reconcile_layers — ref-count the shared layer pool by images/*
descriptors; reap orphans after the grace period (which also covers the
bless write-race). Layers live outside exports/, untouched by per-prefix GC.
Verification: end-to-end docker_integration test (oci_layer_dedup) pushes three
images sharing a base layer to registry:2 and asserts the base is stored once,
layered storage < merged storage, overlay composition equals the merged
filesystem (incl. whiteout + opaque dir), and the GC reference invariant holds.
Passes against a real registry. Plus ext4 + bless + layer_store + gc unit tests.
Phase 2 (not included): runtime so a VM boots from layered storage via overlayfs
over lazy per-layer devices; per-layer hot-sets.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
Flattening all OCI layers into one merged ext4 destroys cross-image dedup: a shared base layer lands at different block offsets in each image, so it shares 0 blocks. Proven empirically with the new
oci_dedup_measurebin on realdebian/python/nodeimages (all share the debian base layer):A single linear ext4 and cross-image layer dedup are fundamentally incompatible (deltas don't help; layer-stable layout fights ext4's global metadata). So this stops merging and stores each layer once. Direction matches the platform's
beyond/primitives/oci, which composes images with overlayfs over content-addressed layers.What changed
ext4::convert_layer_to_ext4— convert one OCI layer to a deterministic ext4 that is a valid overlayfs lower layer:.wh.<f>→ char-device0,0,.wh..wh..opq→trusted.overlay.opaquexattr (instead of flattening).oci::ext4_store— extracted the block→pack→manifest streaming core out of the feature-gatedcli::blessinto the always-on lib so bless and the layer store share it (store_ext4_stream,deterministic_uuid).cli::blessnow delegates to it.oci::layer_store— store each layer once under a global content-addressed namespacelayers/{digest}(idempotent via HEAD); record an image as an ordered digest list atimages/{name}.cli::bless—run_bless_oci_layered+bless --oci --layered.cli::gc—reconcile_layers: ref-count the shared layer pool byimages/*descriptors; reap orphans after the grace period (which also covers the layered-bless write race). Layers live outsideexports/, so the existing per-prefix GC never touches them.Verification
End-to-end
docker_integrationtest (oci_layer_dedup) pushes three images sharing a base layer to a realregistry:2and asserts:ext4::Reader,Passes against a real registry. Plus ext4 (52) + bless (8) + layer_store (3) + gc (29) unit tests, all green.
Scope / follow-up
Storage dedup + GC + proofs are in. Phase 2 (not in this PR): the runtime so a VM boots from layered storage via overlayfs over lazy per-layer devices; per-layer hot-sets.
🤖 Generated with Claude Code