Documentation
¶
Overview ¶
Package gc is mlfs's refcount-free, mark-and-sweep garbage collector.
There is no chunk_refcount table (by design). Liveness is derived: the metadata engine's slice_ref rows are the system-of-record for what data is reachable, and the physical chunks beneath are content-addressed by casstore. A GC pass therefore:
- marks the live slice set = DISTINCT slice_id in slice_ref;
- deletes the casstore manifest of every stored slice NOT in that set (an orphan whose last referencing inode was unlinked), EXCEPT manifests younger than the safety window;
- runs the casstore blob sweep to reclaim the now-unreferenced chunk/pack blobs (also safety-windowed).
The safety window guards the GC↔write race: fileio writes a slice's manifest BEFORE committing its slice_ref row, so a just-written slice momentarily looks like an orphan. The window (default 24h in prod, tiny in tests) ensures an in-flight write's data is never reclaimed out from under it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GC ¶
type GC struct {
// contains filtered or unexported fields
}
GC collects orphaned slice data for an engine + local chunk store.
func New ¶
func New(engine *meta.Engine, local *chunkstore.Local) *GC
New builds a GC over the engine and a local chunk store bundle.
func (*GC) Run ¶
Run executes one GC pass. It streams the stored slice manifests, and for each batch resolves liveness against slice_ref and reclaims the orphans older than the safety window — so neither the live set nor the orphan set is ever fully materialised. The casstore blob sweep follows (itself bounded by its live set).
func (*GC) SetBatchSize ¶
SetBatchSize overrides the manifest-walk batch size (0 keeps the default). Used by tests to force the multi-batch path; production leaves it at sliceGCBatch.
func (*GC) SetClock ¶
SetClock overrides the clock (tests). Propagated to the casstore sweep so both layers agree on "now".
func (*GC) SetSafetyWindow ¶
SetSafetyWindow sets the minimum age before an orphaned slice manifest or chunk blob may be reclaimed. Propagated to the casstore blob sweep.
type Result ¶
type Result struct {
LiveSlices int // live slice manifests seen (referenced by some file)
SlicesScanned int // stored slice manifests examined
SlicesDeleted int // orphaned slice manifests reclaimed this pass
SlicesDeferredYoung int // orphans skipped for being younger than the window
Cas snapshot.GCResult // underlying casstore blob sweep result
}
Result summarizes one GC pass.