Build Once. The Next Worktree Builds in 0.6 Seconds.
You open a second worktree to review a branch, to give an agent its own checkout, or to keep a build running while you edit. The code is the same as in the checkout next to it, and so are the dependencies. But the new worktree has its own empty target directory, so its first build compiles every dependency again.
Mitts builds Rust projects from their existing Cargo.toml and Cargo.lock, and keeps compiled registry and Git dependencies in one store per machine. A second worktree takes them from that store and compiles only what is its own.
We measured how long that takes on the release that came out today, Mitts 0.5.10. On hyperfine v1.19.0, the first build took 3.8 s, and a second worktree of the same commit took 0.62 s.
The measurement
- Project: hyperfine v1.19.0 (commit 12fec42), a well-known Rust CLI. It is a single crate, so its build is 88 dependency units plus the application itself.
- Mitts: the released 0.5.10, default dev profile (
mitts build, no flags). - Machine: AMD Ryzen 9 9950X (16 cores, 32 threads), Ubuntu 24.04, rustc 1.100.0.
- Conditions: each of the three runs started with an empty store. The first build filled it; the later worktrees reused it. The sources were fetched before the timer, so download time is not included.
| Step | Compiled | Wall time, three runs |
|---|---|---|
| First build, empty store | 89 of 89 units | 3.80 s, 3.78 s, 3.73 s |
| Same worktree again, nothing changed | nothing (Mitts reports a no-op) | 0.00 s |
| Second worktree, same commit | 1 unit, 88 from the store | 0.62 s, 0.62 s, 0.62 s |
| Worktree five commits later (16 files changed) | 6 units, 83 from the store | 2.52 s, 2.51 s, 2.56 s |
In the second worktree rustc compiled only hyperfine itself, in 0.45 s of compiler time. Restoring the 88 dependency units from the store took 0.16-0.25 s. The table shows wall time; the log below uses Mitts's own timer.
This is what the build summary printed:
โโโ [compile] 89 units: 1 compiled, 88 from the cache
โโ โจ dev profile completed in 0.61s (1 compiled, 88 from the cache)
The worktree five commits later compiled the six units whose inputs those commits changed and took the other 83 from the store.
When the gain is smaller
On a 32-thread machine even hyperfine's first build takes only 3.8 s. The number that matters is what is left for the second worktree: your own crate. When your own crate is the slow part, there is less to reuse.
In one run of starship v1.22.1 on the same machine, the first build took 15.5 s and the second worktree 6.6 s. Mitts took 314 of 316 units from the store, but the two units left to compile, starship's own crate among them, took 5.7 s of compiler time.
Since 0.5.8 the project's own crates (workspace members and path dependencies) are built into a store in its target directory, which keeps one version of each. Only registry and Git dependencies are shared across the machine, unless MITTS_SHARE_WORKSPACE_CRATES=1 is set.
How Mitts decides what to reuse
Each compile action is keyed by its inputs: toolchain, target, profile, flags, features, source contents, the keys of its dependencies and the environment it reads. Different inputs produce a different key, and Mitts compiles when the store has no result for that key. An input it cannot account for causes a rebuild rather than a guess.
The worktree guide shows what is shared between worktrees and what is not.
Run it yourself
curl -fsSL https://mittsbuild.com/install.sh | sh # Linux and macOS
git clone https://github.com/sharkdp/hyperfine && cd hyperfine
git checkout v1.19.0
mitts build # first build
git worktree add ../hyperfine-b v1.19.0
cd ../hyperfine-b && mitts build # second worktree
On Windows, install with irm https://mittsbuild.com/install.ps1 | iex in PowerShell.
Your times depend on your machine. The last line of the summary shows how many units came from the store.
Also in 0.5.10
- A
-C linkerin RUSTFLAGS now wins over the linker set in the Cargo config, as in Cargo, and the build summary names the linker that ran. --featuresthat need packages Cargo.lock does not hold are resolved for the build, and the lockfile is left as it is, as with Cargo.- Three Cargo.lock fixes: two versions of a renamed crate in a Git package, a dependency moved from a path to the registry, and a new direct dependency that the lock already held through another package.
- A prebuilt binary for RISC-V 64 Linux.
mitts publishnames the registry's status, detail and Retry-After when an upload is refused, the build header names the Mitts version, and incremental sessions untouched for 7 days are removed.- Known and not changed: build scripts are compiled without the configured linker and without RUSTFLAGS (issue #213).
Several of these fixes started with reports from a user building Slint from Git on a RISC-V board (issue #143). Thanks to omac777.
Full release notes ยท Report an issue
To cite this release, use Panasenko, A. (2026). Mitts Build - Rust-first build system with a machine-wide, content-addressed artifact cache (0.5.10). Zenodo. 10.5281/zenodo.24642662.
Originally published on prod.codes.
Comments
No comments yet. Start the discussion.