Skip to content

storage: avoid per-blob manifest lookups during garbage collection - #5100

Merged
milosgajdos merged 6 commits into
distribution:mainfrom
perfloop-oss:perfloop-pr-open-9e0fwxybvb
Nov 25, 2026
Merged

milosgajdos merged 6 commits into
distribution:mainfrom
perfloop-oss:perfloop-pr-open-9e0fwxybvb

Conversation

@perfloop-agent

Copy link
Copy Markdown
Contributor

#4285 added recursive GC marking with per-reference manifest probes, so registry operators running GC also pay storage lookups for layers and configuration blobs. On the committed OCI manifest example plus an empty image at default settings, median GC elapsed time changed from 2741621 to 2571477 ns/op across 70 pairs. MarkAndSweep now snapshots each repository's revisions before traversal and uses in-memory membership for canonical references after a complete inventory.

cc @milosgajdos

The local filesystem image benchmark measured median elapsed time of 121298794 ns/op before and 110555453 ns/op after across 138 pairs. On the BenchmarkGarbageCollect fixture, whole-GC GetContent calls fell from 663 to 462; Stat and Walk were unchanged. A repository with a dangling revision link keeps the reduction.

This change edits the same lines in markManifestReferences as #5083, and whichever merges second will be rebased.

Small-repository workloads added two to five allocations per collection for ordered snapshot bookkeeping. Tested smaller construction alternatives allocated more.

GC still requires stopped or read-only storage. Snapshot memory grows with manifest count. Remote-backend and production effects remain unmeasured.

registry/storage/garbagecollect_test.go includes the native filesystem benchmark. A further reproduction recipe is go test -count=1 -run='^$' -bench='^BenchmarkGarbageCollect$' -benchmem -benchtime=20x ./registry/storage.

This change was developed with AI assistance.

Measurement details and validation

For the OCI example, the paired median elapsed-time change was −169046 ns/op, with sequential median bounds of −267984 to −26288 ns/op from 70 complete pairs. Its referenced blobs are missing; it is not a production workload sample.

For the filesystem image benchmark, the paired median change was −10571783 ns/op, with sequential median bounds of −13321921 to −9183317 ns/op from 138 complete pairs.

Aliases and interrupted enumeration retain existence lookups. Lookup error handling stays unchanged from main.

Go storage tests passed.

Case and evidence


Made by Perfloop. Human sponsor: Tomás Senart.

Cover redundant manifest probes, alias lookup failures, interrupted enumeration and malformed references followed by a valid layer. Add a filesystem GC benchmark using default progress output and deterministic image metadata.

Signed-off-by: Perfloop Agent <[email protected]>
Collect repository revisions before following references and build membership after enumeration. Preserve ordered recursive traversal and use checked storage lookups for aliases or incomplete walks. Classify canonical digests without panicking on malformed stored references, retaining the existing handling of invalid operands.

Signed-off-by: Perfloop Agent <[email protected]>
Leave the manifest-existence error policy unchanged while reusing the revision snapshot. Add coverage for alias-only child references and for stopping before sweep when the first of two manifest reads fails.

Signed-off-by: Perfloop Agent <[email protected]>
Build the canonical manifest inventory after successful enumeration. Preserve alias and interrupted-enumeration lookups without coupling generic walks or linked blob enumeration to GC-only status tracking. GC continues to require stopped or read-only storage.

Signed-off-by: Perfloop Agent <[email protected]>
@milosgajdos
milosgajdos merged commit ad5dd81 into distribution:main Nov 25, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants