Skip to content

Commit f23cfbb

Browse files
Andrew Kriegerakrieger
Andrew Krieger
authored andcommitted
Use ccache --evict-older-than for more accurate and leaner ccaches.
1 parent e384df8 commit f23cfbb

File tree

5 files changed

+35
-13
lines changed

5 files changed

+35
-13
lines changed

.github/workflows/emscripten.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
id: get-vars
3030
run: |
3131
echo "datetime=$(/bin/date -u "+%Y%m%d%H%M")" >> $GITHUB_OUTPUT
32+
echo "datetime-seconds=$(/bin/date +%s)" >> $GITHUB_OUTPUT
3233
echo "ccache-path=$(echo '~/.cache/ccache')" >> $GITHUB_OUTPUT
3334
3435
- name: ccache cache files
@@ -53,7 +54,7 @@ jobs:
5354
export EM_CONFIG=$EMSDK/.emscripten
5455
export CCACHE_COMPILERCHECK=string:3.1.51
5556
ccache --zero-stats
56-
ccache -M 5G
57+
ccache -M 20G
5758
ccache --show-stats
5859
5960
./build-scripts/build-emscripten.sh
@@ -63,7 +64,11 @@ jobs:
6364
emsdk activate ccache-git-emscripten-64bit
6465
export PATH="${PATH%%:*}/../../ccache/git-emscripten_64bit/bin":$PATH
6566
ccache --show-stats
66-
ccache -M 5G
67+
NOW=`/bin/date +%s`
68+
DELTA=$(( $NOW - ${{ steps.get-vars.outputs.datetime-seconds }} ))
69+
ccache --evict-older-than ${DELTA}s
70+
ccache --show-stats
71+
ccache -M 1G
6772
ccache -c
6873
ccache --show-stats
6974

.github/workflows/matrix.yml

+15-9
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
dont_skip_data_only_changes: 1
9595
mods: --mods=magiclysm
9696
title: Basic Build and Test (Clang 10, Ubuntu, Curses)
97-
ccache_limit: 5G
97+
ccache_limit: 4.5G
9898
ccache_key: linux-llvm-10-break1
9999

100100
- compiler: clang++
@@ -106,7 +106,7 @@ jobs:
106106
sound: 1
107107
localize: 1
108108
title: Clang 14, macOS 12, Tiles, Sound, x64 and arm64 Universal Binary
109-
ccache_limit: 6G
109+
ccache_limit: 10G
110110
ccache_key: macos-llvm-14-universal-break1
111111

112112
- compiler: g++-9
@@ -122,7 +122,7 @@ jobs:
122122
pch: 1
123123
cxxflags: -gsplit-dwarf
124124
title: GCC 9, Curses, LTO
125-
ccache_limit: 4.5G
125+
ccache_limit: 7.5G
126126
ccache_key: linux-gcc-9-lto
127127

128128
- compiler: clang++-12
@@ -137,7 +137,7 @@ jobs:
137137
cxxflags: --gcc-toolchain=/opt/mock-gcc-11
138138
dont_skip_data_only_changes: 1
139139
title: Clang 12, Ubuntu, Tiles, ASan
140-
ccache_limit: 4.5G
140+
ccache_limit: 6G
141141
ccache_key: linux-llvm-12-asan
142142

143143
- compiler: g++-11
@@ -150,7 +150,7 @@ jobs:
150150
pch: 1
151151
sanitize: address
152152
title: GCC 11, Ubuntu, Curses, ASan
153-
ccache_limit: 6G
153+
ccache_limit: 6.5G
154154
ccache_key: linux-gcc-11-asan
155155

156156
- compiler: g++-9
@@ -162,7 +162,7 @@ jobs:
162162
native: linux64
163163
pch: 1
164164
title: GCC 9, Ubuntu, Tiles, Sound, CMake
165-
ccache_limit: 3G
165+
ccache_limit: 1G
166166
ccache_key: linux-gcc-9-cmake
167167

