Skip to content

Remove buildConfig from sccache cache key to share across PR/rolling builds#127997

Merged
agocke merged 2 commits intodotnet:mainfrom
agocke:sccache-cache-key-fix
May 10, 2026
Merged

Remove buildConfig from sccache cache key to share across PR/rolling builds#127997
agocke merged 2 commits intodotnet:mainfrom
agocke:sccache-cache-key-fix

Conversation

@agocke
Copy link
Copy Markdown
Member

@agocke agocke commented May 9, 2026

Note

This PR description was generated with the assistance of GitHub Copilot.

Summary

Remove buildConfig (Debug/Release) from the sccache ADO Pipeline Cache key so that PR builds can warm-start from rolling-build caches.

Problem

The sccache cache key included buildConfig, which is Debug for PR builds and Release for rolling builds. This created completely separate cache namespaces, meaning:

  • Rolling builds saved caches to sccache|...|Release|... keys in the refs/heads/main scope
  • PR builds looked for sccache|...|Debug|... keys, never finding rolling build caches
  • Every first build of a new PR started with a cold sccache cache (0% hit rate)
  • Cache hits only occurred on subsequent pushes to the same PR

Why this is safe

The native compiler flags are determined by -rc (RuntimeConfiguration), not -c (Configuration):

Leg -rc (native) -c (managed) PR -c (managed) Rolling
CoreCLR_Libraries Release Debug Release
Libraries_CheckedCoreCLR Checked Debug Release

Since -rc is hardcoded per leg, the CMake build type and native compiler flags are identical between PR and rolling builds. The -c flag only affects managed code, which sccache doesn't cache.

Expected impact

PR builds will restore sccache caches from rolling builds (saved in the main scope), giving ~99% hit rates on first push — a 33-46% reduction in build time for the linux-x64 native compilation legs based on prior analysis.

@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/runtime-infrastructure
See info in area-owners.md if you want to be subscribed.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts the Azure Pipelines Cache key used for the sccache local cache so that PR builds can restore caches produced by rolling (main) builds, improving cache reuse across build types.

Changes:

  • Removed buildConfig from the sccache Cache@2 key and restoreKeys to avoid splitting cache namespaces between PR (Debug) and rolling (Release) builds.
  • Added inline documentation explaining why buildConfig is excluded and what benefit it enables (warm-starting PR builds from rolling caches).

…builds

The sccache cache key included buildConfig (Debug for PRs, Release for
rolling builds), creating separate cache namespaces.  This meant PR
builds could never warm-start from rolling-build caches.

buildConfig reflects the *managed* Configuration (-c), but sccache only
caches native (C/C++) compilations whose flags are controlled by
RuntimeConfiguration (-rc), which is constant per leg regardless of
buildConfig.  Removing it lets PR builds restore caches saved by rolling
builds in the main scope, giving ~99% hit rates on first push instead
of 0%.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@agocke agocke force-pushed the sccache-cache-key-fix branch from 3652bf0 to 6bc7ee9 Compare May 9, 2026 20:29
Copilot AI review requested due to automatic review settings May 9, 2026 23:37
@agocke agocke force-pushed the sccache-cache-key-fix branch from 6bc7ee9 to bab3ecb Compare May 9, 2026 23:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

The stackalloc of uninitialized memory requires an unsafe context.
Wrap it in an unsafe block rather than marking the entire method unsafe.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@agocke agocke force-pushed the sccache-cache-key-fix branch from bab3ecb to ce73855 Compare May 10, 2026 00:42
@agocke
Copy link
Copy Markdown
Member Author

agocke commented May 10, 2026

/ba-g remote exec failure

@agocke agocke enabled auto-merge (squash) May 10, 2026 03:25
@agocke agocke disabled auto-merge May 10, 2026 04:32
@agocke
Copy link
Copy Markdown
Member Author

agocke commented May 10, 2026

/ba-g first ba-g didn't work

@agocke agocke merged commit 5fbc082 into dotnet:main May 10, 2026
157 checks passed
@agocke agocke deleted the sccache-cache-key-fix branch May 10, 2026 08:31
@github-project-automation github-project-automation Bot moved this to Done in AppModel May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done
Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants