{{ message }}
Add forward References to the GC collection context - #13634
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Extends the core/metadata garbage-collection traversal logic to support lazy, forward reference emission from externally-registered collectible resource types, complementing the existing eager/back-reference mechanism.
Changes:
- Introduces an optional
collectionWithReferencesinterface forCollectionContextto emit forward references on demand. - Caches per-resource-type
collectionWithReferencesimplementations ingcContext.refContextsduringstartGCContext. - Updates
gcContext.referencesto invokeReferences(...)for matching external resource types after handling built-in core types.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Extend the garbage-collection framework so a collectible resource can emit forward references during graph traversal, in addition to the existing back-reference mechanism. A CollectionContext may now implement the optional collectionWithReferences interface: References(ctx context.Context, node gc.Node, fn func(gc.Node)) When the GC visits a node whose resource type was registered by an external collector, gcContext.references consults the per-type References implementation after the built-in core resource types are handled. This is the forward-reference analogue of collectionWithBackRefs. Whereas ActiveWithBackRefs must enumerate every edge up front and the gcContext holds all of them in its backRefs map for the entire collection, References is invoked on demand for a single node. A collector whose resources fan out to many other nodes can therefore emit those edges without retaining them in memory for the gc context. This commit is intentionally a no-op: no plugin registers a collector that uses collectionWithReferences yet. It is isolated here so that concurrent development efforts that depend on this interface can be proposed and reviewed upstream independently. Signed-off-by: Derek McGowan <derek@mcg.dev>
dmcgowan
force-pushed
the
gc-forward-references
branch
from
June 19, 2026 19:49
ee2a4ca to
4be39f1
Compare
fuweid
approved these changes
Jun 22, 2026
Kern--
approved these changes
Jun 22, 2026
mxpv
approved these changes
Jun 22, 2026
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.

Extend the garbage-collection framework so a collectible resource can emit forward references during graph traversal, in addition to the existing back-reference mechanism.
A CollectionContext may now implement the optional collectionWithReferences interface:
When the GC visits a node whose resource type was registered by an external collector, gcContext.references consults the per-type References implementation after the built-in core resource types are handled.
This is the forward-reference analogue of collectionWithBackRefs. Whereas ActiveWithBackRefs must enumerate every edge up front and the gcContext holds all of them in its backRefs map for the entire collection, References is invoked on demand for a single node. A collector whose resources fan out to many other nodes can therefore emit those edges without retaining them in memory for the gc context.
This commit is intentionally a no-op: no plugin registers a collector that uses collectionWithReferences yet. It is isolated here so that concurrent development efforts that depend on this interface can be proposed and reviewed upstream independently. This is useful for implementing chunked storage as a plugin, which will directly reference blobs in the content store. This is also useful for any plugin that might hold a reference to a core containerd type.