Skip to main content

Module eval_cache

Module eval_cache 

Source
Expand description

Content-addressed evaluation cache (file hash + lock hash → result). Content-addressed evaluation cache.

Maps (source_hash, lock_hash) pairs to previously evaluated results, skipping redundant evaluation when inputs haven’t changed.

§Tier model (additive — every tier is optional, all may stack)

  1. In-memory (HashMap) for the current session — instant lookups. Always present.
  2. JSON file at ~/.cache/sui/eval-cache.json — survives across invocations. Optional; enabled by with_persistent.
  3. GraphStore (sui-graph-store, redb + rkyv on a ZFS-friendly blob layout) — fleet-shared / cross-process tier. Optional; enabled by with_graph_store. When set, the eval cache’s entries become first-class blobs in GraphKind::EvalCacheEntry, which means a peer with the same GraphStore root (e.g. via zfs send | zfs recv or a future substituter push) gets every cached eval for free. Lookup-order on get: memory → graph_store (warm on disk via mmap, hits sub-200 µs); on a hit from the graph_store tier the result is promoted into memory so the next same-process lookup is sub-microsecond.

All three tiers honor the same enabled flag (set by the CLI flag that disables caching entirely) and the same key shape (CacheKey). Adding a tier never removes an older one — with_all_tiers enables all three at once; individual with_* constructors stack them incrementally.

Only JSON-serializable values are cached (no lambdas, no thunks).

Structs§

CacheKey
Hash of a source file plus its transitive inputs (flake.lock).
CachedValue
A cached evaluation result.
EvalCache
Content-addressed evaluation cache with optional persistence.

Functions§

now_timestamp
Return the current Unix timestamp (seconds since epoch).