Limit sccache cache size to 3.5 GB to reduce transfer overhead#128048
Merged
Conversation
The sccache local cache grows unboundedly (default 10 GB max) as stale entries accumulate across rolling builds. Currently at ~6-7 GB and growing ~0.5 GB per rolling build cycle, the cache restore/save overhead is ~3 minutes per leg, eating into the ~9 minute build time savings. Setting SCCACHE_CACHE_SIZE to 3.5G forces LRU eviction of stale entries, keeping the cache close to the working set size (~3 GB for ~3,482 compiled objects). This should roughly halve the cache transfer times. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
c7b4dc6 to
d0acaa9
Compare
Contributor
|
Tagging subscribers to this area: @dotnet/runtime-infrastructure |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR primarily updates the CoreCLR pipeline sccache setup to reduce cache transfer overhead by bounding the local cache size, but it also includes unrelated System.Security.Cryptography signature changes that don’t match the stated scope.
Changes:
- Set
SCCACHE_CACHE_SIZEin the sccache setup pipeline step (currently to3.5G). - Adjust the Azure Pipelines Cache key/restoreKeys to exclude
buildConfig. - Mark
X25519DiffieHellmanCng.DeriveRawSecretAgreementCorepartial overrides asunsafeacross Windows + not-supported shims.
Reviewed changes
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| eng/pipelines/coreclr/templates/setup-sccache.yml | Sets sccache environment variables and modifies cache keying/restoration behavior. |
| src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X25519DiffieHellmanCng.Windows.cs | Changes the override signature to add unsafe on the Windows implementation. |
| src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X25519DiffieHellmanCng.cs | Changes the partial override declaration to add unsafe. |
| src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/Cng.NotSupported.cs | Changes the PNSE shim override signature to add unsafe. |
Comments suppressed due to low confidence (1)
eng/pipelines/coreclr/templates/setup-sccache.yml:35
- The PR description/title talks about limiting the local sccache size, but this hunk also changes the cache key/restoreKeys to drop
buildConfig(affecting cache sharing behavior between PR/rolling builds). Either update the PR description to cover this behavior change and its rationale/risks, or keep this PR focused by reverting the key change.
#
# buildConfig is intentionally excluded from the key: it reflects
# the *managed* Configuration (Debug for PRs, Release for rolling
# builds), but sccache only caches native (C/C++) compilations whose
# flags are controlled by RuntimeConfiguration (-rc), which is
# constant per leg regardless of buildConfig. Omitting it lets PR
# builds warm-start from rolling-build caches saved in the main scope.
- task: Cache@2
displayName: Sccache cache
inputs:
key: sccache | ${{ parameters.osGroup }} | ${{ parameters.archType }} | ${{ parameters.nameSuffix }} | "$(Build.BuildId)"
path: $(Pipeline.Workspace)/.sccache
restoreKeys: |
sccache | ${{ parameters.osGroup }} | ${{ parameters.archType }} | ${{ parameters.nameSuffix }}
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
steveisok
approved these changes
May 11, 2026
This was referenced May 11, 2026
Member
Author
|
/ba-g all affected legs have passed |
agocke
added a commit
to agocke/runtime
that referenced
this pull request
May 11, 2026
Widen the sccache condition from osSubgroup=='' to also include osSubgroup=='_musl'. The sccache NuGet package (0.15.0) is a statically-linked binary that works on both glibc and musl. The cache key now includes osSubgroup to keep musl and glibc caches separate (different system headers/compiler flags produce different object files). For non-musl builds, osSubgroup is empty so the key is unchanged — existing caches remain valid. Also includes the SCCACHE_CACHE_SIZE=3.5G limit from PR dotnet#128048 to prevent unbounded cache growth. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Open
3 tasks
agocke
added a commit
to agocke/runtime
that referenced
this pull request
May 12, 2026
Widen the sccache condition from osSubgroup=='' to also include osSubgroup=='_musl'. The sccache NuGet package (0.15.0) is a statically-linked binary that works on both glibc and musl. The cache key now includes osSubgroup to keep musl and glibc caches separate (different system headers/compiler flags produce different object files). For non-musl builds, osSubgroup is empty so the key is unchanged — existing caches remain valid. Also includes the SCCACHE_CACHE_SIZE=3.5G limit from PR dotnet#128048 to prevent unbounded cache growth. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
agocke
added a commit
that referenced
this pull request
May 12, 2026
> [!NOTE] > This PR was generated with the assistance of GitHub Copilot. ## Summary Extends sccache caching from linux-x64 to also cover linux-musl-x64 coreclr build legs. Based on the linux-x64 results (~9 min/leg gross savings, 97.59% hit rate at steady state), this should provide similar speedups for the musl legs. ## Changes - **setup-sccache.yml**: Widen condition to include `osSubgroup == '_musl'`; add `osSubgroup` to cache key to keep musl/glibc caches separate - **sccache-stats.yml**: Widen condition to match ## Why this works - The sccache NuGet package (v0.15.0) is a **statically-linked** binary — verified with `file` showing `static-pie linked`. Works on both glibc and musl. - The sccache package is already downloaded by `runtime-prereqs.proj` on all Linux CI builds (line 13-14, condition: `IsOsPlatform(Linux)`). - Cache keys include `osSubgroup` so musl builds get `sccache|linux_musl|x64|...` vs `sccache|linux|x64|...` for glibc — no cross-contamination. - For non-musl builds, `osSubgroup` is empty, so the key is **unchanged** — existing caches remain valid. ## Also included `SCCACHE_CACHE_SIZE=3.5G` limit (from #128048) to prevent unbounded cache growth. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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.
Note
This PR was generated with the assistance of GitHub Copilot.
Summary
The sccache local cache grows unboundedly (default 10 GB max) as stale entries accumulate across rolling builds. It's currently at ~6-7 GB and growing ~0.5 GB per rolling build cycle. The cache restore/save overhead is ~3 minutes per leg, eating into the ~9 minute build time savings sccache provides.
Change
Sets
SCCACHE_CACHE_SIZE=3.5Gto force LRU eviction of stale entries, keeping the cache close to its working set size (~3 GB for ~3,482 compiled objects).Expected Impact
If hit rates drop due to premature eviction, the limit can be raised.