Documentation ¶
Overview ¶
Package gc experiments with providing central gc tooling to ensure deterministic resource removal within containerd.
For now, we just have a single exported implementation that can be used under certain use cases.
Index ¶
- func ConcurrentMark(ctx context.Context, root <-chan Node, ...) (map[Node]struct{}, error)
- func Sweep(reachable map[Node]struct{}, all []Node, remove func(Node) error) error
- func Tricolor(roots []Node, refs func(ref Node) ([]Node, error)) (map[Node]struct{}, error)
- type Node
- type ResourceType
- type Stats
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConcurrentMark ¶
func ConcurrentMark(ctx context.Context, root <-chan Node, refs func(context.Context, Node, func(Node)) error) (map[Node]struct{}, error)
ConcurrentMark implements simple, concurrent GC. All the roots are scanned and the complete set of references is formed by calling the refs function for each seen object. This function returns a map of all object reachable from a root.
Correct usage requires that the caller not allow the arguments to change until the result is used to delete objects in the system.
It will allocate memory proportional to the size of the reachable set.
func Sweep ¶
Sweep removes all nodes returned through the channel which are not in the reachable set by calling the provided remove function.
func Tricolor ¶
Tricolor implements basic, single-thread tri-color GC. Given the roots, the complete set and a refs function, this function returns a map of all reachable objects.
Correct usage requires that the caller not allow the arguments to change until the result is used to delete objects in the system.
It will allocate memory proportional to the size of the reachable set.
We can probably use this to inform a design for incremental GC by injecting callbacks to the set modification algorithms.
Types ¶
type Node ¶
type Node struct { Type ResourceType Namespace string Key string }
Node presents a resource which has a type and key, this node can be used to lookup other nodes.