Skip to content

ci: cache-prune will outgrow its 30m timeout now that sccache writes one entry per object again #902

Not planned

Description

@athvin

Fallout from #887/#893 moving sccache back onto the Actions cache backend.

The number that moved

pre-flip:  10,387,544,511 bytes /    73 entries
+1 hour:   12,026,615,900 bytes / 1,223 entries

sccache writes one Actions-cache entry per compilation object, and because the
backend is scoped per branch, each PR branch gets its own ~1,137-entry /
~1.48 GB scope
. 309 distinct PR branches ran rust.yml in the last 7 days.

Why that is a problem for this job specifically

cache-prune's own comment records the cost of enumeration:

30, not 15: listing ~5,600 entries over 56 paginated requests and then
deleting thousands of them is minutes of pure API round trips even eight at a
time. The first version ran sequentially and did not finish in ten.

timeout-minutes: 30. We were at 73 entries an hour ago and are at 1,223. At
~1,137 entries per compiling PR run, 5,600 is days away and 20,000+ is
plausible inside a week. The job's failure mode is a timeout partway through a
delete sweep
— which looks like a flaky nightly rather than a capacity
problem, and leaves the budget unenforced.

Note the interaction with the eviction limit: raising the limit makes this
worse
, because more retained entries is more to enumerate. That is the main
argument against going from 20 GB to 30 GB, since the $0.70/month difference is
not one.

Options, roughly in order of preference

  1. Land ci: concentrate the sccache GHA write quota on one writer (upstream 429 drops 45-90% of writes) #901 first. Making PR runs SCCACHE_GHA_RW_MODE: READ_ONLY removes
    the per-branch scopes entirely, so entry count collapses to main's single
    scope. This may dissolve the problem rather than manage it — measure after
    ci: concentrate the sccache GHA write quota on one writer (upstream 429 drops 45-90% of writes) #901 before building anything here.
  2. Raise MAX_DELETES (currently 4000) and the timeout together, and have the
    job report how far it got. It already "reports when it stops short rather
    than looking finished" — confirm that still holds at 20,000 entries.
  3. Prune by ref rather than by key prefix: refs/pull/* scopes of merged or
    closed PRs are pure waste and are the bulk of the growth.
  4. Drop the enumeration in favour of the usage endpoint for the size check, and
    enumerate only when over budget.

Verify

gh api /repos/{owner}/{repo}/actions/cache/usage daily for the trend, and the
next few nightly cache-prune runs for wall-clock and whether they completed
their sweep.


Product context (2026-11-26)

Why this matters for the API product: Indirect, it's about CI cost and speed. It doesn't touch the API itself.

Current state:

  • The premise has been reversed. rust.yml:114-115 turns the Actions-cache backend (SCCACHE_GHA_ENABLED) on only for Dependabot PRs. Everyone else uses R2 (SCCACHE_BUCKET=er-ci-sccache), so the per-PR-branch scopes this ticket worried about no longer grow.
  • ci: concentrate the sccache GHA write quota on one writer (upstream 429 drops 45-90% of writes) #901 (READ_ONLY on PRs) is closed.
  • The 2026-11-26 nightly enumerated 4,162 entries / 19.94 GiB. Of those, 4,012 entries (3.6 GiB) were Dependabot sccache, under the 12,288 MiB budget (rust.yml:1515-1522). It finished in under a minute against the 30-minute timeout.
  • /actions/cache/usage today reports 1,500 active entries and 21.06 GB. That doesn't match the prune's enumeration, and I didn't resolve why.
  • The last prune failures were on 2026-11-03 and 2026-11-04, before this ticket was filed.

Definition of done: None. Close as obsolete. If Dependabot volume ever pushes the enumeration toward the timeout, option 3 (prune refs/pull/* scopes of closed PRs) is still the right shape.

Size: 0.

Activity

  1. athvin commented on Nov 29, 2026

    @athvin
    OwnerAuthor

    Closing as obsolete, which is what the 2026-11-26 product context concluded, re-checked 2026-11-29. Sccache now writes to R2 for everything except Dependabot (rust.yml), so the per-branch Actions-cache scopes this ticket worried about no longer grow. The last three scheduled prunes (2026-11-27, 11-28, 11-29) took 24 s, 11 s and 10 s against the 30-minute timeout, all successful. If Dependabot volume ever pushes the enumeration toward the timeout, option 3 here (prune the refs/pull/* scopes of closed PRs) is still the right shape.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions