Skip to main content

Module gc

Module gc 

Source
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 roots shows for it.
LiveRoot
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.
KeepLatest
Which root is kept whatever its age.
Status
Why a root is kept, or why the age rules drop it.

Constants§

ROOT_SCHEMA 🔒

Functions§

age
How long ago time was, to one unit: 40s, 5m, 3h, 12d.
classify 🔒
What the settings make of each root. roots is oldest first.
classify_why 🔒
As classify, with what each root keep_latest protects is the newest of: the job IDs under job-branch, or nothing (its whole branch) under branch. Empty for other roots.
collect
Drop roots as the settings say, then delete every entry no remaining root reaches. None if runs are using the cache and wait is off.
find
The root spec names: by ID, by pin name, by a prefix of the ID that only one root has, or latest for 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.5M or 4096, 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-HHMMSS in UTC, so root IDs sort by age.
stored_outputs
Where the cache keeps the outputs of job’s step step in the run that wrote root, 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. None if 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.