Skip to content

Commit 310b034

Browse files
committed
ci: add compiler cache to heavy workflows
1 parent 7f58219 commit 310b034

7 files changed

Lines changed: 151 additions & 4 deletions

File tree

.github/workflows/build-kuebikodb.yaml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
description: 'the build mode'
88
type: string
99
required: true
10+
enable_ccache:
11+
description: 'enable ccache for non-reproducibility builds'
12+
type: boolean
13+
default: true
1014
outputs:
1115
md5sum:
1216
description: 'the md5sum for the inherited database executable'
@@ -20,19 +24,55 @@ jobs:
2024
- read-toolchain
2125
runs-on: depot-ubuntu-24.04-8
2226
container: ${{ needs.read-toolchain.outputs.image }}
27+
env:
28+
CCACHE_DIR: ${{ github.workspace }}/.ccache
29+
CCACHE_MAXSIZE: 2G
30+
CCACHE_BASEDIR: ${{ github.workspace }}
31+
CCACHE_NOHASHDIR: true
2332
outputs:
2433
md5sum: ${{ steps.checksum.outputs.md5sum }}
2534
steps:
2635
- uses: actions/checkout@v4
2736
with:
2837
submodules: recursive
38+
- name: Install ccache
39+
if: ${{ inputs.enable_ccache }}
40+
run: |
41+
sudo dnf -y install ccache zstd
42+
- name: Restore ccache
43+
if: ${{ inputs.enable_ccache }}
44+
uses: actions/cache@v4
45+
with:
46+
path: ${{ env.CCACHE_DIR }}
47+
key: ccache-${{ runner.os }}-build-kuebikodb-${{ inputs.build_mode }}-${{ hashFiles('tools/toolchain/image', 'configure.py', 'CMakeLists.txt', 'cmake/**', '.gitmodules') }}-${{ github.run_id }}
48+
restore-keys: |
49+
ccache-${{ runner.os }}-build-kuebikodb-${{ inputs.build_mode }}-${{ hashFiles('tools/toolchain/image', 'configure.py', 'CMakeLists.txt', 'cmake/**', '.gitmodules') }}-
50+
ccache-${{ runner.os }}-build-kuebikodb-${{ inputs.build_mode }}-
51+
ccache-${{ runner.os }}-build-kuebikodb-
52+
- name: Configure ccache
53+
if: ${{ inputs.enable_ccache }}
54+
run: |
55+
mkdir -p "$CCACHE_DIR" "$GITHUB_WORKSPACE/.cache-wrappers"
56+
printf '#!/bin/sh\nexec ccache clang "$@"\n' > "$GITHUB_WORKSPACE/.cache-wrappers/clang"
57+
printf '#!/bin/sh\nexec ccache clang++ "$@"\n' > "$GITHUB_WORKSPACE/.cache-wrappers/clang++"
58+
chmod +x "$GITHUB_WORKSPACE/.cache-wrappers/clang" "$GITHUB_WORKSPACE/.cache-wrappers/clang++"
59+
ccache --max-size="$CCACHE_MAXSIZE"
60+
ccache --zero-stats
2961
- name: Generate the building system
3062
run: |
3163
git config --global --add safe.directory $GITHUB_WORKSPACE
32-
./configure.py --mode ${{ inputs.build_mode }} --with scylla
64+
if [ '${{ inputs.enable_ccache }}' = 'true' ]; then
65+
./configure.py --mode ${{ inputs.build_mode }} --with scylla --compiler "$GITHUB_WORKSPACE/.cache-wrappers/clang++" --c-compiler "$GITHUB_WORKSPACE/.cache-wrappers/clang"
66+
else
67+
./configure.py --mode ${{ inputs.build_mode }} --with scylla
68+
fi
3369
- run: |
3470
ninja build/${{ inputs.build_mode }}/scylla
3571
- id: checksum
3672
run: |
3773
checksum=$(md5sum build/${{ inputs.build_mode }}/scylla | cut -c -32)
3874
echo "md5sum=$checksum" >> $GITHUB_OUTPUT
75+
- name: Show ccache stats
76+
if: ${{ always() && inputs.enable_ccache }}
77+
run: |
78+
ccache --show-stats

