Share one cargo target dir per repo across worktrees #11
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
vnprc/hashpool#11
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Stop per-worktree cargo target dirs from filling the disk: share one build cache per repo so branch worktrees dedup artifacts and keep them warm across
allod change cleanup.Primary goals:
devenv.nixsetsenv.CARGO_TARGET_DIR = "${config.env.HOME}/.cache/cargo-target/hashpool"(or equivalent), so every worktree of this repo builds into one cache instead of its owntarget/.du -sh ~/.cache/cargo-target/*answers "what is eating the disk" in one line.Current state and specifics
Every
allod changeworktree gets an independenttarget/per workspace, and each rebuilds a nearly identical dependency graph. A recent multi-branch stretch accumulated ~90G of near-duplicate build artifacts on the 98G root disk (individual dirs measured at 20-31G for full workspace builds, 11-24G per hashpool worktree) and hit ENOSPC twice in two days; recovery each time was manually deleting~/changes/*/targetdirs. Cargo keys artifacts by toolchain/feature/dependency fingerprints, so builds under different rustc versions or cdk pins coexist in one dir without invalidating each other — the shared dir holds the union, which is far smaller than N copies. A second win: today the cache dies with the worktree atallod change cleanup, so every new change branch starts from a cold build; a shared dir keeps it warm.Tradeoff to accept: cargo holds an exclusive build lock per target dir, so concurrent builds of the same repo serialize (waiting on the lock, visible as "Blocking waiting for file lock"). Per-repo sharing (rather than one global dir) confines that contention to same-repo builds and keeps cross-repo parallelism.
Validation
Two worktrees of this repo build sequentially into the shared dir with the second build substantially cache-warm;
devenv upworks unchanged; deleting a worktree leaves the cache; disk usage across a multi-worktree session stays bounded near single-build size.Scope
In scope: hashpool
devenv.nix+ docs. The same convention applied to the cdk/cdk-ehash checkouts is a docs/practice change alongside, not separate tooling. Out of scope: sccache or other compiler-level caches (heavier machinery than this needs), and anyallod changetooling changes.