Skip to content

Introduction

kache is a drop-in RUSTC_WRAPPER for Rust and a cc / c++ compiler wrapper for C/C++ object compiles. Cache keys are blake3 hashes of normalized compiler inputs; cache hits restore zero-copy (reflink, with a hardlink/copy fallback on filesystems without CoW), and identical blobs are stored once and shared. Optional S3 sync (AWS, Ceph, MinIO, R2) shares Rust artifacts across machines.

Local Rust caching, local C/C++ object caching, and direct S3 sync are working today. C/C++ artifacts are local-only for now; unsupported compiler shapes pass through to the real compiler.

PREVIEW: a remote planner that prefetches from workspace manifests, dependency history, and build intent — warming the right artifacts before rustc asks for them. The daemon already calls a planner when KACHE_PLANNER_ENDPOINT is set; the hosted service is still preview. See Remote service.

kache: cold build populates the store, then cargo clean && cargo build restores every artifact zero-copy

Cold compile populates kache's store, cargo clean wipes target/, and the second build pulls every artifact back zero-copy (reflink, falling back to hardlink/copy).

Why local kache is fast

kache is useful even before remote cache is configured:

  • Zero-copy restores. Local hits are restored without copying bytes — via reflink (copy-on-write) where the filesystem supports it (APFS, btrfs, XFS-with-reflink), and via hardlink on other filesystems.
  • Content-addressed storage. The store is keyed by blake3 hash, so identical artifact blobs are stored once and linked many times.
  • Compile-then-record on misses. Misses compile normally, then kache records the outputs for future builds.
  • Daemon-optional locally. If the daemon is not running, local hits and misses still work; remote checks, uploads, and prefetching degrade gracefully.
  • Safer on macOS. Incremental compilation is disabled on every platform while kache wraps rustc — artifact caching subsumes it. On macOS this also avoids APFS-related incremental-compilation corruption in git worktrees.

Try it

# install
mise use -g github:kunobi-ninja/kache@latest

# interactive setup: cargo wrapper + login service + daemon start
kache init

# verify
kache doctor

kache init is idempotent — re-run it any time to repair configuration. Prefer to wire things by hand? Just export RUSTC_WRAPPER=kache or set rustc-wrapper = "kache" under [build] in ~/.cargo/config.toml.

Architecture in one screen

  • WrapperRUSTC_WRAPPER intercepts rustc calls; CC="kache cc" and CXX="kache c++" intercept supported C/C++ object compiles. Hits restore zero-copy (reflink, falling back to hardlink/copy).
  • Daemon — background process handles async S3 uploads, remote checks, and prefetch. Auto-restarts on binary update.
  • Store — SQLite index at {cache_dir}/index.db, plus content-addressed blobs under {cache_dir}/store/blobs/; hits restore those blobs into target/ zero-copy (reflink, falling back to hardlink/copy).
  • Cache keys — deterministic blake3 hash of rustc version, crate name, source, dependencies, and normalized flags — portable across machines.
Available for:
Apple macOS logomacOSMicrosoft Windows logoWindowsLinux logoLinux
Download Kunobi