Add a script that prunes stale build targets #24

Closed
github-bot wants to merge 1 commit from github-bot/gh-24 into main AGit
Owner

@⁠jgrizon on GitHub · 2026-11-29 23:21 UTC · original
clean-build-targets → main · +125 −0 · 3 files · 1 commits · closed without merging

Summary

scripts/clean.sh
  (no args)   remove build roots with no file changed in 48 h
  --hours N   change the idle window
  --all       remove every build root, fresh ones included
  --caches    also drop shader caches and lift dumps
  --dry-run   list what would go

build root = a directory holding cargo's CACHEDIR.TAG,
             or any directory named target

Why

One day of parallel experiments left 148 Rust build roots under .build: 377 GB, the same dependency tree compiled once per worktree. Nothing in the repo could reclaim it, so it grew by roughly 200 GB per day of experiments.

Selection uses cargo's own CACHEDIR.TAG marker rather than the directory name, because several roots carry custom names (aero-flatmem-target, wt-mesh/target-arm, bench/p64-target). The name pass stays as a fallback for roots created before the marker. The script refuses to run while cargo or rustc is running, and it removes build output only. Branches, worktrees and tracked files stay.

Rejected: a git clean-style helper that also removes worktrees, because unmerged experiment branches would be at risk.

Evidence

  • Before: disk at 1.2 TiB used, 610 GiB free. .build at 468 GB.
  • After the same cleanup by hand: disk at 823 GiB used, 1.0 TiB free. .build at 52 GB. All 117 worktrees and branches intact.
  • Command: zsh -n scripts/clean.sh -> syntax ok. ./scripts/clean.sh --hours 24 --dry-run -> selected a stale fixture root and skipped a fresh one. --all -> removed nested fixtures once, by their outer root. ./scripts/clean.sh after a real sweep -> Nothing to clean. python3 -m unittest discover -s tests -> 6 tests OK.

Not tested: a run against a 20 GB root; the fixtures covered selection, nesting and deletion.

Risk

Can we undo it? Yes. Only build output is deleted; the next build recreates it.

What could break: A root that looks idle but is in active use gets rebuilt. The 48-hour window and the cargo/rustc running check bound that.

How to undo: revert the commit.

Panel

Not run.

**@⁠jgrizon** on GitHub · 2026-11-29 23:21 UTC · [original](https://github.com/paveledits/ScarlettMac/pull/24) `clean-build-targets` → `main` · +125 −0 · 3 files · 1 commits · closed without merging ## Summary ```text scripts/clean.sh (no args) remove build roots with no file changed in 48 h --hours N change the idle window --all remove every build root, fresh ones included --caches also drop shader caches and lift dumps --dry-run list what would go build root = a directory holding cargo's CACHEDIR.TAG, or any directory named target ``` ## Why One day of parallel experiments left 148 Rust build roots under `.build`: 377 GB, the same dependency tree compiled once per worktree. Nothing in the repo could reclaim it, so it grew by roughly 200 GB per day of experiments. Selection uses cargo's own `CACHEDIR.TAG` marker rather than the directory name, because several roots carry custom names (`aero-flatmem-target`, `wt-mesh/target-arm`, `bench/p64-target`). The name pass stays as a fallback for roots created before the marker. The script refuses to run while `cargo` or `rustc` is running, and it removes build output only. Branches, worktrees and tracked files stay. Rejected: a `git clean`-style helper that also removes worktrees, because unmerged experiment branches would be at risk. ## Evidence - **Before:** disk at 1.2 TiB used, 610 GiB free. `.build` at 468 GB. - **After the same cleanup by hand:** disk at 823 GiB used, 1.0 TiB free. `.build` at 52 GB. All 117 worktrees and branches intact. - **Command:** `zsh -n scripts/clean.sh` -> syntax ok. `./scripts/clean.sh --hours 24 --dry-run` -> selected a stale fixture root and skipped a fresh one. `--all` -> removed nested fixtures once, by their outer root. `./scripts/clean.sh` after a real sweep -> `Nothing to clean.` `python3 -m unittest discover -s tests` -> 6 tests OK. Not tested: a run against a 20 GB root; the fixtures covered selection, nesting and deletion. ## Risk **Can we undo it?** Yes. Only build output is deleted; the next build recreates it. **What could break:** A root that looks idle but is in active use gets rebuilt. The 48-hour window and the `cargo`/`rustc` running check bound that. **How to undo:** revert the commit. ## Panel Not run.
A day of parallel experiments left 148 Rust target directories and 372 GB of build output under .build. scripts/clean.sh removes targets idle for 48 hours, with --all for every target and --caches for shader caches and lift dumps.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 23:23:39 +00:00
Author
Owner

@⁠copilot-pull-request-reviewer[bot] on GitHub · 2026-11-29 23:21 UTC · original · reviewed

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

**@⁠copilot-pull-request-reviewer[bot]** on GitHub · 2026-11-29 23:21 UTC · [original](https://github.com/paveledits/ScarlettMac/pull/24#pullrequestreview-6105339834) · **reviewed** Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
github-bot force-pushed github-bot/gh-24 from 49dac739bc to e92de073c6 2026-11-29 23:28:48 +00:00 Compare
github-bot closed this pull request 2026-12-01 21:32:36 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.