Skip to main content

Module gc

Module gc 

Source
Expand description

Mark-sweep garbage collection for blobs (ADR 0012, gonzalo#292).

A blob is live iff some stored record still points at it: as a record’s own Body::Blob, as the blob a tombstone pins, as a slice a graph manifest names, or as a shard a vector manifest names. GC marks that union and sweeps every stored blob outside it. Liveness is derived from the records themselves rather than a maintained refcount, so it is self-correcting: a missed event can leave a blob briefly un-swept, never wrongly deleted, and never leaked forever the way a drifted refcount would.

Structs§

GcReport
What a GC sweep did.
SweepPolicy
When a sweep runs and how old a blob must be to qualify.

Constants§

DEFAULT_MIN_AGE
How long a blob must have gone untouched before a sweep may delete it.

Functions§

gc_blobs
Mark-sweep every blob in store: delete the ones no record references.
gc_blobs_with
As gc_blobs, with an explicit policy.
live_blob_hashes
The mark set: every blob hash these records still need. records must be the store’s raw records, tombstones included.
sweep_blobs
Delete every blob in blobs outside the live mark set and at least DEFAULT_MIN_AGE old, and report what was freed, retained, and deferred.
sweep_blobs_with
As sweep_blobs, with an explicit policy.