168168
name: ${{ matrix.title }}
@@ -221,11 +221,12 @@ jobs:
221221
if: ${{ env.SKIP == 'false' && runner.os == 'Linux' && matrix.tiles == 1 }}
222222
run: |
223223
sudo apt-get install libflac-dev libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev libpulse-dev
224-
- name: install recent ccache on ubuntu 20.04
225-
if: ${{ env.SKIP == 'false' && runner.os == 'Linux' && matrix.os == 'ubuntu-20.04' }}
224+
- name: install recent ccache on ubuntu
225+
if: ${{ env.SKIP == 'false' && runner.os == 'Linux' }}
226226
run: |
227+
ccache --version
227228
sudo apt-get remove --purge -y ccache
228-
curl -sL https://github.com/ccache/ccache/releases/download/v4.8.3/ccache-4.8.3-linux-x86_64.tar.xz | sudo tar Jxvf - --strip-components 1 -C /usr/bin ccache-4.8.3-linux-x86_64/ccache
229+
curl -sL https://github.com/ccache/ccache/releases/download/v4.10.2/ccache-4.10.2-linux-x86_64.tar.xz | sudo tar Jxvf - --strip-components 1 -C /usr/bin ccache-4.10.2-linux-x86_64/ccache
229230
ccache --version
230231
- name: install Clang 12 (Ubuntu)
231232
if: ${{ env.SKIP == 'false' && runner.os == 'Linux' && (matrix.compiler == 'clang++-12') }}
@@ -264,6 +265,7 @@ jobs:
264265
if: ${{ env.SKIP == 'false' }}
265266
run: |
266267
echo "datetime=$(/bin/date -u "+%Y%m%d%H%M")" >> $GITHUB_OUTPUT
268+
echo "datetime-seconds=$(/bin/date +%s)" >> $GITHUB_OUTPUT
267269
echo "ccache-path=$([ "$RUNNER_OS" = "macOS" ] && echo '/Users/runner/Library/Caches/ccache' || echo '~/.cache/ccache')" >> $GITHUB_OUTPUT
268270
shell: bash
269271
- name: ccache cache files
@@ -282,6 +284,10 @@ jobs:
282284
- name: post-build ccache manipulation
283285
if: ${{ env.SKIP == 'false' && !failure() && (runner.os == 'Linux' || runner.os == 'macOS') }}
284286
run: |
287+
ccache --show-stats --verbose
288+
NOW=`/bin/date +%s`
289+
DELTA=$(( $NOW - ${{ steps.get-vars.outputs.datetime-seconds }} ))
290+
ccache --evict-older-than ${DELTA}s
285291
ccache --show-stats --verbose
286292
ccache -M ${{ env.CCACHE_LIMIT }}
287293
ccache -c

.github/workflows/msvc-full-features.yml

+11
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ jobs:
111111
id: get-vars
112112
run: |
113113
echo "datetime=$(/bin/date -u "+%Y%m%d%H%M")" >> $GITHUB_OUTPUT
114+
echo "datetime-seconds=$(/bin/date +%s)" >> $GITHUB_OUTPUT
114115
echo "ccache-path=$(echo "$APPDATA\\ccache")" >> $GITHUB_OUTPUT
115116
shell: bash
116117

@@ -138,9 +139,19 @@ jobs:
138139
run: |
139140
msbuild -m -p:Configuration=Release -p:Platform=x64 "-target:Cataclysm-vcpkg-static;Cataclysm-test-vcpkg-static;JsonFormatter-vcpkg-static" msvc-full-features/Cataclysm-vcpkg-static.sln
140141
142+
- name: Get ccache cache age cutoff
143+
id: get-cache-age
144+
run: |
145+
NOW=`/bin/date +%s`
146+
DELTA=$(( $NOW - ${{ steps.get-vars.outputs.datetime-seconds }} ))
147+
echo "ccache-age=$(( $NOW - ${{ steps.get-vars.outputs.datetime-seconds }} ))" >> $GITHUB_OUTPUT
148+
shell: bash
149+
141150
- name: Post-build ccache manipulation
142151
if: ${{ !failure() }}
143152
run: |
153+
${{ env.CDDA_CCACHE_PATH }}\ccache.exe -s -v
154+
${{ env.CDDA_CCACHE_PATH }}\ccache.exe --evict-older-than ${{ steps.get-ccache-age.outputs.ccache-age }}
144155
${{ env.CDDA_CCACHE_PATH }}\ccache.exe -s -v
145156
${{ env.CDDA_CCACHE_PATH }}\ccache.exe -M ${{ env.CCACHE_LIMIT }}
146157
${{ env.CDDA_CCACHE_PATH }}\ccache.exe -c

build-scripts/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fi
4040

4141
ccache --zero-stats
4242
# Increase cache size because debug builds generate large object files
43-
ccache -M 10G
43+
ccache -M 20G
4444
ccache --show-stats --verbose
4545

4646
function run_test

build-scripts/gha_compile_only.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fi
4040

4141
ccache --zero-stats
4242
# Increase cache size because debug builds generate large object files
43-
ccache -M 10G
43+
ccache -M 20G
4444
ccache --show-stats --verbose
4545

4646
if [ "$CMAKE" = "1" ]

0 commit comments

Comments
 (0)