Repository navigation
Description
GHACache::build (src/cache/gha.rs) builds its opendal Operator with only a logging layer:
let op = Operator::new(builder)?
.with_context(OperationContext::new().with_http_transport(set_user_agent()))
.layer(LoggingLayer::default());GitHub's Actions cache service rate limits per workflow run, shared across every job in it, and
answers a burst of writes with HTTP 429. opendal marks that error temporary, but RetryLayer
appears nowhere in the repository, so nothing acts on it: sccache increments cache_write_errors
and the compilation result is never stored. Confirmed unchanged on main as of 2026-08-23 and on
v0.17.0.
What it costs
A dropped write is not slow, it is gone, until that object is recompiled and re-offered on some
later run that happens to win the rate limit.
We moved a six-job CI matrix from a tarball cache to SCCACHE_GHA_ENABLED=on. Two consecutive
runs, same code, all six jobs writing at once (run 1,
run 2). Run 2's hit rate reads out
what run 1 managed to store:
| job family | run 1 stored / attempted | run 2 Rust hit rate |
|---|---|---|
| windows-latest | 337 / 610 (55%) | 41.29% |
| macos-latest | 369 / 905 (41%) | 39.20% |
| ubuntu-24.04-arm | 274 / 895 (31%) | 34.37% |
| Android (cargo-ndk) | 128 / 819 (16%) | 23.92% |
Because sccache keys on the whole compiler invocation, each family's objects are private to it
(different target triples, cargo check vs cargo build, different RUSTFLAGS), so a write one
job loses is never covered by another job's write. The loss rate is an upper bound on the
achievable hit rate, not a warm-up effect.
The control: one job family ran ghac alone for seven consecutive runs before the others migrated,
and sustained 96.79% Rust hit rate with zero write errors, read errors, cache errors and timeouts
in every one of them. Same repo, same sccache version, same backend. Adding five concurrent
writers took write loss from 0% to 45-90%.
Why it can't be worked around
SCCACHE_GHA_RW_MODE only turns writing off. The limit is shared across the whole run, so no
single job can observe it or throttle against it, and retrying at the CI level is impossible
because the put happens inside the compile request.
Suggested fix
sccache pins opendal 0.58.1 and already pulls layers as separate crates (opendal-layer-logging).
opendal-layer-retry is published at the same version, so this is a dependency plus a layer:
.layer(RetryLayer::new().with_jitter())RetryLayer retries only errors opendal marks temporary, so it does not paper over real failures.
Given the service asks for retry-after: 1, even a small max_times should recover most of
these. The default matters more than a tuning knob: the failure is silent, so people are far more
likely to report "GHA cache builds are surprisingly slow" than "my cache is 40% smaller than it
should be".
Possibly related: #1485 reports the same 429s against the older v1 cache service, diagnosed as far
as Cache write error: ... 429 Too Many Requests, and never closed.
Environment
sccache 0.17.0, SCCACHE_GHA_ENABLED=on, ACTIONS_CACHE_SERVICE_V2=true, SCCACHE_DIRECT=true,
GitHub-hosted runners: ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
paulirotta commentedon Aug 23, 2026
I built the RetryLayer patch and ran it on the same workload, on the same six-family
matrix, against the live cache service. Run:
https://github.com/paulirotta/ahma/actions/runs/32626626090
It works, but opendal's default backoff is too impatient for this service.
Across the run there were 56 HTTP 429s, all of them on
CacheService/CreateCacheEntry. The retry layer retried 51 of them. Of the 18distinct operations that were throttled, 13 recovered and 5 were lost — all writes.
Reads recovered 10 of 10. Total write loss was 7 of 509 attempts (1.4%), and two of
those seven were
AlreadyExists409s from another job storing the same key, not ratelimiting. No read errors, no cache errors, no timeouts, and ordinary misses still come
back
NotFound (persistent), so nothing is retried that should not be.The reason for the five that were still lost is in the response headers. GitHub sends
retry-afteron these 429s and asks for 1 to 21 seconds, median around 7:RetryLayerignores that header and backs off exponentially — I measured 1.2s, 2.8s,5.1s, so about 10 seconds of patience across the three default retries. Every one of
the five losses is the same shape: the service asked for 11, 18 or 21 seconds and the
retry budget ran out first.
So I would suggest the layer be configured rather than left at defaults, e.g.
.with_max_times(6).with_max_delay(Duration::from_secs(8)), which puts attempts atroughly 1, 3, 7, 15, 23 and 31 seconds and covers the observed range. Honouring
retry-afterwould be better still, but opendal's error type carries no delay hint,so max_times is the lever available.
One caveat on the numbers: this run started warm, 509 write attempts against roughly
4000 in the runs quoted above, so 1.4% is not directly comparable to the 45-90% there.
What it does show is that the layer engages on real 429s and recovers 91% of them.
fix: switch DuckDB build cache from sccache's GHA backend to local disk
ci(local): surface sccache server errors in release stats step
ci: cache the bundled DuckDB C++ build with sccache (#2132)
perf(ci): pin sccache 0.17.0 so the Windows cache actually stores
perf(ci): cache niu Windows release builds with sccache
ci: cmd probes on Windows, sccache writes from main only
ci: GitHub-hosted runners, build once and shard, caching fixed (provi…
infra(core): declare the R2 sccache bucket and its lifecycle rule
infra(core): declare the R2 sccache bucket and its lifecycle rule (#910…
ci(rust): sccache on Cloudflare R2 — cheap AND fast (#909) (#920)