Skip to content

ci: move sccache off S3 to the Actions cache backend ($209/mo egress -> ~$5) #887

Closed

Description

@athvin

Problem

S3 egress from the sccache bucket is the single largest line item in the AWS
account. November MTD, per CUR 2.0 per-resource attribution:

resource usage type qty cost
er-ci-sccache DataTransfer-Out-Bytes 2,425.7 GB $209.32
er-ci-sccache Requests-Tier2 4,598,006 $1.84
er-ci-sccache TimedStorage-ByteHrs 0.9 GB-mo $0.02

$209.32 of the $211.62 S3 total, one resource, one usage type. The next-largest
S3 line anywhere in the account is $0.05. Storage is not the cost — the read
path is.
The bucket is 4.78 GB with a 14-day expiry and egressed 507× its own
size in a week.

The multiplier is compile jobs, not runs. Measured across 25 rust.yml runs on
2026-11-07: ~8.7 sccache jobs per run (lint, entities, 2 test shards,
lake-e2e, a 7-way ducklake matrix, plus benchmarks (compile) and
scale golden on about a third of runs), each pulling ~0.43 GB / ~830 GETs.
Nov 7 reconciles as 106 runs x 8.7 x 0.43 GB = 396 GB = $35.67.

Hit rate is 99.8%, so nearly every lookup is a real download, and each job
starts with an empty rust/target. Those 8.7 jobs share almost all of their
dependency tree, so ~7/8 of the bill is the same bytes re-fetched inside one
run
— no sccache job carries a target-dir cache (rust-cache was removed over
the libduckdb-sys DirectoryNotEmpty bug, not for cost).

Fix: back to the Actions cache backend

The 10 GB per-repository ceiling that motivated #350 became purchasable on
2025-11-20
, after that decision was made: $0.07/GB-month above the included
10 GB, billed on peak hourly usage, user-owned repos configurable to 10 TB.

Raising to 20 GB costs $0.70/mo, plus $4/mo for the GitHub Pro account
the feature requires (this account is on free). ~$4.70/mo against $209.
The limit is both cap and budget — past it the cache evicts rather than billing
more, so that is a ceiling rather than an estimate.

This beats the Cloudflare R2 alternative (~$2/mo) despite being nominally
dearer:

  1. It solves cache poisoning natively. GitHub scoping: a run "cannot restore
    caches created for child branches or sibling branches", so a PR-branch cache
    is unreadable from main — exactly what sccache.tf's two-role IAM split was
    built to provide. R2 has no equivalent, and designing a replacement was the
    blocking question on that path.
  2. It is a revert of perf(ci): point sccache at S3 — DO NOT MERGE UNTIL THE TERRAFORM IS APPLIED #350, not an integration. No new vendor or credential.
  3. The backend was never slow. cache-prune's own comment records run
    39783867347 at 96.65% / 97.54% hit rate with the whole workflow in 8m03 on
    the GHA backend
    . Eviction was the entire problem, and the ceiling is the
    part that is now purchasable.

Sequencing

Ordering is load-bearing: flipping the backend before the limit is raised
evicts into cold runs, and cold is ~3x (gate 14m -> 42m; DuckLake e2e 8m -> 25m;
test 6m -> 15m). test-shard's timeout was already raised 30 -> 45 because cold
compiles were being killed mid-build, so routine eviction would fail jobs
rather than merely slow them.

  • single-writer guards on pnpm-store / next-build (separate ticket) — the
    budget is currently full at 10,387,544,511 bytes / 73 entries with
    sccache out of it
    , and ~2.3 GB of that is PR branches writing entries
    main already owns
  • owner action, not API-settable: upgrade to GitHub Pro, then
    Settings -> Actions -> cache limit 20 GB (/actions/cache/settings
    returns 404; this is UI-only)
  • revert perf(ci): point sccache at S3 — DO NOT MERGE UNTIL THE TERRAFORM IS APPLIED #350's workflow half: SCCACHE_GHA_ENABLED=true, drop
    SCCACHE_BUCKET/SCCACHE_REGION and the OIDC role step from all 8 compile
    jobs
  • measure hit rate and peak cache usage for several days; re-tune
    cache-prune, whose sccache budget line is currently vestigial
  • delete infra/terraform/envs/core/sccache.tf and both OIDC roles

Verification

gh api /repos/{owner}/{repo}/actions/cache/usage for peak usage, the
Build cost (sccache stats, target size) step for hit rate, and the CUR query
above to confirm DataTransfer-Out-Bytes goes to zero.

Activity

  1. added
    no-ticket
    and removed
    no-ticket
    on Nov 8, 2026
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