Expand description
Local artifact storage, independent of compiler parsing and remote transports.
Modules§
- atomic
- config
- eviction
- Eviction selection, decoupled from the removal mechanism (kunobi-ninja/kache#595).
- file_
hash - Persistent file fingerprints and opaque compiler memo records.
- filesystem
- Filesystem identity and physical reclamation.
- link
- markers
- Cross-process advisory and activity markers.
- opcounts
- Bytes materialized by the store and its consumers.
- sharing
- Cache reporting policy over shared filesystem measurements.
Structs§
- Artifact
Store - The local content-addressed store.
- Blob
Index Drift - Difference between the derived SQLite blob index and committed entry metadata, which is the store’s authoritative reference graph (#819).
- Blob
Refcount Drift - Disagreement between the two derived blob tables, read without touching
meta.jsonand without the write lock. - Blob
Stats - Content-dedup statistics.
- Cached
File - Crate
History Entry - One prior build of a crate on this machine, from the local store’s index
(kunobi-ninja/kache#617). Replaces a bare
(key, crate, dir)tuple so the planner can rank by rebuild cost and size. - Entry
Info - Entry
Meta - Metadata stored alongside cached artifacts.
- Eviction
Evidence Cohort - One observation per key: latest live eviction or first shadow-only sweep.
- Eviction
Horizon Evidence - GcStats
- Statistics returned by GC operations.
- Housekeeping
Stats - Counts from [
Store::sweep_housekeeping], recorded with the GC run so growth in either structure shows up without a shell on the host. - KeyLock
Sweep Stats - What one [
Store::sweep_stale_key_locks] pass saw and did. - Migration
Stats - Statistics from a blob migration run.
- Orphan
Sweep Stats - Statistics returned by
ArtifactStore::sweep_orphan_blobs. - Policy
Cost - Evictions one policy made, and the compile time later spent rebuilding the ones the build asked for again (kunobi-ninja/kache#594).
- Quarantined
Index File - One retained corrupt index file, including WAL/SHM sidecars.
- Rebuild
Stats - Outcome of
ArtifactStore::rebuild_index_from_store. - Removal
Reclaim - Registered blob bytes and blob rows an entry removal released — blobs
whose last reference went away, not the entry’s logical size
(kunobi-ninja/kache#608). Denominated in
blobsTABLE bytes, the same unit asArtifactStore::physical_size, so eviction’s running budget stays consistent with its trigger; the file unlink itself is best-effort (Windows can defer it), so this is not a guarantee about the disk. - Shadow
Counterfactual - The live policy against the value-density shadow over the same sweeps:
see [
Store::shadow_counterfactual]. - Shadow
Demand Split - Post-eviction demand, split by whether the shadow policy agreed with the live one about each evicted entry (kunobi-ninja/kache#594).
- Store
Lock - Cross-process advisory lock held through an open file handle.
- Store
PutResult - Tracked
Target Root - Verified
Restored Entry - An entry whose remote bytes and declared artifact hashes were verified in the same pass that extracted them. Construction stays inside the remote transport boundary; the store still re-checks metadata, paths and lengths, but deliberately does not read every artifact a second time.
Enums§
- Build
Claim - Result of claiming responsibility for a cache miss.
- Guarded
Removal - Outcome of removing an entry while holding its compile lock.
- Sweep
Origin - Who started a sweep. Automatic sweeps (after an upload, on a size hint,
the daemon’s timer, the detached worker) keep recent imports; a sweep the
user asked for does not, so
kache gccan always get back under budget. - Verify
Restores - How aggressively a local cache hit re-hashes its blobs against their content address before serving them, to catch silent on-disk corruption / bit rot / a memo collision before it reaches the compiler as a wrong artifact (kunobi-ninja/kache#332).
Constants§
- EVICTION_
IDLE_ GRACE - How recently an entry must have been accessed for eviction to treat it as “pinned by a live build” and skip it (kunobi-ninja/kache#326, #182).
- EVICTION_
WRITE_ PAUSE - How long an eviction sweep stands off the write lock after each
EVICTION_WRITE_SLICE, or after it lost the lock to another writer. Longer than the busy handler’s 100 ms poll interval, so every waiting writer polls at least once while the lock is free. - EVICTION_
WRITE_ SLICE - Write-lock time an eviction sweep may spend on removals before it pauses.
- HIT_
STAMP_ INTERVAL - A hit re-stamps
last_accessedonly when the previous stamp is at least this old: well insideEVICTION_IDLE_GRACE, so a restore in flight is still pinned, and rare enough that concurrent hits stop contending for the index’s write lock. - IMPORT_
PIN - How long an automatic sweep keeps an entry the remote delivered, used or
not (kunobi-ninja/kache#1008). A CI job imports a warm set, then runs
several cargo commands; an upload between them used to evict whatever the
job had not touched for
EVICTION_IDLE_GRACE, and the next command downloaded it again or missed. Six hours covers the longest GitHub-hosted job, and bounds how long a long-lived daemon keeps imports nobody used. - KEY_
LOCK_ SWEEP_ CAP - Most key lock files one sweep unlinks. Each costs an open, a lock, two
stats and an unlink under
gc.lock, tens of microseconds on Linux and a few hundred on macOS and Windows, so a full batch stays within seconds. A store with 84k stale locks converges in five sweeps. - KEY_
LOCK_ SWEEP_ GRACE - How long a key lock file must sit unused before the sweep may unlink it.
Every acquisition rewrites the file, so its mtime is the last claim of the
key. Holding a key lock spans one compile and
BUILD_LOCK_TIMEOUTis ten minutes; an hour, the staging and orphan-blob grace, leaves any claim that is still in flight far behind, and a key untouched that long is not being contended. The sweep also takes the lock before unlinking, so the grace only decides how eagerly idle files go, never whether a holder is safe. - STAGING_
SWEEP_ GRACE - How long a staging snapshot must sit untouched before a sweep may reclaim
it. A snapshot belonging to a put running in another process is
indistinguishable from a crash leftover, and unlinking one fails that put
at publish time — so the grace has to outlast any plausible in-flight put.
Shared by the daemon’s GC sweep and
doctor --repairso neither can undercut the other. - TOMBSTONE_
RETENTION_ DAYS - How long a post-eviction demand record is kept (kunobi-ninja/kache#594).
Traits§
- Artifact
Policy - Compiler-owned rules applied when publishing an entry. Implementations must permit shared inodes only for outputs that remain immutable after publication.
Functions§
- blob_
path_ in_ store_ dir - blob_
refcount_ drift - The probe for any connection to the index, including read-only ones.
- is_
sqlite_ busy_ snapshot - is_
sqlite_ contention - Whether
errcarries SQLite write contention (SQLITE_BUSYorSQLITE_LOCKED) anywhere in its cause chain. Bad data and I/O errors are not contention; GC counts the two apart. - lock_
poll_ interval - How long a waiter sleeps before its next
try_lock: 1 ms, doubling up to [BUILD_LOCK_POLL_INTERVAL]. A fixed 100 ms poll cost every waiter half of that on each hand-off; in a six-job cold cell that was 350 s of sleep per cell, more than the compiles being waited for. - open_
index_ db - open_
index_ db_ readonly - Open the index database read-only. No schema work, no WAL/synchronous
pragma churn —
query_onlyhard-refuses any accidental write, and the short busy timeout lets a caller skip a figure the index is too busy to answer instead of waiting for it. - open_
index_ db_ reporting_ recovery - Like
open_index_db, but also reports whether the index had to be recreated from scratch. - quarantined_
index_ files - List forensic copies without opening or modifying the index. Ordinary GC leaves these copies intact; an explicit full cache clear removes them.
- verify_
restores_ mode - Parse the restore-verification mode from
KACHE_VERIFY_RESTORES. Read per call (cheap, off the hot path) so tests can toggle it. Back-compatible: the old boolean1/truemaps toAlways, unset/0/false/offtoOff.