.github/workflows/clang-nightly.yaml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ jobs:
2323
name: Build with clang nightly
2424
runs-on: depot-ubuntu-24.04-8
2525
container: fedora:40
26+
env:
27+
CCACHE_DIR: ${{ github.workspace }}/.ccache
28+
CCACHE_MAXSIZE: 2G
29+
CCACHE_BASEDIR: ${{ github.workspace }}
30+
CCACHE_NOHASHDIR: true
2631
strategy:
2732
matrix:
2833
build_type:
@@ -47,13 +52,29 @@ jobs:
4752
-e 's/(minio_download_jobs)/(true)/' \
4853
./install-dependencies.sh
4954
sudo ./install-dependencies.sh
50-
sudo dnf -y install lld
55+
sudo dnf -y install ccache lld zstd
56+
- name: Restore ccache
57+
uses: actions/cache@v4
58+
with:
59+
path: ${{ env.CCACHE_DIR }}
60+
key: ccache-${{ runner.os }}-clang-nightly-${{ env.CLANG_VERSION }}-${{ matrix.build_type }}-${{ hashFiles('configure.py', 'CMakeLists.txt', 'cmake/**', '.gitmodules') }}-${{ github.run_id }}
61+
restore-keys: |
62+
ccache-${{ runner.os }}-clang-nightly-${{ env.CLANG_VERSION }}-${{ matrix.build_type }}-${{ hashFiles('configure.py', 'CMakeLists.txt', 'cmake/**', '.gitmodules') }}-
63+
ccache-${{ runner.os }}-clang-nightly-${{ env.CLANG_VERSION }}-${{ matrix.build_type }}-
64+
ccache-${{ runner.os }}-clang-nightly-${{ env.CLANG_VERSION }}-
65+
- name: Configure ccache
66+
run: |
67+
mkdir -p "$CCACHE_DIR"
68+
ccache --max-size="$CCACHE_MAXSIZE"
69+
ccache --zero-stats
5170
- name: Generate the building system
5271
run: |
5372
cmake \
5473
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
5574
-DCMAKE_C_COMPILER=clang-$CLANG_VERSION \
75+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
5676
-DCMAKE_CXX_COMPILER=clang++-$CLANG_VERSION \
77+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
5778
-G Ninja \
5879
-B $BUILD_DIR \
5980
-S .
@@ -64,3 +85,7 @@ jobs:
6485
cmake --build $BUILD_DIR --target scylla
6586
- run: |
6687
echo "::remove-matcher owner=clang::"
88+
- name: Show ccache stats
89+
if: ${{ always() }}
90+
run: |
91+
ccache --show-stats

.github/workflows/clang-tidy.yaml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ jobs:
4141
- read-toolchain
4242
runs-on: depot-ubuntu-24.04-8
4343
container: ${{ needs.read-toolchain.outputs.image }}
44+
env:
45+
CCACHE_DIR: ${{ github.workspace }}/.ccache
46+
CCACHE_MAXSIZE: 2G
47+
CCACHE_BASEDIR: ${{ github.workspace }}
48+
CCACHE_NOHASHDIR: true
4449
steps:
4550
- env:
4651
IMAGE: ${{ needs.read-toolchain.image }}
@@ -50,14 +55,30 @@ jobs:
5055
with:
5156
submodules: true
5257
- run: |
53-
sudo dnf -y install clang-tools-extra
58+
sudo dnf -y install ccache clang-tools-extra zstd
59+
- name: Restore ccache
60+
uses: actions/cache@v4
61+
with:
62+
path: ${{ env.CCACHE_DIR }}
63+
key: ccache-${{ runner.os }}-clang-tidy-${{ env.BUILD_TYPE }}-${{ hashFiles('tools/toolchain/image', 'configure.py', 'CMakeLists.txt', 'cmake/**', '.gitmodules') }}-${{ github.run_id }}
64+
restore-keys: |
65+
ccache-${{ runner.os }}-clang-tidy-${{ env.BUILD_TYPE }}-${{ hashFiles('tools/toolchain/image', 'configure.py', 'CMakeLists.txt', 'cmake/**', '.gitmodules') }}-
66+
ccache-${{ runner.os }}-clang-tidy-${{ env.BUILD_TYPE }}-
67+
ccache-${{ runner.os }}-clang-tidy-
68+
- name: Configure ccache
69+
run: |
70+
mkdir -p "$CCACHE_DIR"
71+
ccache --max-size="$CCACHE_MAXSIZE"
72+
ccache --zero-stats
5473
- name: Generate the building system
5574
run: |
5675
cmake \
5776
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
5877
-DCMAKE_C_COMPILER=clang \
78+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
5979
-DScylla_USE_LINKER=ld.lld \
6080
-DCMAKE_CXX_COMPILER=clang++ \
81+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
6182
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
6283
-DCMAKE_CXX_CLANG_TIDY="clang-tidy;--checks=$CLANG_TIDY_CHECKS" \
6384
-G Ninja \
@@ -71,3 +92,7 @@ jobs:
7192
cmake --build $BUILD_DIR --target scylla
7293
- run: |
7394
echo "::remove-matcher owner=clang::"
95+
- name: Show ccache stats
96+
if: ${{ always() }}
97+
run: |
98+
ccache --show-stats

