Skip to content

build-gc: age out unused FFmpeg cache keys from --auto under disk pressure - #1336

Merged
GLinnik21 merged 3 commits into
mainfrom
tools/auto-ffmpeg-cache-ageout
Nov 11, 2026
Merged

GLinnik21 merged 3 commits into
mainfrom
tools/auto-ffmpeg-cache-ageout

Conversation

@GLinnik21

Copy link
Copy Markdown
Collaborator

What

tools/build-gc.sh --auto now ages out FFmpeg cache keys that have not been used for PLX_GC_AUTO_CACHE_DAYS days (default 7). It does this only when free space is below the comfort line, as a stage between the worktrees pass and the planner pass. Before this change, --auto never pruned the FFmpeg cache; only the manual --cache did, at 30 days.

  • New mode --ffmpeg-cache: the FFmpeg half of --cache, without the cargo-seed prune. --auto uses it, so the seed is never touched by --auto. A test pins that.
  • The --cache and --all modes still prune both the FFmpeg keys and the seed, as before.
  • Ages are now measured in minutes (find -mmin), so a key goes once it is more than N×24 h old. The old -mtime +N check kept keys up to a day longer.
  • A non-numeric threshold selects nothing, as before.
  • A held FFmpeg build lock makes the whole stage refuse, as --cache does. The next hourly run of --auto tries again.

Why

The internal SSD keeps running out of space while several worktrees build. On 2026-11-11, 11 of the 15 FFmpeg cache keys had not been used for more than 7 days, about 1.4 GiB. Each key belongs to a superseded FFmpeg version, flag set or toolchain.

This is the first, independent step of the disk plan. The plan's later steps (parking idle build folders on the external disk) depend on a measurement that is still running.

Verification

  • ci/test_build_gc.py: Ran 66 tests, OK. The tests cover:
    • 6.5/7.5-day and 29.5/30.5-day boundaries;
    • a held lock;
    • seed survival;
    • no pruning above the comfort line;
    • -n preview;
    • a custom PLX_GC_AUTO_CACHE_DAYS value.
  • ci/test_disk_budget.py: Ran 97 tests, OK.
  • ci/test_ci_split.py: Ran 16 tests, OK.
  • sh -n tools/build-gc.sh: clean.
  • No Makefile change and no change to ci/build-ffmpeg.sh.

🤖 Generated with Claude Code

GLinnik21 and others added 2 commits November 11, 2026 20:44
…ressure

`--auto` never touched the shared FFmpeg cache, so keys stranded by a version bump or an NDK
upgrade (each ~100+ MB) stayed until someone ran `--cache` by hand, which only collects keys
unused for 30 days and also prunes the cargo seed.

Below the comfort line, after the idle-lane `--worktrees` stage and before the planner pass,
`--auto` now runs a new `--ffmpeg-cache` mode with PLX_CACHE_MAX_DAYS set to
PLX_GC_AUTO_CACHE_DAYS (default 7; non-numeric falls back to 7). `--ffmpeg-cache` is the FFmpeg
half of `--cache` split into its own case: same per-key lock, same refusal for a held FFmpeg
cache lock, same `.last-used` marker, tarballs and `.tombstone.` handling unchanged. The cargo
seed stays out of it; `--cache` and `--all` still run both halves. Above the comfort line no key
is touched, and `--auto -n` previews the age-out.

Tests: old/new keys under pressure, the env var, a held lock keeping its key, a 40-day cargo seed
surviving `--auto`, nothing touched above the line, the dry run, and `--ffmpeg-cache` by hand.
The two existing assertions that `--auto` leaves a 40-day-old key now say the opposite.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`find -mtime +N` counts whole days and truncates the age, so it matched only keys unused for
N+1 days or more while the help text, the docs and the `--auto` stage name all say "unused for N
days". `stale_cache_trees` now uses `-mmin +$((N * 1440))`, which makes `--auto` (7 days) and
manual `--cache` / `--ffmpeg-cache` (30 days) exact. A threshold that is not a number still
selects nothing (the old `find` error was silenced); `$((abc * 1440))` would have read as 0 and
selected every key, so it is checked before the arithmetic.

Tests: a key at 7.5 days is aged out by `--auto` and one at 6.5 days is kept; the same half-day
either side of 30 for `--ffmpeg-cache`; a non-numeric PLX_CACHE_MAX_DAYS removes nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@GLinnik21
GLinnik21 merged commit 4cc74ab into main Nov 11, 2026
15 checks passed
@GLinnik21
GLinnik21 deleted the tools/auto-ffmpeg-cache-ageout branch November 11, 2026 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant