From 12408268be262939ed1cab8c409aecbf907bcef4 Mon Sep 17 00:00:00 2001 From: Julian Sommer <115516918+juliansommer@users.noreply.github.com> Date: Tue, 1 Sep 2026 14:26:54 +1000 Subject: [PATCH] chore: trim unused entries from the go build cache before saving The cache was a union that only grew: each run restored everything, added what it compiled and saved the result, so objects superseded by later commits stayed for Go's full five-day window. Deleting every entry and letting it rebuild took Build and Test from 3434 MB to 478 MB, restore from 75s to 13s and save from 64s to 7s. Dropping entries nothing has touched in four hours holds it near that. Go bumps an entry's mtime when a run uses it, so the working set survives; the step runs after the tests, so a pruned entry costs a later run a partial recompile at worst and never the current one. --- .github/workflows/spinifex.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/.github/workflows/spinifex.yml b/.github/workflows/spinifex.yml index efd2c2b1a..931c8ef31 100644 --- a/.github/workflows/spinifex.yml +++ b/.github/workflows/spinifex.yml @@ -137,6 +137,17 @@ jobs: # Compiled output stays valid whatever the tests said, and skipping the # save on a red run would leave the next one rebuilding it, so this is # gated on the branch rather than on success. + # Go bumps an entry's mtime when a run uses it, so this run's working set + # survives and objects superseded by later commits do not. Runs after the + # work, so it costs this job nothing and only shrinks what the next reads. + - name: Trim Go build cache + if: ${{ !cancelled() && (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main') }} + run: | + C="$(go env GOCACHE)" + before=$(du -sm "$C" | cut -f1) + find "$C" -type f -mmin +240 -delete + echo "trimmed ${before}MB -> $(du -sm "$C" | cut -f1)MB" + - name: Save Go build cache if: ${{ !cancelled() && (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main') }} uses: actions/cache/save@v6 @@ -227,6 +238,17 @@ jobs: - name: Run Tests with Race Detector run: make -C spinifex test-race GOTESTFLAGS=-count=1 + # Go bumps an entry's mtime when a run uses it, so this run's working set + # survives and objects superseded by later commits do not. Runs after the + # work, so it costs this job nothing and only shrinks what the next reads. + - name: Trim Go build cache + if: ${{ !cancelled() && (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main') }} + run: | + C="$(go env GOCACHE)" + before=$(du -sm "$C" | cut -f1) + find "$C" -type f -mmin +240 -delete + echo "trimmed ${before}MB -> $(du -sm "$C" | cut -f1)MB" + - name: Save Go build cache if: ${{ !cancelled() && (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main') }} uses: actions/cache/save@v6 @@ -328,6 +350,17 @@ jobs: if: ${{ !cancelled() }} run: make -C spinifex test-integration + # Go bumps an entry's mtime when a run uses it, so this run's working set + # survives and objects superseded by later commits do not. Runs after the + # work, so it costs this job nothing and only shrinks what the next reads. + - name: Trim Go build cache + if: ${{ !cancelled() && (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main') }} + run: | + C="$(go env GOCACHE)" + before=$(du -sm "$C" | cut -f1) + find "$C" -type f -mmin +240 -delete + echo "trimmed ${before}MB -> $(du -sm "$C" | cut -f1)MB" + - name: Save Go build cache if: ${{ !cancelled() && (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main') }} uses: actions/cache/save@v6