Skip to content

ci: enable sccache GHA backend and optimize rust-cache keys#372

Merged
streamer45 merged 1 commit intomainfrom
devin/1777126095-ci-cache-optimization
Apr 25, 2026
Merged

ci: enable sccache GHA backend and optimize rust-cache keys#372
streamer45 merged 1 commit intomainfrom
devin/1777126095-ci-cache-optimization

Conversation

@staging-devin-ai-integration
Copy link
Copy Markdown
Contributor

Summary

sccache has been running with a 0% cache hit rate on all hosted runner jobs because the SCCACHE_GHA_ENABLED environment variable was never set. The mozilla-actions/sccache-action@v0.0.9 installs sccache and exposes the GHA cache service variables but — unlike earlier versions — does not set SCCACHE_GHA_ENABLED=true. Without it, sccache falls back to local disk (/home/runner/.cache/sccache), which is empty on each ephemeral runner.

Additionally, release.yml and marketplace-build.yml installed sccache but never set RUSTC_WRAPPER=sccache, so it was never used as the compiler wrapper.

This PR fixes these issues and optimizes the Swatinem/rust-cache configuration:

  1. Enable sccache GHA backend — adds SCCACHE_GHA_ENABLED: "true" to all 5 Rust workflow env blocks (skit.yml, e2e.yml, plugins.yml, release.yml, marketplace-build.yml).

  2. Add RUSTC_WRAPPER: sccache to release.yml and marketplace-build.yml where it was missing.

  3. Share rust-cache via shared-key — groups 7 independent job caches into 3 shared namespaces:

    • skit → lint, test, build (ubuntu-22.04)
    • skit-e2e → pipeline-validation, playwright-e2e (ubuntu-22.04)
    • skit-gpu → test-gpu, pipeline-validation-gpu (self-hosted)
  4. Save rust-cache only from main — adds save-if: ${{ github.ref == 'refs/heads/main' }} on hosted runner jobs so PR pushes don't churn the cache pool. sccache (now with GHA backend) handles the delta for changed crates.

  5. Enable cache-on-failure: true on all rust-cache entries so partially-completed builds still contribute.

Evidence from a recent Skit / Test run showing the problem:

Cache hits                            0
Cache misses (Rust)                  77
Cache hits rate                    0.00 %
Cache location             Local disk: "/home/runner/.cache/sccache"

The self-hosted GPU runner (persistent disk) confirms sccache works when it has a warm cache:

Cache hits (Rust)                    11
Cache hits rate (Rust)           100.00 %

Review & Testing Checklist for Human

  • Verify sccache stats in the first CI run after merge — the Skit / Test and Skit / Lint post-step should show Cache location: GitHub Actions Cache instead of Local disk and a non-zero hit rate on subsequent runs
  • Check https://github.com/streamer45/streamkit/actions/caches after a few main-branch runs to confirm the number of v0-rust-* entries has decreased (3 shared-key groups instead of 7 per-job groups)
  • Confirm PR-branch CI runs still restore caches correctly (they should restore from main's cache but not save new entries)

Notes

  • The self-hosted GPU jobs (skit-gpu shared-key) do not have save-if since the GPU runner's persistent local sccache disk already provides excellent hit rates, and always-save ensures the GHA rust-cache stays warm as a fallback.
  • sccache inherently cannot cache cargo clippy invocations (~85% of lint calls are "multiple input files") or proc-macro/cdylib crate types (~50% of test/build). rust-cache continues to handle these via target/ snapshot restore.
  • The plugins.yml rust-cache already had cache-on-failure: true and a custom workspaces config — only SCCACHE_GHA_ENABLED was added there.

Link to Devin session: https://staging.itsdev.in/sessions/cdf841e834eb419aa04168a565311f10
Requested by: @streamer45

- Add SCCACHE_GHA_ENABLED=true to all Rust workflows so sccache uses
  the GitHub Actions cache API instead of local disk (which is empty on
  each ephemeral runner, causing 0% hit rate).

- Add RUSTC_WRAPPER=sccache to release.yml and marketplace-build.yml
  where it was missing (sccache was installed but never used).

- Use shared-key in Swatinem/rust-cache to group jobs with similar
  compilation profiles: skit (lint/test/build), skit-e2e
  (pipeline-validation/playwright), skit-gpu (GPU jobs). This reduces
  7 independent cache namespaces to 3.

- Add save-if on hosted runner jobs so rust-cache is only saved from
  main branch runs. PR runs still restore from main cache; sccache
  handles the delta for changed crates.

- Enable cache-on-failure everywhere so partially-completed builds
  still contribute to the cache.

Signed-off-by: StreamKit Devin <devin@streamkit.dev>
Co-Authored-By: Claudio Costa <cstcld91@gmail.com>
@staging-devin-ai-integration
Copy link
Copy Markdown
Contributor Author

staging-devin-ai-integration Bot commented Apr 25, 2026

✅ Reviewed on bb575a2

View review

@staging-devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Copy Markdown
Contributor Author

@staging-devin-ai-integration staging-devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review (Staging)
Debug

Playground

@streamer45 streamer45 merged commit d3acb21 into main Apr 25, 2026
16 checks passed
@streamer45 streamer45 deleted the devin/1777126095-ci-cache-optimization branch April 25, 2026 14:16
streamer45 added a commit that referenced this pull request Apr 25, 2026
The sccache GHA backend stores one cache entry per compiled artifact,
creating ~1000 tiny entries that evict the much more valuable
Swatinem/rust-cache entries (full target/ snapshots) via LRU.

Remove SCCACHE_GHA_ENABLED from all workflows. On hosted runners
sccache falls back to local disk (harmless no-op on ephemeral VMs).
On the self-hosted GPU runner it continues to work via persistent
local disk cache. The other optimizations from #372 (shared-key,
save-if, cache-on-failure, RUSTC_WRAPPER) remain in place.

Signed-off-by: StreamKit Devin <devin@streamkit.dev>
Co-authored-by: StreamKit Devin <devin@streamkit.dev>
Co-authored-by: Claudio Costa <cstcld91@gmail.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.

2 participants