CI: Improve ccache handling in build and test jobs
Cache key isolation: Include the build flavour (ccwarn/asan/gcov) in the build ccache key, so the coverage (gcov), asan, and RTLMeter (ccwarn-off) configurations no longer share and thrash the single '<runs-on>-<cc>' bucket, nor warm-start from each other's (near-useless) caches. Prune stale entries instead of a fixed size cap: After building/testing, evict ccache entries this run did not touch (--evict-older-than, based on the run's own duration). This bounds the saved cache to the current working set, so CCACHE_MAXSIZE and CCACHE_LIMIT_MULTIPLE are no longer needed and are removed (ccache falls back to its 5G default ceiling, but is realistically much smaller). ccache configuration: - Drop CCACHE_COMPRESS (already the default in ccache 4.x). - Add CCACHE_COMPILERCHECK=content, so a changed compiler mtime on a rebuilt ephemeral runner image does not invalidate the whole restored cache. - Hoist all ccache-related variables (CACHE_BASE_KEY, CCACHE_*, CXX) to the workflow-level env. Remove dead ccache scaffolding: - reusable-lint-py: the job never compiles or caches; drop its ccache env. - reusable-rtlmeter-run: remove the disabled persistent-cache step and its storage variables; keep CCACHE_DISABLE=1, since caching must stay off to keep RTLMeter timings representative.
This commit is contained in:
parent
8b564f509b
commit
a7119ad451
|
|
@ -45,9 +45,9 @@ on:
|
|||
value: ${{ jobs.build.outputs.archive }}
|
||||
|
||||
env:
|
||||
CCACHE_COMPRESS: 1
|
||||
CACHE_BASE_KEY: build-${{ inputs.runs-on }}-${{ inputs.cc }}${{ inputs.ccwarn && '-ccwarn' || '' }}${{ inputs.dev-asan && '-asan' || '' }}${{ inputs.dev-gcov && '-gcov' || '' }}
|
||||
CCACHE_COMPILERCHECK: content
|
||||
CCACHE_DIR: ${{ github.workspace }}/.ccache
|
||||
CCACHE_LIMIT_MULTIPLE: 0.95
|
||||
|
||||
defaults:
|
||||
run:
|
||||
|
|
@ -61,9 +61,6 @@ jobs:
|
|||
runs-on: ${{ inputs.runs-on }}
|
||||
outputs:
|
||||
archive: ${{ steps.create-archive.outputs.archive }}
|
||||
env:
|
||||
CACHE_BASE_KEY: build-${{ inputs.runs-on }}-${{ inputs.cc }}
|
||||
CCACHE_MAXSIZE: 1000M
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
||||
|
|
@ -74,7 +71,13 @@ jobs:
|
|||
# behind 'verilator --version'
|
||||
fetch-depth: ${{ (inputs.install || inputs.dev-gcov) && '0' || '1' }}
|
||||
|
||||
# ccache is unreliable on the macOS runners; disable it there
|
||||
- name: Disable ccache on macOS
|
||||
if: ${{ startsWith(inputs.runs-on, 'macos') }}
|
||||
run: echo "CCACHE_DISABLE=1" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Cache $CCACHE_DIR
|
||||
if: ${{ env.CCACHE_DISABLE != '1' }}
|
||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
|
||||
env:
|
||||
CACHE_KEY: ${{ env.CACHE_BASE_KEY }}-ccache
|
||||
|
|
@ -82,7 +85,7 @@ jobs:
|
|||
path: ${{ env.CCACHE_DIR }}
|
||||
key: ${{ env.CACHE_KEY }}-${{ inputs.sha }}
|
||||
restore-keys: |
|
||||
${{ env.CACHE_KEY }}-
|
||||
${{ env.CACHE_KEY }}
|
||||
|
||||
- name: Install packages for build
|
||||
run: ./ci/ci-install.bash build
|
||||
|
|
|
|||
|
|
@ -7,11 +7,6 @@ name: reusable-lint-py
|
|||
on:
|
||||
workflow_call:
|
||||
|
||||
env:
|
||||
CCACHE_COMPRESS: 1
|
||||
CCACHE_DIR: ${{ github.workspace }}/.ccache
|
||||
CCACHE_LIMIT_MULTIPLE: 0.95
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ defaults:
|
|||
shell: bash
|
||||
|
||||
env:
|
||||
CCACHE_DIR: ${{ github.workspace }}/ccache
|
||||
CCACHE_MAXSIZE: 512M
|
||||
# RTLMeter measures compile/execute times, so caching must stay off to keep
|
||||
# timings representative; ccache is still on PATH but acts as a pass-through
|
||||
CCACHE_DISABLE: 1
|
||||
|
||||
jobs:
|
||||
|
|
@ -82,14 +82,6 @@ jobs:
|
|||
working-directory: rtlmeter
|
||||
run: make venv
|
||||
|
||||
- name: Use saved ccache
|
||||
if: ${{ env.CCACHE_DISABLE == 0 }}
|
||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
|
||||
with:
|
||||
path: ${{ env.CCACHE_DIR }}
|
||||
key: rtlmeter-run-ccache-${{ inputs.runs-on }}-${{ inputs.cc }}-${{ inputs.cases }}-${{ inputs.compileArgs }}-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
restore-keys: rtlmeter-run-ccache-${{ inputs.runs-on }}-${{ inputs.cc }}-${{ inputs.cases }}-${{ inputs.compileArgs }}
|
||||
|
||||
########################################################################
|
||||
# Run with new Verilator
|
||||
########################################################################
|
||||
|
|
|
|||
|
|
@ -35,9 +35,10 @@ on:
|
|||
type: string
|
||||
|
||||
env:
|
||||
CCACHE_COMPRESS: 1
|
||||
CACHE_BASE_KEY: test-${{ inputs.runs-on }}-${{ inputs.cc }}-${{ inputs.suite }}
|
||||
CCACHE_COMPILERCHECK: content
|
||||
CCACHE_DIR: ${{ github.workspace }}/.ccache
|
||||
CCACHE_LIMIT_MULTIPLE: 0.95
|
||||
CXX: ${{ inputs.cc == 'clang' && 'clang++' || 'g++' }}
|
||||
|
||||
defaults:
|
||||
run:
|
||||
|
|
@ -49,10 +50,6 @@ jobs:
|
|||
test:
|
||||
runs-on: ${{ inputs.runs-on }}
|
||||
name: Test
|
||||
env:
|
||||
CXX: ${{ inputs.cc == 'clang' && 'clang++' || 'g++' }}
|
||||
CACHE_BASE_KEY: test-${{ inputs.runs-on }}-${{ inputs.cc }}-${{ inputs.reloc }}-${{ inputs.suite }}
|
||||
CCACHE_MAXSIZE: 100M # Per build per suite (* 5 * 5 = 2500M in total)
|
||||
steps:
|
||||
|
||||
- name: Download repository archive
|
||||
|
|
@ -70,12 +67,12 @@ jobs:
|
|||
- name: Cache $CCACHE_DIR
|
||||
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
|
||||
env:
|
||||
CACHE_KEY: ${{ env.CACHE_BASE_KEY }}-ccache2
|
||||
CACHE_KEY: ${{ env.CACHE_BASE_KEY }}-ccache
|
||||
with:
|
||||
path: ${{ env.CCACHE_DIR }}
|
||||
key: ${{ env.CACHE_KEY }}-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ env.CACHE_KEY }}-
|
||||
${{ env.CACHE_KEY }}
|
||||
|
||||
- name: Install test dependencies
|
||||
run: |
|
||||
|
|
|
|||
|
|
@ -78,5 +78,8 @@ autoconf
|
|||
# Build
|
||||
|
||||
ccache -z
|
||||
BUILD_START=$SECONDS
|
||||
"$MAKE" -j "$NPROC" -k
|
||||
ccache -svv
|
||||
ccache --evict-older-than "$((SECONDS - BUILD_START + 60))s"
|
||||
ccache -svv
|
||||
|
|
|
|||
|
|
@ -26,8 +26,6 @@ case "$(uname -s)" in
|
|||
HOST_OS=macOS
|
||||
MAKE=make
|
||||
NPROC=$(sysctl -n hw.logicalcpu)
|
||||
# Disable ccache, doesn't always work in GitHub Actions
|
||||
export OBJCACHE=
|
||||
;;
|
||||
*)
|
||||
fatal "Unknown host OS: '$(uname -s)'"
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ fi
|
|||
|
||||
# Run the specified suite
|
||||
ccache -z
|
||||
TEST_START=$SECONDS
|
||||
case $OPT_SUITE in
|
||||
dist-vlt-0)
|
||||
"$MAKE" -C "$TEST_REGRESS" SCENARIOS="--dist --vlt --driver-clean" DRIVER_HASHSET=--hashset=0/4
|
||||
|
|
@ -163,4 +164,6 @@ case $OPT_SUITE in
|
|||
;;
|
||||
esac
|
||||
ccache -svv
|
||||
ccache --evict-older-than "$((SECONDS - TEST_START + 60))s"
|
||||
ccache -svv
|
||||
uptime # To see load average
|
||||
|
|
|
|||
Loading…
Reference in New Issue