Skip to content

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

Draft
michaelroy-amd wants to merge 2 commits into
mainfrom
sccache-current-main
Draft

ci: cache rustc with sccache on compile-heavy jobs#125
michaelroy-amd wants to merge 2 commits into
mainfrom
sccache-current-main

Conversation

@michaelroy-amd

Copy link
Copy Markdown
Member

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:

Run clippy Linux build/test Windows build/test
29429820624 209s 378s 967s
29380117776 59s 154s 426s
29352053724 56s 147s 374s

Change

  • Install SHA-pinned mozilla-actions/sccache-action before Rust cache setup.
  • Set RUSTC_WRAPPER=sccache and SCCACHE_GHA_ENABLED=true only in build-and-test, windows-build-and-test, and clippy.
  • Preserve existing affected-path gates and CARGO_INCREMENTAL=0 behavior.
  • Report sccache --show-stats after each compile-heavy job.
  • Leave coverage, E2E, signing, legal, and reporting jobs unchanged.

This rebuilds the intent of #71 from current main; it does not resolve the stale workflow branch.

Verification

  • workspace clippy with warnings denied
  • workspace build and smoke test
  • nextest: 1506 passed, 6 skipped
  • workflow YAML and action-pin checks
  • signed commits with DCO sign-off
  • OSS leak scan clean

A bounded local disk-backend check on rocm-engine-protocol measured 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.

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>
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.

1 participant