Skip to content

Commit f38090e

Browse files
abnobdossAbanoub Doss
andauthored
ci: cache the sccache directory across C++ test builds (#765)
## What Turn on compiler caching (sccache) for the Linux and macOS builds in `test`, `aws_test`, `sanitizer_test`, and `sql_catalog_test`, and switch the Windows `test` build to the same setup. `main` builds once and saves the cache; pull requests reuse it without writing back. ## Why Right now only the Windows builds reuse compiled output — every Linux and macOS build recompiles the whole bundled Arrow/Parquet/Avro/Boost stack from scratch, even though it never changes between PRs. Building it once and reusing it removes most of that repeated work. Saving the cache as a single file (instead of one upload per compiled file) also avoids the upload rate limit that causes "cache write error" spam. ## Validation On a warm pull-request run, every build reused the cache: 99.6–99.9% of files came from cache, zero write errors. The heavy builds drop from ~10–27 min to ~1.5–5 min. --------- Co-authored-by: Abanoub Doss <abanoub.doss@gmail.com>
1 parent 5c8c4e5 commit f38090e

4 files changed

Lines changed: 171 additions & 16 deletions

File tree

.github/workflows/aws_test.yml

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ jobs:
7474
AWS_DEFAULT_REGION: us-east-1
7575
AWS_ENDPOINT_URL: http://127.0.0.1:9000
7676
AWS_EC2_METADATA_DISABLED: "TRUE"
77+
SCCACHE_DIR: ${{ github.workspace }}/.sccache
78+
SCCACHE_CACHE_SIZE: "2G"
7779
steps:
7880
- name: Checkout iceberg-cpp
7981
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
@@ -113,11 +115,29 @@ jobs:
113115
if: ${{ matrix.s3 == 'ON' }}
114116
shell: bash
115117
run: bash ci/scripts/start_minio.sh
118+
- name: Restore sccache cache
119+
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
120+
with:
121+
path: ${{ github.workspace }}/.sccache
122+
key: sccache-aws-${{ matrix.runs-on }}-bundle${{ matrix.bundle_awssdk }}-s3${{ matrix.s3 }}-sigv4${{ matrix.sigv4 }}-${{ github.run_id }}
123+
restore-keys: |
124+
sccache-aws-${{ matrix.runs-on }}-bundle${{ matrix.bundle_awssdk }}-s3${{ matrix.s3 }}-sigv4${{ matrix.sigv4 }}-
125+
- name: Setup sccache
126+
uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10
116127
- name: Build and test Iceberg
117128
shell: bash
118129
env:
119130
CMAKE_TOOLCHAIN_FILE: ${{ startsWith(matrix.runs-on, 'ubuntu') && matrix.bundle_awssdk == 'OFF' && '/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake' || '' }}
120-
run: ci/scripts/build_iceberg.sh "$(pwd)" OFF OFF ${{ matrix.s3 }} ${{ matrix.sigv4 }} ${{ matrix.bundle_awssdk }}
131+
run: ci/scripts/build_iceberg.sh "$(pwd)" OFF ON ${{ matrix.s3 }} ${{ matrix.sigv4 }} ${{ matrix.bundle_awssdk }}
132+
- name: Show sccache stats
133+
shell: bash
134+
run: sccache --show-stats
135+
- name: Save sccache cache
136+
if: github.ref == 'refs/heads/main'
137+
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
138+
with:
139+
path: ${{ github.workspace }}/.sccache
140+
key: sccache-aws-${{ matrix.runs-on }}-bundle${{ matrix.bundle_awssdk }}-s3${{ matrix.s3 }}-sigv4${{ matrix.sigv4 }}-${{ github.run_id }}
121141

122142
# Exercise the Meson build with SigV4 enabled (resolves aws-cpp-sdk-core via
123143
# its CMake config, not pkg-config whose Cflags force -std=c++11).
@@ -126,6 +146,9 @@ jobs:
126146
name: Meson SigV4 (AMD64 Ubuntu 24.04)
127147
runs-on: ubuntu-24.04
128148
timeout-minutes: 45
149+
env:
150+
SCCACHE_DIR: ${{ github.workspace }}/.sccache
151+
SCCACHE_CACHE_SIZE: "2G"
129152
steps:
130153
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
131154
with:
@@ -161,14 +184,32 @@ jobs:
161184
echo "::error::vcpkg install failed after 3 attempts"
162185
exit 1
163186
- name: Set Ubuntu Compilers
187+
# Wrap the compiler with sccache: Meson uses an explicit CC/CXX verbatim,
188+
# so the launcher must be prepended here to route compiles through sccache.
164189
run: |
165-
echo "CC=gcc-14" >> $GITHUB_ENV
166-
echo "CXX=g++-14" >> $GITHUB_ENV
190+
echo "CC=sccache gcc-14" >> $GITHUB_ENV
191+
echo "CXX=sccache g++-14" >> $GITHUB_ENV
192+
- name: Restore sccache cache
193+
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
194+
with:
195+
path: ${{ github.workspace }}/.sccache
196+
key: sccache-meson-sigv4-${{ github.run_id }}
197+
restore-keys: |
198+
sccache-meson-sigv4-
199+
- name: Setup sccache
200+
uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10
167201
- name: Build and test Iceberg
168202
shell: bash
169203
env:
170204
CMAKE_PREFIX_PATH: /usr/local/share/vcpkg/installed/x64-linux
171205
run: |
172206
meson setup builddir -Dsigv4=enabled
173207
meson compile -C builddir
208+
sccache --show-stats
174209
meson test -C builddir --timeout-multiplier 0 --print-errorlogs
210+
- name: Save sccache cache
211+
if: github.ref == 'refs/heads/main'
212+
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
213+
with:
214+
path: ${{ github.workspace }}/.sccache
215+
key: sccache-meson-sigv4-${{ github.run_id }}

.github/workflows/sanitizer_test.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ jobs:
3939
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
4040
name: "ASAN and UBSAN Tests"
4141
runs-on: ubuntu-24.04
42+
env:
43+
SCCACHE_DIR: ${{ github.workspace }}/.sccache
44+
SCCACHE_CACHE_SIZE: "2G"
4245
steps:
4346
- name: Checkout iceberg-cpp
4447
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
@@ -47,14 +50,33 @@ jobs:
4750
- name: Install dependencies
4851
shell: bash
4952
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
53+
- name: Restore sccache cache
54+
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
55+
with:
56+
path: ${{ github.workspace }}/.sccache
57+
key: sccache-sanitizer-ubuntu-${{ github.run_id }}
58+
restore-keys: |
59+
sccache-sanitizer-ubuntu-
60+
- name: Setup sccache
61+
uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10
5062
- name: Configure and Build with ASAN & UBSAN
5163
env:
5264
CC: gcc-14
5365
CXX: g++-14
5466
run: |
5567
mkdir build && cd build
56-
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Debug -DICEBERG_ENABLE_ASAN=ON -DICEBERG_ENABLE_UBSAN=ON
68+
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Debug -DICEBERG_ENABLE_ASAN=ON -DICEBERG_ENABLE_UBSAN=ON \
69+
-DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
5770
cmake --build . --verbose
71+
- name: Show sccache stats
72+
shell: bash
73+
run: sccache --show-stats
74+
- name: Save sccache cache
75+
if: github.ref == 'refs/heads/main'
76+
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
77+
with:
78+
path: ${{ github.workspace }}/.sccache
79+
key: sccache-sanitizer-ubuntu-${{ github.run_id }}
5880
- name: Run Tests
5981
working-directory: build
6082
env:

.github/workflows/sql_catalog_test.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ jobs:
6161
runs-on: windows-2025
6262
cmake_build_type: Release
6363
cmake_extra_args: -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
64+
env:
65+
SCCACHE_DIR: ${{ github.workspace }}/.sccache
66+
SCCACHE_CACHE_SIZE: "2G"
6467
steps:
6568
- name: Checkout iceberg-cpp
6669
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
@@ -92,6 +95,15 @@ jobs:
9295
shell: pwsh
9396
run: |
9497
vcpkg install zlib:x64-windows nlohmann-json:x64-windows nanoarrow:x64-windows roaring:x64-windows sqlite3:x64-windows
98+
- name: Restore sccache cache
99+
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
100+
with:
101+
path: ${{ github.workspace }}/.sccache
102+
key: sccache-sqlcatalog-${{ matrix.runs-on }}-${{ github.run_id }}
103+
restore-keys: |
104+
sccache-sqlcatalog-${{ matrix.runs-on }}-
105+
- name: Setup sccache
106+
uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10
95107
- name: Configure Iceberg
96108
shell: bash
97109
run: |
@@ -103,10 +115,21 @@ jobs:
103115
-DICEBERG_BUILD_REST=OFF \
104116
-DICEBERG_BUILD_SQL_CATALOG=ON \
105117
-DICEBERG_SQL_SQLITE=ON \
118+
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
119+
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
106120
${{ matrix.cmake_extra_args }}
107121
- name: Build SQL catalog tests
108122
shell: bash
109123
run: cmake --build build --target sql_catalog_test
124+
- name: Show sccache stats
125+
shell: bash
126+
run: sccache --show-stats
127+
- name: Save sccache cache
128+
if: github.ref == 'refs/heads/main'
129+
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
130+
with:
131+
path: ${{ github.workspace }}/.sccache
132+
key: sccache-sqlcatalog-${{ matrix.runs-on }}-${{ github.run_id }}
110133
- name: Run SQL catalog tests
111134
shell: bash
112135
run: ctest --test-dir build -R '^sql_catalog_test$' --output-on-failure -C ${{ matrix.cmake_build_type }}

.github/workflows/test.yml

Lines changed: 81 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ jobs:
4545
timeout-minutes: 30
4646
strategy:
4747
fail-fast: false
48+
env:
49+
SCCACHE_DIR: ${{ github.workspace }}/.sccache
50+
SCCACHE_CACHE_SIZE: "2G"
4851
steps:
4952
- name: Checkout iceberg-cpp
5053
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
@@ -53,12 +56,30 @@ jobs:
5356
- name: Install dependencies
5457
shell: bash
5558
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
59+
- name: Restore sccache cache
60+
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
61+
with:
62+
path: ${{ github.workspace }}/.sccache
63+
key: sccache-test-ubuntu-${{ github.run_id }}
64+
restore-keys: |
65+
sccache-test-ubuntu-
66+
- name: Setup sccache
67+
uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10
5668
- name: Build Iceberg
5769
shell: bash
5870
env:
5971
CC: gcc-14
6072
CXX: g++-14
61-
run: ci/scripts/build_iceberg.sh $(pwd) ON
73+
run: ci/scripts/build_iceberg.sh $(pwd) ON ON
74+
- name: Show sccache stats
75+
shell: bash
76+
run: sccache --show-stats
77+
- name: Save sccache cache
78+
if: github.ref == 'refs/heads/main'
79+
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
80+
with:
81+
path: ${{ github.workspace }}/.sccache
82+
key: sccache-test-ubuntu-${{ github.run_id }}
6283
- name: Build Example
6384
shell: bash
6485
env:
@@ -72,14 +93,35 @@ jobs:
7293
timeout-minutes: 30
7394
strategy:
7495
fail-fast: false
96+
env:
97+
SCCACHE_DIR: ${{ github.workspace }}/.sccache
98+
SCCACHE_CACHE_SIZE: "2G"
7599
steps:
76100
- name: Checkout iceberg-cpp
77101
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
78102
with:
79103
persist-credentials: false
104+
- name: Restore sccache cache
105+
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
106+
with:
107+
path: ${{ github.workspace }}/.sccache
108+
key: sccache-test-macos-${{ github.run_id }}
109+
restore-keys: |
110+
sccache-test-macos-
111+
- name: Setup sccache
112+
uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10
80113
- name: Build Iceberg
81114
shell: bash
82-
run: ci/scripts/build_iceberg.sh $(pwd)
115+
run: ci/scripts/build_iceberg.sh $(pwd) OFF ON
116+
- name: Show sccache stats
117+
shell: bash
118+
run: sccache --show-stats
119+
- name: Save sccache cache
120+
if: github.ref == 'refs/heads/main'
121+
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
122+
with:
123+
path: ${{ github.workspace }}/.sccache
124+
key: sccache-test-macos-${{ github.run_id }}
83125
- name: Build Example
84126
shell: bash
85127
run: ci/scripts/build_example.sh $(pwd)/example
@@ -90,6 +132,9 @@ jobs:
90132
timeout-minutes: 60
91133
strategy:
92134
fail-fast: false
135+
env:
136+
SCCACHE_DIR: ${{ github.workspace }}/.sccache
137+
SCCACHE_CACHE_SIZE: "2G"
93138
steps:
94139
- name: Checkout iceberg-cpp
95140
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
@@ -110,17 +155,28 @@ jobs:
110155
shell: pwsh
111156
run: |
112157
vcpkg install zlib:x64-windows nlohmann-json:x64-windows nanoarrow:x64-windows roaring:x64-windows cpr:x64-windows
158+
- name: Restore sccache cache
159+
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
160+
with:
161+
path: ${{ github.workspace }}/.sccache
162+
key: sccache-test-windows-${{ github.run_id }}
163+
restore-keys: |
164+
sccache-test-windows-
113165
- name: Setup sccache
114166
uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10
115167
- name: Build Iceberg
116168
shell: pwsh
117-
env:
118-
SCCACHE_GHA_ENABLED: "true"
119169
run: |
120170
$ErrorActionPreference = "Stop"
121171
bash -lc 'ci/scripts/build_iceberg.sh $(pwd) OFF ON'
122172
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
123173
sccache --show-stats
174+
- name: Save sccache cache
175+
if: github.ref == 'refs/heads/main'
176+
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
177+
with:
178+
path: ${{ github.workspace }}/.sccache
179+
key: sccache-test-windows-${{ github.run_id }}
124180
- name: Build Example
125181
shell: pwsh
126182
run: |
@@ -131,6 +187,9 @@ jobs:
131187
name: Meson - ${{ matrix.title }}
132188
runs-on: ${{ matrix.runs-on }}
133189
timeout-minutes: 30
190+
env:
191+
SCCACHE_DIR: ${{ github.workspace }}/.sccache
192+
SCCACHE_CACHE_SIZE: "2G"
134193
strategy:
135194
max-parallel: 15
136195
fail-fast: false
@@ -159,24 +218,34 @@ jobs:
159218
python3 -m pip install --upgrade pip
160219
python3 -m pip install -r requirements.txt
161220
- name: Set Ubuntu Compilers
221+
# Wrap the compiler with sccache: Meson auto-detects sccache for the
222+
# default compiler (macOS/Windows), but uses an explicit CC/CXX verbatim,
223+
# so the launcher must be prepended here to route Ubuntu compiles through it.
162224
if: ${{ startsWith(matrix.runs-on, 'ubuntu') }}
163225
run: |
164-
echo "CC=${{ matrix.CC }}" >> $GITHUB_ENV
165-
echo "CXX=${{ matrix.CXX }}" >> $GITHUB_ENV
226+
echo "CC=sccache ${{ matrix.CC }}" >> $GITHUB_ENV
227+
echo "CXX=sccache ${{ matrix.CXX }}" >> $GITHUB_ENV
228+
- name: Restore sccache cache
229+
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
230+
with:
231+
path: ${{ github.workspace }}/.sccache
232+
key: sccache-meson-${{ matrix.runs-on }}-${{ github.run_id }}
233+
restore-keys: |
234+
sccache-meson-${{ matrix.runs-on }}-
166235
- name: Setup sccache
167-
if: ${{ startsWith(matrix.runs-on, 'windows') }}
168236
uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10
169-
- name: Enable sccache
170-
if: ${{ startsWith(matrix.runs-on, 'windows') }}
171-
shell: bash
172-
run: echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
173237
- name: Build Iceberg
174238
run: |
175239
meson setup builddir ${{ matrix.meson-setup-args || '' }}
176240
meson compile -C builddir
177241
- name: Show sccache stats
178-
if: ${{ startsWith(matrix.runs-on, 'windows') }}
179242
run: sccache --show-stats
243+
- name: Save sccache cache
244+
if: github.ref == 'refs/heads/main'
245+
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
246+
with:
247+
path: ${{ github.workspace }}/.sccache
248+
key: sccache-meson-${{ matrix.runs-on }}-${{ github.run_id }}
180249
- name: Test Iceberg
181250
run: |
182251
meson test -C builddir --timeout-multiplier 0 --print-errorlogs

0 commit comments

Comments
 (0)