Skip to content

ci: cache rustc with sccache on compile-heavy jobs - #71

Closed
rominf wants to merge 1 commit into
mainfrom
ci-sccache-compile-cache
Closed

ci: cache rustc with sccache on compile-heavy jobs#71
rominf wants to merge 1 commit into
mainfrom
ci-sccache-compile-cache

Conversation

@rominf

@rominf rominf commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Problem

CI time is dominated by compilation, not tests. On the Windows job the workspace build is ~560s versus ~150s for the test step, and it pays that even on a full cache hit: rust-cache restores the registry and dependency artifacts but deliberately does not cache workspace crates, so all 15 crates and their targets recompile from scratch every run.

Change

Add sccache as a RUSTC_WRAPPER on the compile-heavy jobs (build-and-test, windows-build-and-test, clippy), backed by the GitHub Actions cache. sccache keys each rustc invocation on its source, dependencies, and flags, so unchanged crates are restored instead of recompiled across runs and branches. It layers on top of rust-cache (which still handles the registry/deps) rather than replacing it. CARGO_INCREMENTAL=0 is already set, which sccache requires. Coverage is left out (instrumented builds). The action is pinned to a commit SHA.

A sccache --show-stats step reports the hit rate so the effect is visible in the logs.

Status: draft — measuring

This is an experiment to validate the win before merging. sccache helps on the second run (the first populates the cache), and the GitHub Actions cache backend has real limits (10 GB/repo shared with rust-cache, per-request chattiness). I'll post the cold-vs-warm build-time delta and hit rate from two runs, then mark ready only if the numbers justify it.

This is independent of the affected-test-selection work (#70).

The build dominates CI time: on Windows the workspace build is ~560s, far
more than the ~150s test step, and a full cache hit from rust-cache does
not help it. rust-cache restores the registry and dependency artifacts but
deliberately does not cache workspace crates, so all 15 crates and their
targets recompile from scratch every run.

Add sccache as a RUSTC_WRAPPER on build-and-test, windows-build-and-test,
and clippy, backed by the GitHub Actions cache. sccache keys each rustc
invocation on its source, dependencies, and flags, so unchanged crates are
restored instead of recompiled across runs and branches. It layers on top
of rust-cache (registry/deps) rather than replacing it; CARGO_INCREMENTAL
is already 0, which sccache requires. A `sccache --show-stats` step reports
the hit rate.

Coverage is left out (instrumented builds). The action is pinned to a
commit SHA.

Signed-off-by: Roman Inflianskas <Roman.Inflianskas@amd.com>
@michaelroy-amd

Copy link
Copy Markdown
Member

Superseded by #125, rebuilt from current main rather than resolving this stale workflow branch.

The replacement preserves the original sccache intent while retaining current affected-crate CI, merge-queue checks, signing gates, and E2E/reporting workflows. It remains draft until GitHub Actions provides a cold/warm cache comparison and hit-rate evidence.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants