{"slug": "kache-zero-copy-compiler-cache-for-rust", "title": "Kache: Zero-copy, compiler cache for Rust", "summary": "Kunobi released Kache, a zero-copy compiler cache for Rust, C/C++, and CUDA that keys each compiler invocation by the content of its inputs so a crate built once is restored rather than rebuilt across worktrees, branches, or CI runs. Kache installs via `cargo install kache` (requiring Rust 1.95 or newer) followed by `kache init`, which sets `rustc-wrapper` in Cargo's config, and stores outputs in a local content-addressed store that can be shared through S3-compatible or filesystem remotes. The tool ships prebuilt packages for Homebrew, APT, AUR, winget, Scoop, Chocolatey, mise, and Nix, with release builds covering x86_64 and ARM on Linux, macOS, and Windows.", "body_md": "Kache is a compiler cache for Rust, C/C++, and CUDA. It keys every compiler invocation by the content of its inputs, so a crate built once is restored instead of rebuilt in your next worktree, branch, or CI run. Outputs live in a local content-addressed store and can be shared through S3-compatible or filesystem remotes. Linux, macOS, and Windows are supported and release-tested.\n\nBuilt by [Kunobi](https://kunobi.ninja/?utm_source=github&utm_medium=readme&utm_campaign=kache&utm_content=brand).\n\n[Benchmarks](https://kunobi.ninja/docs/kache/benchmarks?utm_source=github&utm_medium=readme&utm_campaign=kache&utm_content=nav_benchmarks) · [Kache vs sccache](https://kunobi.ninja/docs/kache/getting-started/comparison?utm_source=github&utm_medium=readme&utm_campaign=kache&utm_content=nav_comparison) · [CI setup](https://kunobi.ninja/docs/kache/remote-cache/ci?utm_source=github&utm_medium=readme&utm_campaign=kache&utm_content=nav_ci)\n\n[See how Kache shares build outputs across worktrees →](https://kunobi.ninja/product/kache?utm_source=github&utm_medium=readme&utm_campaign=kache&utm_content=hero_details)\n\n```\ncargo install kache\nkache init\n```\n\nYour Cargo commands do not change.\n\n`kache init` sets `rustc-wrapper` in Cargo's config. On Unix it also adds the `[env]` keys for build-script C and C++. Run `kache init --check` to preview the changes, or `kache init --no-service` to skip the OS service.\n\n`cargo install` needs Rust 1.95 or newer. Prebuilt packages exist for Homebrew, APT, AUR, winget, Scoop, Chocolatey, mise, and Nix. Release builds cover x86_64 and ARM on Linux, macOS, and Windows. See [Install Kache](https://kunobi.ninja/docs/kache/getting-started/installation) for each channel.\n\nAfter `kache init`, [build the same revision in two temporary worktrees](https://kunobi.ninja/docs/kache/getting-started/quick-start?utm_source=github&utm_medium=readme&utm_campaign=kache&utm_content=first_reuse). Each gets its own target directory, so your existing build outputs stay in place. The second tree's report lists the hits and a bypass reason for every unit that still compiled.\n\nKache has three parts: a compiler wrapper, a local store, and an optional daemon.\n\n- The wrapper parses each `rustc` ,`rustdoc` ,`cc` ,`c++` , or`nvcc` invocation, hashes the inputs that change the output, and normalizes the machine-local paths that do not. Two worktrees of the same revision produce the same key.\n- Wrappers that reach the same key at the same time join one flight, so the compiler runs once per key on a machine, however many Cargo processes ask for it.\n- The store keeps outputs as content-addressed blobs. Identical bytes are stored once. Restores use copy-on-write clones where the filesystem supports them, so a second worktree costs little disk.\n- The daemon serves remote lookups after a local miss and uploads new entries in the background.\n\nHits, misses, and passthroughs are reported per unit, and `kache why-miss` explains what changed. [Read the architecture →](https://kunobi.ninja/docs/kache/how-it-works/architecture)\n\n| Workload | Status | Notes | \n|---|---|---|\n| Rust libraries and build scripts | Supported | Run `kache init` . Build-script runs are cached on Linux and macOS | \n| Rust executables | Supported on Linux and macOS | Disabled by default on Windows | \n| C and C++ object files | Supported | GCC, Clang, Apple Clang, and clang-cl. Build scripts via `kache init` ; other builds via shims or`CC` /`CXX` | \n| CUDA object files | Supported | Single-source `nvcc -c` and`-dc` via`CUDACXX=\"kache nvcc\"` or a CMake launcher | \n| Rust documentation | Unix | `cargo doc` with`RUSTC_BOOTSTRAP=1` and`-Z rustdoc-depinfo -Z rustdoc-mergeable-info` . Windows has no compiler shims, so`cargo doc` is not cached there | \n| Local storage | Built in | Content-addressed store with garbage collection | \n| S3-compatible remote storage | Built in | Includes AWS S3, MinIO, and Cloudflare R2 | \n| Google Cloud Storage | Built in | Application Default Credentials, including GKE workload identity | \n| Filesystem remote storage | Built in | Useful for shared disks and CI volumes | \n\nIn a Firefox 151 benchmark with Kache 0.7.0 on macOS/APFS, the second worktree added about 3 GB of new data. [Read the measurements and methodology →](https://kunobi.ninja/blog/kache-storage-worktrees?utm_source=github&utm_medium=readme&utm_campaign=kache&utm_content=storage_report)\n\nFor a comparison with sccache, read [Kache or sccache?](https://kunobi.ninja/docs/kache/getting-started/comparison).\n\nThe scheduled [benchmark workflow](https://github.com/kunobi-ninja/kache/actions/workflows/bench.yml) runs real cold and warm builds of Firefox, LLVM, SurrealDB, Lance, OpenDAL, cuda-oxide, and eza on Linux. Separate workflows build Firefox on Windows every night and compare Firefox with sccache once a week. It also measures how much of a Firefox build survives a source update.\n\nEach run checks its own measurement validity and uploads reports, traces, and logs for 30 days. Treat timing or hit-rate numbers as evidence only when the individual job succeeds and its benchmark verdict is `ok`.\n\n[See the benchmark setup and report guide →](https://kunobi.ninja/docs/kache/benchmarks?utm_source=github&utm_medium=readme&utm_campaign=kache&utm_content=benchmark_guide)\n\nThe official action installs Kache and wires it into the build:\n\n```\n- uses: kunobi-ninja/kache-action@v1\n\n- run: cargo build --locked\n```\n\nSee the [CI guide](https://kunobi.ninja/docs/kache/remote-cache/ci) for GitHub Actions and shell-based CI examples.\n\nOn Unix, `kache init` creates compiler-name shims and offers to add their directory to `PATH` in your zsh, bash, or fish startup file. Make, CMake, autotools, and Arch PKGBUILDs that call `gcc` by name then go through Kache, with no `CC=` edit or shell wrapper.\n\nFor managed dotfiles or another shell, set it up by hand:\n\n```\nkache install-shims\nexport PATH=\"$HOME/.local/lib/kache/shims:$PATH\"\n```\n\nAPT and AUR packages install `/usr/lib/kache`. Nix packages include the same symlinks in `${kache}/shims` and `${kache}/lib/kache`; see the [Nix configuration example](https://kunobi.ninja/docs/kache/getting-started/installation#nix).\n\nFor `makepkg`, put the same assignment in `~/.makepkg.conf`. Wrap extra names already on `PATH` with `kache install-shims --from-path`.\n\nKache inspects the real compiler invocation. Unsupported or unsafe invocations pass through. See [C and C++](https://kunobi.ninja/docs/kache/getting-started/c-cpp).\n\nThe default local cache is:\n\n- Linux: `$XDG_CACHE_HOME/kache` or`~/.cache/kache`\n- macOS: `~/Library/Caches/kache`\n- Windows: `%LOCALAPPDATA%\\kache`\n\nOpen the configuration editor with `kache config`, or edit the TOML file directly. A minimal S3-compatible remote looks like this:\n\n```\n[cache.remote]\ntype = \"s3\"\nbucket = \"my-build-cache\"\nregion = \"us-east-1\"\n```\n\nCredentials come from the standard AWS environment variables or credential chain. See [S3 setup](https://kunobi.ninja/docs/kache/remote-cache/s3-setup) and [filesystem setup](https://kunobi.ninja/docs/kache/remote-cache/filesystem-setup).\n\n```\nkache monitor                 # live build and cache activity\nkache stats                   # hit rate, time saved, cache size\nkache stats --last-build      # hits, misses, and bypass reasons of the latest build\nkache stats --full --redact   # full report without cache keys and paths, for sharing\nkache diff                    # compare the two newest sessions of one root\nkache doctor                  # setup and integrity checks\nkache install-shims           # Unix compiler-name PATH farm\nkache why-miss <crate>        # explain the latest miss\nkache list                    # inspect cached entries\nkache gc                      # enforce cache limits\nkache targets                 # target dirs, what each frees, deleted worktrees\nkache clean --orphans --yes   # remove the targets of deleted worktrees\nkache sync                    # pull from and push to the configured remote\nkache daemon status           # inspect the background service\n```\n\nRun `kache help <command>` for exact flags. The [command reference](https://kunobi.ninja/docs/kache/commands/reference) covers every top-level command.\n\nTo pass one build through without changing the setup, run it with `KACHE_DISABLED=1`.\n\nFor Kubernetes and GitOps, [Kunobi Desktop](https://kunobi.ninja/product/desktop?utm_source=github&utm_medium=readme&utm_campaign=kache&utm_content=desktop) lets you inspect clusters and manage Flux and Argo CD.\n\n- [Open a bug report](https://github.com/kunobi-ninja/kache/issues/new?template=bug_report.md) when Kache behaves differently from the documentation.\n- [Request a feature](https://github.com/kunobi-ninja/kache/issues/new?template=feature_request.md) for a missing compiler, remote backend, or build workflow.\n\n```\ngit clone https://github.com/kunobi-ninja/kache.git\ncd kache\ncargo test --workspace --all-features\n```\n\nSee [CONTRIBUTING.md](https://github.com/kunobi-ninja/kache/blob/main/.github/CONTRIBUTING.md) before opening a pull request.\n\nKache is licensed under the [Apache License 2.0](https://github.com/kunobi-ninja/kache/blob/main/LICENSE).", "url": "https://wpnews.pro/news/kache-zero-copy-compiler-cache-for-rust", "canonical_source": "https://github.com/kunobi-ninja/kache", "published_at": "2026-10-01 18:08:16+00:00", "updated_at": "2026-10-01 18:17:00.000328+00:00", "lang": "en", "topics": ["developer-tools", "ai-infrastructure"], "entities": ["Kache", "Kunobi", "Rust", "Cargo", "CUDA", "sccache", "AWS S3", "Google Cloud Storage"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/kache-zero-copy-compiler-cache-for-rust", "markdown": "https://wpnews.pro/news/kache-zero-copy-compiler-cache-for-rust.md", "text": "https://wpnews.pro/news/kache-zero-copy-compiler-cache-for-rust.txt", "jsonld": "https://wpnews.pro/news/kache-zero-copy-compiler-cache-for-rust.jsonld"}}