Skip to content

ci: move the sccache bucket to Cloudflare R2 (zero egress AND no per-run write quota) #909

Closed

Description

@athvin

Blocked on #908 (Cloudflare under Terraform), because an R2 bucket and its
API token are Cloudflare resources and this repo declares all infrastructure in
Terraform.

Why: the Actions cache backend is measurably too slow

#887/#893 moved sccache off S3 to kill $209/month of egress. That worked — the
egress is gone and is not coming back. But the Actions cache backend is 2.5x
slower
, measured on main:

wall backend
3615cf18 9.8 min S3
9583e470 25.1 min ghac, first main run

Two independent causes, both measured:

1. Per-hit read latency doubled. Average cache read hit 0.122 s on S3
against 0.242 s on ghac. At 500–1,100 hits per job that is ~1–2 min on the
critical-path job, and it is irreducible — it is just a slower store.

2. The write quota, which is the dominant cause. 9583e470 dropped 3,763
writes
and landed 1,164, a ~24% success rate, giving hit rates across its
nine compile jobs of 1.37 / 6.32 / 21.77 / 26.74 / 30.34 / 32.04 / 36.32 /
39.74 / 48.25 % — mean ~27%. Cause is upstream and confirmed:
mozilla/sccache#2821 —
GHACache::build installs no RetryLayer, so GitHub's HTTP 429 is counted
rather than retried. The rate limit is per workflow run, shared across every
job in it
, and 0.19.0 is affected.

#901 cannot fix this, and the ticket overstates its effect. Because the quota
is per run, one writer and twelve writers get the same ~1,100 objects. #901
makes those 1,100 a coherent set from one job instead of twelve overlapping
fragments — a real improvement in coverage, not a path back to a 10-minute gate.

Why R2 specifically

cost/mo read latency per-run write quota
S3 (before) $209 0.122 s none
ghac (now) ~$5 0.242 s ~1,100/run
R2 ~$2 S3-grade (S3 API) none

R2 is the only option that is both cheap and fast: zero egress fees, and it
is not GitHub's cache service so neither the 429 bug nor the per-run quota
applies. Priced at this footprint: ~4.8 GB storage at $0.015/GB-mo = ~$0.07,
plus ~4.6M Class B reads at $0.36/M = ~$1.66.

sccache reaches it through the S3 backend with SCCACHE_ENDPOINT, so the
workflow change is an endpoint and a credential rather than a new code path.

Cache poisoning — the open design question

The S3 setup had er-ci-sccache-read / er-ci-sccache-write precisely because a
PR able to write the cache is a path for a branch to plant object code a later
main build consumes, and poisoning outlives the credential that planted it.
R2 has no IAM condition keys, so that must be rebuilt:

Also closes, as a side effect

Scope

Interim

Until this lands the gate runs at ~25 min. Reverting #893 restores ~9.8 min at
$209/month — sccache.tf, the bucket and both roles are deliberately still in
place, so git revert needs nothing re-provisioned. That is a cost-versus-CI-
throughput call for the owner.

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