Skip to content

Commit

Permalink
Merge pull request #78743 from akrieger/ccache_is_ace
Browse files Browse the repository at this point in the history
Use ccache --evict-older-than for more accurate and leaner ccaches.
  • Loading branch information
kevingranade authored Dec 24, 2024
2 parents e384df8 + f23cfbb commit 44f913f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 13 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/emscripten.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
id: get-vars
run: |
echo "datetime=$(/bin/date -u "+%Y%m%d%H%M")" >> $GITHUB_OUTPUT
echo "datetime-seconds=$(/bin/date +%s)" >> $GITHUB_OUTPUT
echo "ccache-path=$(echo '~/.cache/ccache')" >> $GITHUB_OUTPUT
- name: ccache cache files
Expand All @@ -53,7 +54,7 @@ jobs:
export EM_CONFIG=$EMSDK/.emscripten
export CCACHE_COMPILERCHECK=string:3.1.51
ccache --zero-stats
ccache -M 5G
ccache -M 20G
ccache --show-stats
./build-scripts/build-emscripten.sh
Expand All @@ -63,7 +64,11 @@ jobs:
emsdk activate ccache-git-emscripten-64bit
export PATH="${PATH%%:*}/../../ccache/git-emscripten_64bit/bin":$PATH
ccache --show-stats
ccache -M 5G
NOW=`/bin/date +%s`
DELTA=$(( $NOW - ${{ steps.get-vars.outputs.datetime-seconds }} ))
ccache --evict-older-than ${DELTA}s
ccache --show-stats
ccache -M 1G
ccache -c
ccache --show-stats
Expand Down
24 changes: 15 additions & 9 deletions .github/workflows/matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
dont_skip_data_only_changes: 1
mods: --mods=magiclysm
title: Basic Build and Test (Clang 10, Ubuntu, Curses)
ccache_limit: 5G
ccache_limit: 4.5G
ccache_key: linux-llvm-10-break1

- compiler: clang++
Expand All @@ -106,7 +106,7 @@ jobs:
sound: 1
localize: 1
title: Clang 14, macOS 12, Tiles, Sound, x64 and arm64 Universal Binary
ccache_limit: 6G
ccache_limit: 10G
ccache_key: macos-llvm-14-universal-break1

- compiler: g++-9
Expand All @@ -122,7 +122,7 @@ jobs:
pch: 1
cxxflags: -gsplit-dwarf
title: GCC 9, Curses, LTO
ccache_limit: 4.5G
ccache_limit: 7.5G
ccache_key: linux-gcc-9-lto

- compiler: clang++-12
Expand All @@ -137,7 +137,7 @@ jobs:
cxxflags: --gcc-toolchain=/opt/mock-gcc-11
dont_skip_data_only_changes: 1
title: Clang 12, Ubuntu, Tiles, ASan
ccache_limit: 4.5G
ccache_limit: 6G
ccache_key: linux-llvm-12-asan

- compiler: g++-11
Expand All @@ -150,7 +150,7 @@ jobs:
pch: 1
sanitize: address
title: GCC 11, Ubuntu, Curses, ASan
ccache_limit: 6G
ccache_limit: 6.5G
ccache_key: linux-gcc-11-asan

- compiler: g++-9
Expand All @@ -162,7 +162,7 @@ jobs:
native: linux64
pch: 1
title: GCC 9, Ubuntu, Tiles, Sound, CMake
ccache_limit: 3G
ccache_limit: 1G
ccache_key: linux-gcc-9-cmake

name: ${{ matrix.title }}
Expand Down Expand Up @@ -221,11 +221,12 @@ jobs:
if: ${{ env.SKIP == 'false' && runner.os == 'Linux' && matrix.tiles == 1 }}
run: |
sudo apt-get install libflac-dev libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev libpulse-dev
- name: install recent ccache on ubuntu 20.04
if: ${{ env.SKIP == 'false' && runner.os == 'Linux' && matrix.os == 'ubuntu-20.04' }}
- name: install recent ccache on ubuntu
if: ${{ env.SKIP == 'false' && runner.os == 'Linux' }}
run: |
ccache --version
sudo apt-get remove --purge -y ccache
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
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
ccache --version
- name: install Clang 12 (Ubuntu)
if: ${{ env.SKIP == 'false' && runner.os == 'Linux' && (matrix.compiler == 'clang++-12') }}
Expand Down Expand Up @@ -264,6 +265,7 @@ jobs:
if: ${{ env.SKIP == 'false' }}
run: |
echo "datetime=$(/bin/date -u "+%Y%m%d%H%M")" >> $GITHUB_OUTPUT
echo "datetime-seconds=$(/bin/date +%s)" >> $GITHUB_OUTPUT
echo "ccache-path=$([ "$RUNNER_OS" = "macOS" ] && echo '/Users/runner/Library/Caches/ccache' || echo '~/.cache/ccache')" >> $GITHUB_OUTPUT
shell: bash
- name: ccache cache files
Expand All @@ -282,6 +284,10 @@ jobs:
- name: post-build ccache manipulation
if: ${{ env.SKIP == 'false' && !failure() && (runner.os == 'Linux' || runner.os == 'macOS') }}
run: |
ccache --show-stats --verbose
NOW=`/bin/date +%s`
DELTA=$(( $NOW - ${{ steps.get-vars.outputs.datetime-seconds }} ))
ccache --evict-older-than ${DELTA}s
ccache --show-stats --verbose
ccache -M ${{ env.CCACHE_LIMIT }}
ccache -c
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/msvc-full-features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ jobs:
id: get-vars
run: |
echo "datetime=$(/bin/date -u "+%Y%m%d%H%M")" >> $GITHUB_OUTPUT
echo "datetime-seconds=$(/bin/date +%s)" >> $GITHUB_OUTPUT
echo "ccache-path=$(echo "$APPDATA\\ccache")" >> $GITHUB_OUTPUT
shell: bash

Expand Down Expand Up @@ -138,9 +139,19 @@ jobs:
run: |
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
- name: Get ccache cache age cutoff
id: get-cache-age
run: |
NOW=`/bin/date +%s`
DELTA=$(( $NOW - ${{ steps.get-vars.outputs.datetime-seconds }} ))
echo "ccache-age=$(( $NOW - ${{ steps.get-vars.outputs.datetime-seconds }} ))" >> $GITHUB_OUTPUT
shell: bash

- name: Post-build ccache manipulation
if: ${{ !failure() }}
run: |
${{ env.CDDA_CCACHE_PATH }}\ccache.exe -s -v
${{ env.CDDA_CCACHE_PATH }}\ccache.exe --evict-older-than ${{ steps.get-ccache-age.outputs.ccache-age }}
${{ env.CDDA_CCACHE_PATH }}\ccache.exe -s -v
${{ env.CDDA_CCACHE_PATH }}\ccache.exe -M ${{ env.CCACHE_LIMIT }}
${{ env.CDDA_CCACHE_PATH }}\ccache.exe -c
Expand Down
2 changes: 1 addition & 1 deletion build-scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fi

ccache --zero-stats
# Increase cache size because debug builds generate large object files
ccache -M 10G
ccache -M 20G
ccache --show-stats --verbose

function run_test
Expand Down
2 changes: 1 addition & 1 deletion build-scripts/gha_compile_only.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fi

ccache --zero-stats
# Increase cache size because debug builds generate large object files
ccache -M 10G
ccache -M 20G
ccache --show-stats --verbose

if [ "$CMAKE" = "1" ]
Expand Down

0 comments on commit 44f913f

Please sign in to comment.