Add sccache (local disk backend) to the CI cache action#15147
Closed
reaperhulk wants to merge 8 commits into
Closed
Add sccache (local disk backend) to the CI cache action#15147reaperhulk wants to merge 8 commits into
reaperhulk wants to merge 8 commits into
Conversation
…warm PEP 517 build isolation creates a temporary virtualenv with a randomized path for every build, so PYO3_PYTHON changes on each install. Our cryptography-cffi build script registers rerun-if-env-changed=PYO3_PYTHON, so cryptography-cffi and cryptography-rust recompiled on every CI job even with a fully warm Swatinem/rust-cache (and on free-threaded builds the pyo3 crates recompiled too, since the non-abi3 interpreter config also embeds the ephemeral path). See PyO3/pyo3#6113 Install the build requirements into the session venv and pass --no-build-isolation instead: the build backend then runs from the stable .nox/<session> interpreter, making the cargo fingerprints stable across CI runs. Verified locally: with isolation every reinstall recompiles the crates (~30s); without it a warm-cache reinstall compiles nothing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lj3BsMN8xmPQQ89d6nzDcZ
rust-cache skips saving on an exact key hit, so without a roll the caches would keep the fingerprints recorded from isolated builds and every job would keep rebuilding once per run. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lj3BsMN8xmPQQ89d6nzDcZ
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lj3BsMN8xmPQQ89d6nzDcZ
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lj3BsMN8xmPQQ89d6nzDcZ
Compiler-level caching to recover the cases Swatinem/rust-cache can't: Cargo.lock bumps (full rust-cache miss) and the workspace crates that rust-cache deliberately prunes from every saved cache. sccache runs with its local disk backend, persisted as a single actions/cache entry per job (~30-40 MB measured for a cold build), so it adds exactly one cache restore and at most one save per job -- no per-object GHA cache API traffic, no rate-limit exposure. The entry key includes the rustc host triple + version and the existing job key; a restore-keys prefix lets an entry carry over across lockfile changes. Jobs on architectures without prebuilt sccache binaries (and the sccache-action failing for any reason) degrade to today's behavior: the wrapper is only enabled if the binary is actually present. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WYvs2Ppi5y2moJF5uoWbvr
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WYvs2Ppi5y2moJF5uoWbvr
43106ef to
ea91da8
Compare
…84' into claude/sccache-gha-caching-lfk8qj # Conflicts: # .github/actions/cache/action.yml
8ef1298 to
d6036ab
Compare
llvm-cov emits warnings to stderr, which session.run(silent=True) captures into the same string as stdout, so any warning ends up written into the .lcov file and crashes merge_rust_coverage.py's strict parser. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WYvs2Ppi5y2moJF5uoWbvr
db5c413 to
67a29a7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds compiler-level caching via sccache to the shared CI cache composite action, layered on top of the existing
Swatinem/rust-cache. The two cover complementary gaps:target/, cargo registry, git deps.Cargo.lockbumps (full rust-cache key miss, e.g. every Dependabot update) and the workspace crates rust-cache deliberately prunes from every saved cache.Design notes:
actions/cacheentry per job — measured ~30–40 MB per cold build flavor (entries are internally compressed). This adds exactly one cache restore and at most one save per job, so no per-object GHA cache API traffic and no rate-limit exposure, unlikeSCCACHE_GHA_ENABLED.sccache-{rustc host triple + version}-{existing job key}-{Cargo.lock hash}with arestore-keysprefix fallback so entries carry across lockfile changes — exactly the moment rust-cache goes cold. Since sccache hashes its real inputs (compiler digest, args, env), a stale entry can only miss, never produce a wrong object.continue-on-error; the wrapper is only enabled after a runtimecommand -v sccachecheck. Jobs without sccache behave exactly as today.SCCACHE_CACHE_SIZE=512Mbounds accretion from restore-keys chains.Expected quota impact: ≤2 GB across the whole matrix, well within the 10 GB free allowance. The sccache-action's post-job hook prints hit/miss stats in each job's logs for verification.
🤖 Generated with Claude Code
https://claude.ai/code/session_01WYvs2Ppi5y2moJF5uoWbvr
Generated by Claude Code