kache README

项目的 README,来自 github.com/kunobi-ninja/kache。合并为一个 markdown 文件:README.md。

CI Bench Crates.io Documentation

Kache

Build once. Reuse the work.

Kache is a compiler cache for Rust, C/C++, and CUDA on Linux, macOS, and Windows. It restores matching compiler outputs across worktrees and CI runs, so you spend less time rebuilding and less disk space storing the same bytes.

Built by Kunobi.

Get started · Benchmarks · Kache vs sccache · CI setup

Install

Install the latest stable Kache and enable it for your build tools.

cargo install kache --locked
kache init
kache doctor --probe

kache init shows the changes before applying them. It configures Cargo's compiler wrapper and the background service. On Unix it also sets up Cargo and C/C++ shims, test pacing, and shell completions. Open a new terminal after setup. Run kache init --check for a preview. The probe checks compile, store and restore in an isolated local cache without contacting a remote.

Then use Cargo as usual in your project. Kache caches eligible compiler work automatically.

Cargo installation needs Rust 1.95 or newer. Prefer a prebuilt package? Homebrew, APT, AUR, Windows packages, mise, and Nix →

Kache installs kache and its matching kache-engine companion. Keep both when copying an installation into a container or managing release archives yourself.

Setup guides

Workflow Start here
Upgrade from 1.x, including the paired binaries and daemon Upgrade guide
Reuse artifacts and private incremental state across worktrees Worktrees
Inspect one build, its misses, and work Kache did not cache Monitor · Troubleshooting
Manage storage, cleanup, and configuration files Storage and cleanup · Configuration
Understand the client, engine, and concurrent daemon pipelines Architecture
Opt into local Blaze routing Blaze

See it reuse a build

Build the same revision in two worktrees with separate target directories. The second can restore compatible outputs from the first. Try the walkthrough.

A recorded demo of a second worktree restoring cached crates, followed by its build report.

View the still image.

A new cache needs a build to fill it. Reuse requires matching inputs, toolchain, and build settings. Unsupported compiler invocations run normally. What can be cached →

Why use Kache?

Four Firefox worktrees sharing cached outputs through copy-on-write clones.

Rust executables and build-script runs are cached by default on Linux and macOS. See platform support and caching limits for Windows and other workload details.

Less disk per worktree

A measured second Firefox worktree adds about 3 GB with Kache on APFS, compared with 16.7 GB with sccache.

In 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 →

Nightly workflows measure cold and warm builds of real projects, including Firefox, LLVM, and SurrealDB. Browse the benchmark reports to see the workload, platform, and validation behind each result.

Optional Blaze builds

The Cargo shim can route eligible local commands through an installed Blaze client. Install Blaze separately and opt in from the project:

kache config set --project cache.blaze true
cargo check

Routing is off by default and supports Linux and Apple silicon macOS. The standalone blaze executable handles plain cargo check and cargo run. CI, release builds, and explicit profiles use Cargo. See the Blaze guide for supported arguments and older Blaze installations.

Watch a build and explain a miss

kache monitor             # live build and cache activity
kache stats --last-build  # latest recorded build session
kache explain             # why the latest build missed
kache explain --all       # all recorded skips and passthroughs, by reason
kache doctor              # check your setup

Reports describe recorded builds. Details missing means those builds did not record enough information to explain a miss. Enable [cache] explain_miss = true before the next build; this cannot reconstruct details from earlier builds. kache config set cache.explain_miss true edits the setting from the CLI.

Kache's monitor showing builds, miss explanations, projects, and stored outputs.

View the still image.

See the current dashboard and controls →

Add it to CI

Install your Rust toolchain, then add the official action before your build:

- uses: kunobi-ninja/kache-action@v1
- run: cargo build --locked

The action installs the latest stable Kache and can persist the local store through GitHub's cache service. The CI guide covers version pins, remote storage, and pull-request policy.

Star History

Star History Chart

Find your next step

I want to… Guide
Confirm my first cache hits Quick start
Cache Make, CMake, or CUDA builds C/C++ · CUDA
Share a cache between machines Remote cache
Change storage limits or build policy Configuration
Investigate unexpected misses Troubleshooting
Understand cache keys and correctness How it works
Look up a command or flag Command reference

Help improve Kache

Report a bug, request a feature, or read CONTRIBUTING.md to contribute.

Licensed under Apache 2.0.

kache (kunobi-ninja/kache)

正在搜索数据库…

这是什么?Kache 是一个面向 Rust、C/C++ 和 CUDA 的编译缓存工具。它根据输入内容为每次构建生成键,因此编译过一次的代码,在下一次使用不同工作树、分支或 CI 运行时会被直接恢复,而不用重新编译。
为什么它自称零拷贝?构建产物存放在本地一个按内容寻址的存储库里,相同的字节只保存一份。在文件系统支持的情况下,恢复时使用写时复制克隆,这正是第二个工作树几乎不占额外磁盘空间的原因。
怎么让它配合 Cargo 使用?运行 kache init 即可:它会在 Cargo 的配置里设置 rustc-wrapper,在 Unix 上还会为构建脚本的 C 和 C++ 添加 [env] 配置项。你的 cargo 命令完全不变,而且可以先用 kache init --check 预览将要做的修改。
怎么安装?需要先装 Rust 工具链吗?预构建软件包覆盖 x86_64 和 ARM 架构,支持 Homebrew、APT、AUR、winget、Scoop、Chocolatey、mise 和 Nix。只有 cargo install 需要 Rust 1.95 或更新版本。
它到底缓存什么?哪些功能不是所有平台都支持?Rust 库和构建脚本在所有平台都支持,但 Rust 可执行文件只支持 Linux 和 macOS——在 Windows 上默认禁用。CUDA 支持覆盖单文件的 nvcc -c 和 -dc 调用,遇到不支持或不安全的编译器调用时会直接放行,不做缓存。
第二个工作树实际会占多少磁盘空间?在一项 Firefox 151 基准测试中(Kache 0.7.0,macOS/APFS),第二个工作树只新增了大约 3 GB 数据,而不是把整个构建目录复制一份。
多个构建同时需要同一个产物时会怎样?到达相同键的并发构建会合并到同一次执行中,所以无论有多少个 Cargo 进程同时请求,编译器在同一台机器上对每个键只运行一次。
它在真实项目上测过吗,还是只有玩具示例?一个定期运行的基准测试工作流会在 Linux 上对 Firefox、LLVM、Substrate、SurrealDB、Lance、OpenDAL、cuda-oxide 和 eza 进行冷构建和热构建,另外还会在 Windows 上构建 Firefox。每次运行都会校验自身测量的有效性,并上传报告、追踪记录和日志,保留 30 天。
它属于哪些主题?zero-copy, s3, ci-cd, caching, compiler, github-actions, ci, c, cuda, cpp, devops, cloud
大小
30.8 MB
星标
1.6K
时长
9个月
提交 · 90 天