Expand description
Cache garbage collection: runs write GC roots, roots keep cache entries alive, and collection deletes every entry no root reaches. See the book’s “Cache garbage collection” chapter.
On disk, next to the cache’s entries:
roots/<id>.json: one root per run, with the keys of the entries each of its jobs used or stored.roots/<id>.pin: present if the root is pinned; holds the pin’s name, if it has one. A separate file, so pinning never races with the run that is still adding keys to the root.lock: runs hold it shared, a sweep holds it exclusive.
Structs§
- Dropped
- Kept
- A root old enough for the age rules to drop, kept by
keep_latest. - Listed
- A root with what
doris gc rootsshows for it. - Live
Root - The root of a run in progress. It is on disk from the start, and each entry the run uses or stores is added as it happens, so a run that crashes still protects what it got through.
- Lock
- The cache’s lock. A run holds it shared for as long as it is adding to its root; a sweep holds it exclusive, so it never deletes an entry a running run has just hit or stored.
- Options
- Report
- What a collection removed, or would remove.
- Root
- What one run keeps alive.
- RootJob
- Settings
- The
gc.*settings. - Stored 🔒
- A cache entry as marking sees it.
Enums§
- Auto
- When a run collects after itself.
- Keep
Latest - Which root is kept whatever its age.
- Status
- Why a root is kept, or why the age rules drop it.
Constants§
Functions§
- age
- How long ago
timewas, to one unit:40s,5m,3h,12d. - classify 🔒
- What the settings make of each root.
rootsis oldest first. - classify_
why 🔒 - As
classify, with what each rootkeep_latestprotects is the newest of: the job IDs underjob-branch, or nothing (its whole branch) underbranch. Empty for other roots. - collect
- Drop roots as the settings say, then delete every entry no remaining root
reaches.
Noneif runs are using the cache andwaitis off. - find
- The root
specnames: by ID, by pin name, by a prefix of the ID that only one root has, orlatestfor the newest. - git 🔒
- list
- Every root, oldest first.
- load_
roots 🔒 - Every root, oldest first, and the root files that can’t be read.
- now 🔒
- parse_
size - A size such as
200G,1.5Mor4096, in powers of 1024. - pin
- Protect a root from collection, optionally under a name.
- pin_
file 🔒 - reach 🔒
- The entries a root keeps alive: those its jobs used, and the entries those were built from.
- root_
file 🔒 - roots
- Every root, as written, without measuring what each keeps.
- roots_
dir 🔒 - scan_
entries 🔒 - size
- A size for people:
512B,3.2G. - stamp 🔒
- A time as
YYYYMMDD-HHMMSSin UTC, so root IDs sort by age. - stored_
outputs - Where the cache keeps the outputs of
job’s stepstepin the run that wroteroot, by output name. Empty if the step was not cached. The paths last as long as the root does. - unpin
- Remove a root’s pin.
Noneif it wasn’t pinned. - write_
root 🔒 - Write a root so that a reader sees the old file or the new one, never half of either.