ra-jit for our Rust builds
Build in the main checkout instead?
The main checkout already has a warm 31 GB target/, so a build there is fast. But that checkout is shared. It has 1,050 uncommitted changes from other sessions, so a build there does not build your branch. It is also one build directory, so builds wait in line for its lock.
Why each worktree starts from scratch
| Fact | Effect |
|---|---|
Each worktree gets its own target/ |
All dependencies compile again |
31 worktrees, 3 with a target/ (5.6, 14, 31 GB) |
Cleanup removes the warm caches |
| 54 GB free, disk 94% full | We can't keep a warm copy per worktree |
Fix 1: shared compiler cache
sccache keeps each compiled dependency once, for the whole Mac. A new worktree reuses those results and does not compile them again. Its own crates still compile. It plugs into our existing rustc-gate limit, so the 8-slot cap stays. Not installed yet.
Fix 2: clone the warm cache into new worktrees
APFS can copy the main target/ instantly, without using extra disk until files change. A new worktree then starts warm. This needs a test to confirm that cargo reuses the copied dependencies.
Does the copy fill the disk?
| Test on this Mac | Free space change |
|---|---|
| Write a 1 GB file | -0.9 GB |
Clone it (cp -c) |
about 0 (128 KB) |
The clone shares the same blocks on disk. A worktree uses new space only for files it rebuilds, mostly its own crates. That is less than a fresh build writes today (5.6–31 GB). du counts every clone at full size, so check space with df.
Caveats: the shared blocks stay on disk until every copy that uses them is deleted. sccache saves time, not space: each worktree still writes a full target/, and the cache adds about 20 GB.
Dropped: faster linker
This Mac already uses Apple's new linker (ld-1115), which is fast. A different linker would save little, so it's not worth it.
Next step
- A release build is running now, so the test waits until it ends.
- Test: build one fresh worktree three ways (cold, with sccache, with a cloned cache) and compare the times.
- Then turn on the winner for all agents. This changes
~/.cargo/config.tomlandrustc-gatefor everyone, so you OK it first.