Skip to content

Commit 10c08b2

Browse files
abnobdossAbanoub Doss
andauthored
ci: key Windows sccache cache on MSVC version (#787)
## What Add the `cl.exe` version to the Windows sccache cache key (and its restore-keys prefix) in `test` and `sql_catalog_test`, so each MSVC build keeps its own cache. On the `sql_catalog_test` matrix the suffix stays empty for the non-Windows legs, so their keys don't change. ## Why sccache decides whether a cached object is still valid from the compiler binary. GitHub patches the Windows runner image regularly, roughly once a week, and rolls each update out across the hosted fleet over a few days rather than all at once. During that window back-to-back runs can land on different `cl.exe` builds. When that happens the two builds share one cache key and keep evicting each other, and a run on a newer compiler restores the old cache, misses everything, and rebuilds the whole stack (around 35 to 50 minutes). Putting the `cl.exe` version in the key gives each compiler its own cache, so a run stays warm instead of recompiling. ## Validation On the `windows-2025` runner the resolve step read `cl.exe` as 19.51.36248, and the Windows `test` and `sql_catalog_test` builds passed with the version in the key. The cache is only saved on `main`, so the warm reuse shows up there rather than on a branch run. Co-authored-by: Abanoub Doss <abanoub.doss@gmail.com>
1 parent b65352a commit 10c08b2

2 files changed

Lines changed: 44 additions & 6 deletions

File tree

.github/workflows/sql_catalog_test.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,26 @@ jobs:
7474
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
7575
with:
7676
arch: x64
77+
# GitHub patches the Windows image roughly weekly via gradual rollouts, so
78+
# back-to-back runs can hit different cl.exe builds. sccache keys on the compiler,
79+
# so a shared key would miss after each bump; the version keeps caches separate.
80+
# Non-Windows legs get an empty suffix, leaving their keys unchanged.
81+
- name: Resolve MSVC version for sccache key
82+
if: ${{ startsWith(matrix.runs-on, 'windows') }}
83+
shell: pwsh
84+
run: |
85+
$PSNativeCommandUseErrorActionPreference = $false
86+
$banner = (cl.exe 2>&1 | Out-String)
87+
if ($banner -match 'Version ([\d.]+)') {
88+
$suffix = "-$($Matches[1])"
89+
} else {
90+
# The key is only a cache hint, so degrade to a shared bucket rather than
91+
# fail the build; the warning flags that the parse needs fixing.
92+
$suffix = '-unknown'
93+
Write-Host "::warning::could not parse cl.exe version for sccache key, using '$suffix'; banner was: $banner"
94+
}
95+
Add-Content -Path $env:GITHUB_ENV -Value "SCCACHE_KEY_SUFFIX=$suffix"
96+
Write-Host "SCCACHE_KEY_SUFFIX=$suffix"
7797
- name: Install dependencies on Ubuntu
7898
if: ${{ startsWith(matrix.runs-on, 'ubuntu') }}
7999
shell: bash
@@ -99,9 +119,9 @@ jobs:
99119
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
100120
with:
101121
path: ${{ github.workspace }}/.sccache
102-
key: sccache-sqlcatalog-${{ matrix.runs-on }}-${{ github.run_id }}
122+
key: sccache-sqlcatalog-${{ matrix.runs-on }}${{ env.SCCACHE_KEY_SUFFIX }}-${{ github.run_id }}
103123
restore-keys: |
104-
sccache-sqlcatalog-${{ matrix.runs-on }}-
124+
sccache-sqlcatalog-${{ matrix.runs-on }}${{ env.SCCACHE_KEY_SUFFIX }}-
105125
- name: Setup sccache
106126
uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10
107127
- name: Configure Iceberg
@@ -129,7 +149,7 @@ jobs:
129149
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
130150
with:
131151
path: ${{ github.workspace }}/.sccache
132-
key: sccache-sqlcatalog-${{ matrix.runs-on }}-${{ github.run_id }}
152+
key: sccache-sqlcatalog-${{ matrix.runs-on }}${{ env.SCCACHE_KEY_SUFFIX }}-${{ github.run_id }}
133153
- name: Run SQL catalog tests
134154
shell: bash
135155
run: ctest --test-dir build -R '^sql_catalog_test$' --output-on-failure -C ${{ matrix.cmake_build_type }}

.github/workflows/test.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,24 @@ jobs:
144144
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
145145
with:
146146
arch: x64
147+
# GitHub patches the Windows image roughly weekly via gradual rollouts, so
148+
# back-to-back runs can hit different cl.exe builds. sccache keys on the compiler,
149+
# so a shared key would miss after each bump; the version keeps caches separate.
150+
- name: Resolve MSVC version for sccache key
151+
shell: pwsh
152+
run: |
153+
$PSNativeCommandUseErrorActionPreference = $false
154+
$banner = (cl.exe 2>&1 | Out-String)
155+
if ($banner -match 'Version ([\d.]+)') {
156+
$msvc = $Matches[1]
157+
} else {
158+
# The key is only a cache hint, so degrade to a shared bucket rather than
159+
# fail the build; the warning flags that the parse needs fixing.
160+
$msvc = 'unknown'
161+
Write-Host "::warning::could not parse cl.exe version for sccache key, using '$msvc'; banner was: $banner"
162+
}
163+
Add-Content -Path $env:GITHUB_ENV -Value "MSVC_VER=$msvc"
164+
Write-Host "Resolved MSVC_VER=$msvc"
147165
- name: Cache vcpkg packages
148166
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
149167
id: vcpkg-cache
@@ -159,9 +177,9 @@ jobs:
159177
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
160178
with:
161179
path: ${{ github.workspace }}/.sccache
162-
key: sccache-test-windows-${{ github.run_id }}
180+
key: sccache-test-windows-${{ env.MSVC_VER }}-${{ github.run_id }}
163181
restore-keys: |
164-
sccache-test-windows-
182+
sccache-test-windows-${{ env.MSVC_VER }}-
165183
- name: Setup sccache
166184
uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10
167185
- name: Build Iceberg
@@ -176,7 +194,7 @@ jobs:
176194
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
177195
with:
178196
path: ${{ github.workspace }}/.sccache
179-
key: sccache-test-windows-${{ github.run_id }}
197+
key: sccache-test-windows-${{ env.MSVC_VER }}-${{ github.run_id }}
180198
- name: Build Example
181199
shell: pwsh
182200
run: |

0 commit comments

Comments
 (0)