ci: cache rustc with sccache on compile-heavy jobs - #125
Draft
michaelroy-amd wants to merge 2 commits into
Draft
Conversation
CI time on the build-heavy jobs is dominated by compiling workspace crates, not tests. setup-rust-toolchain's rust-cache restores the registry and dependency target/ but deliberately does not cache workspace crates, so all first-party crates recompile from scratch every run, even on a full dependency-cache hit. Add sccache as a RUSTC_WRAPPER, backed by the GitHub Actions cache, on the three compile-heavy jobs: build-and-test, windows-build-and-test, and clippy. 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 rather than replacing it. A `sccache --show-stats` step reports the hit rate so the effect is visible in the logs. The env vars (RUSTC_WRAPPER, SCCACHE_GHA_ENABLED) are job-scoped to only these three jobs, and the "Set up sccache" step shares the same heavy/rust gate as the cargo steps, so a skipped or non-heavy run never invokes a missing sccache binary. CARGO_INCREMENTAL=0 (required by sccache) stays explicit on the Windows job and is provided by rust-cache on the Ubuntu jobs. The action is pinned to a commit SHA (v0.0.10). The affected-test-selection, signing, E2E, report, and coverage jobs are untouched. Signed-off-by: Michael Roy <michael.roy@amd.com>
RUSTC_WRAPPER=sccache is set at the job level, so it is already in effect when setup-rust-toolchain runs. Its bundled rust-cache invokes `cargo metadata` during setup, and cargo honours RUSTC_WRAPPER — so with sccache installed only afterwards, that metadata call would try to exec a not-yet-present `sccache` binary. Move the "Set up sccache" step ahead of setup-rust-toolchain in build-and-test, windows-build-and-test, and clippy so the wrapper exists before any cargo invocation, and correct the step comments to match the new ordering. Pure step reordering: conditions (heavy/rust gates) and the SHA-pinned action versions are unchanged. Signed-off-by: Michael Roy <michael.roy@amd.com>
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.
Problem
CI compilation dominates several required jobs, and the existing Rust cache does not preserve workspace crate outputs between runs. Recent baseline main/near-main runs:
Change
mozilla-actions/sccache-actionbefore Rust cache setup.RUSTC_WRAPPER=sccacheandSCCACHE_GHA_ENABLED=trueonly inbuild-and-test,windows-build-and-test, andclippy.CARGO_INCREMENTAL=0behavior.sccache --show-statsafter each compile-heavy job.This rebuilds the intent of #71 from current
main; it does not resolve the stale workflow branch.Verification
A bounded local disk-backend check on
rocm-engine-protocolmeasured 30s cold with 0% hits and 8s warm with 100% hits (~3.6x). This remains a draft until two GitHub Actions runs establish the real GHA cold/warm delta and cache hit rate.