.github/workflows/iwyu.yaml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,39 @@ jobs:
3737
- read-toolchain
3838
runs-on: depot-ubuntu-24.04-8
3939
container: ${{ needs.read-toolchain.outputs.image }}
40+
env:
41+
CCACHE_DIR: ${{ github.workspace }}/.ccache
42+
CCACHE_MAXSIZE: 2G
43+
CCACHE_BASEDIR: ${{ github.workspace }}
44+
CCACHE_NOHASHDIR: true
4045
steps:
4146
- uses: actions/checkout@v4
4247
with:
4348
submodules: true
4449
- run: |
45-
sudo dnf -y install clang-tools-extra
50+
sudo dnf -y install ccache clang-tools-extra zstd
51+
- name: Restore ccache
52+
uses: actions/cache@v4
53+
with:
54+
path: ${{ env.CCACHE_DIR }}
55+
key: ccache-${{ runner.os }}-iwyu-${{ env.BUILD_TYPE }}-${{ hashFiles('tools/toolchain/image', 'configure.py', 'CMakeLists.txt', 'cmake/**', '.gitmodules') }}-${{ github.run_id }}
56+
restore-keys: |
57+
ccache-${{ runner.os }}-iwyu-${{ env.BUILD_TYPE }}-${{ hashFiles('tools/toolchain/image', 'configure.py', 'CMakeLists.txt', 'cmake/**', '.gitmodules') }}-
58+
ccache-${{ runner.os }}-iwyu-${{ env.BUILD_TYPE }}-
59+
ccache-${{ runner.os }}-iwyu-
60+
- name: Configure ccache
61+
run: |
62+
mkdir -p "$CCACHE_DIR"
63+
ccache --max-size="$CCACHE_MAXSIZE"
64+
ccache --zero-stats
4665
- name: Generate compilation database
4766
run: |
4867
cmake \
4968
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
5069
-DCMAKE_C_COMPILER=clang \
70+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
5171
-DCMAKE_CXX_COMPILER=clang++ \
72+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
5273
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
5374
-G Ninja \
5475
-B $BUILD_DIR \
@@ -88,3 +109,7 @@ jobs:
88109
with:
89110
name: Logs (clang-include-cleaner)
90111
path: "./${{ env.CLEANER_OUTPUT_PATH }}"
112+
- name: Show ccache stats
113+
if: ${{ always() }}
114+
run: |
115+
ccache --show-stats

.github/workflows/reproducible-build.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ jobs:
1515
uses: ./.github/workflows/build-kuebikodb.yaml
1616
with:
1717
build_mode: release
18+
enable_ccache: false
1819
build-b:
1920
uses: ./.github/workflows/build-kuebikodb.yaml
2021
with:
2122
build_mode: release
23+
enable_ccache: false
2224
compare-checksum:
2325
runs-on: depot-ubuntu-24.04
2426
needs:

.github/workflows/seastar.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ jobs:
2020
runs-on: depot-ubuntu-24.04-8
2121
# be consistent with tools/toolchain/image
2222
container: scylladb/scylla-toolchain:fedora-40-20240621
23+
env:
24+
CCACHE_DIR: ${{ github.workspace }}/.ccache
25+
CCACHE_MAXSIZE: 2G
26+
CCACHE_BASEDIR: ${{ github.workspace }}
27+
CCACHE_NOHASHDIR: true
2328
strategy:
2429
matrix:
2530
build_type:
@@ -37,15 +42,38 @@ jobs:
3742
repository: scylladb/seastar
3843
submodules: true
3944
path: seastar
45+
- name: Install ccache
46+
run: |
47+
sudo dnf -y install ccache zstd
48+
- name: Restore ccache
49+
uses: actions/cache@v4
50+
with:
51+
path: ${{ env.CCACHE_DIR }}
52+
key: ccache-${{ runner.os }}-latest-seastar-${{ matrix.build_type }}-${{ hashFiles('tools/toolchain/image', 'configure.py', 'CMakeLists.txt', 'cmake/**', '.gitmodules') }}-${{ github.run_id }}
53+
restore-keys: |
54+
ccache-${{ runner.os }}-latest-seastar-${{ matrix.build_type }}-${{ hashFiles('tools/toolchain/image', 'configure.py', 'CMakeLists.txt', 'cmake/**', '.gitmodules') }}-
55+
ccache-${{ runner.os }}-latest-seastar-${{ matrix.build_type }}-
56+
ccache-${{ runner.os }}-latest-seastar-
57+
- name: Configure ccache
58+
run: |
59+
mkdir -p "$CCACHE_DIR"
60+
ccache --max-size="$CCACHE_MAXSIZE"
61+
ccache --zero-stats
4062
- name: Generate the building system
4163
run: |
4264
git config --global --add safe.directory $GITHUB_WORKSPACE
4365
cmake \
4466
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
4567
-DCMAKE_C_COMPILER=clang \
68+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
4669
-DCMAKE_CXX_COMPILER=clang++ \
70+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
4771
-G Ninja \
4872
-B $BUILD_DIR \
4973
-S .
5074
- run: |
5175
cmake --build $BUILD_DIR --target scylla
76+
- name: Show ccache stats
77+
if: ${{ always() }}
78+
run: |
79+
ccache --show-stats

docs/ci/workflow-audit.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,7 @@ changes, and which should be removed.
5858

5959
- Full inherited C++ builds and C++ source-analysis builds use
6060
`depot-ubuntu-24.04-8` so build parallelism has enough CPU.
61+
- Heavy non-reproducibility builds use `ccache` with GitHub Actions cache.
62+
Reproducible builds disable compiler caching to preserve a clean comparison.
6163
- Lightweight validation, relicensing, Rust, Nix, submodule, and reusable
6264
metadata jobs use `depot-ubuntu-24.04`.

0 commit comments

Comments
 (0)