From 4bb422e76efa08f5aaca0ef1021dee291bee042e Mon Sep 17 00:00:00 2001 From: Guillaume Lagrange Date: Tue, 3 Nov 2026 16:41:07 +0100 Subject: [PATCH 1/2] ci: share one rust-cache entry per os across bpf-tests shards Each of the 40 bpf-tests jobs saved its own ~440 MB cache keyed by os and test binary, about 16 GB per run. That pushes the repository over its Actions cache quota and evicts entries within minutes, so later runs of the same PR rebuild from scratch. The shards build the same dependencies and rust-cache drops workspace crates, so key the cache by os only and let the c_tests shard save it. The install-rust action gains a save-cache input forwarded to rust-cache's save-if; other callers keep saving as before. Co-Authored-By: Claude --- .github/actions/install-rust/action.yml | 7 ++++++- .github/workflows/ci.yml | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/actions/install-rust/action.yml b/.github/actions/install-rust/action.yml index 517f27fbe..cd784332c 100644 --- a/.github/actions/install-rust/action.yml +++ b/.github/actions/install-rust/action.yml @@ -6,9 +6,13 @@ inputs: required: false default: "" cache-key: - description: Extra value appended to the rust-cache key, used to give matrix shards distinct caches and avoid concurrent save races. + description: Extra value appended to the rust-cache key, used to give matrix jobs distinct caches. required: false default: "" + save-cache: + description: Whether this job saves the rust-cache entry. Matrix jobs sharing a key should let only one of them save. + required: false + default: "true" runs: using: composite steps: @@ -22,5 +26,6 @@ runs: - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2 with: key: ${{ inputs.cache-key }} + save-if: ${{ inputs.save-cache }} # https://github.com/Swatinem/rust-cache/issues/341 cache-bin: ${{ runner.os != 'macOS' }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64b960daf..eaf5825e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -156,7 +156,9 @@ jobs: submodules: true - uses: ./.github/actions/install-rust with: - cache-key: ${{ matrix.os }}-${{ matrix.test }} + # Test shards share their dependencies, so one cache per OS is enough. + cache-key: ${{ matrix.os }} + save-cache: ${{ matrix.test == 'c_tests' }} - uses: ./.github/actions/install-bpf-deps - name: Install additional allocators From 229413f0ff5e8c4dfbac6b397ed89971d064dc9f Mon Sep 17 00:00:00 2001 From: Guillaume Lagrange Date: Tue, 3 Nov 2026 17:24:17 +0100 Subject: [PATCH 2/2] ci: prime one shared rust-cache for the ubuntu-26.04 x64 jobs Its jobs restore the entry without saving, so a cold run stores one union of their dependencies instead of one copy per job. --- .github/actions/install-rust/action.yml | 14 ++++++- .github/workflows/ci.yml | 52 ++++++++++++++++++++++--- 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/.github/actions/install-rust/action.yml b/.github/actions/install-rust/action.yml index cd784332c..569a4147b 100644 --- a/.github/actions/install-rust/action.yml +++ b/.github/actions/install-rust/action.yml @@ -9,10 +9,18 @@ inputs: description: Extra value appended to the rust-cache key, used to give matrix jobs distinct caches. required: false default: "" + shared-key: + description: Cache key shared across jobs, replacing the per-job key. Jobs using it should restore only, leaving the save to the job that primes it. + required: false + default: "" save-cache: - description: Whether this job saves the rust-cache entry. Matrix jobs sharing a key should let only one of them save. + description: Whether this job saves the rust-cache entry. Jobs sharing a key should let only one of them save. required: false default: "true" +outputs: + cache-hit: + description: Whether rust-cache restored an exact key match. + value: ${{ steps.rust-cache.outputs.cache-hit }} runs: using: composite steps: @@ -23,9 +31,11 @@ runs: if: inputs.components != '' shell: bash run: echo "${{ inputs.components }}" | tr ',' '\n' | xargs rustup component add - - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2 + - id: rust-cache + uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2 with: key: ${{ inputs.cache-key }} + shared-key: ${{ inputs.shared-key }} save-if: ${{ inputs.save-cache }} # https://github.com/Swatinem/rust-cache/issues/341 cache-bin: ${{ runner.os != 'macOS' }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eaf5825e3..b76593946 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,12 +15,38 @@ env: CODSPEED_VALGRIND_BUILD_FROM_SOURCE: "false" jobs: + # Builds the dependencies of every ubuntu-26.04 x64 job into one rust-cache + # entry. Those jobs restore it and save nothing; each command below mirrors + # one of theirs, since package selection changes dependency features. + prime-rust-cache: + runs-on: ubuntu-26.04 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + submodules: true + - id: rust + uses: ./.github/actions/install-rust + with: + components: clippy + shared-key: ubuntu-26.04 + - if: steps.rust.outputs.cache-hit != 'true' + uses: ./.github/actions/install-bpf-deps + - name: Build dependencies + if: steps.rust.outputs.cache-hit != 'true' + run: | + cargo clippy --all-targets + cargo build --bin codspeed --bin generate_config_schema + cargo test --all --exclude memtrack --exclude exec-harness --no-run + cargo test -p exec-harness --no-run + (cd crates/memtrack && cargo test --lib --test c_tests --no-run) + lint: + needs: prime-rust-cache runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-26.04, macos-latest] steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -28,17 +54,20 @@ jobs: - uses: ./.github/actions/install-rust with: components: rustfmt, clippy + shared-key: ${{ matrix.os == 'ubuntu-26.04' && 'ubuntu-26.04' || '' }} + save-cache: ${{ matrix.os != 'ubuntu-26.04' }} # Building the runner builds memtrack's vendored libbpf-sys with it. - uses: ./.github/actions/install-bpf-deps - if: matrix.os == 'ubuntu-latest' + if: matrix.os == 'ubuntu-26.04' - uses: j178/prek-action@4e14d07f9231acabce116ccfca13b13dd9755ece # v3.0.0 with: extra-args: --all-files - name: Check config schema is up to date - if: matrix.os == 'ubuntu-latest' + if: matrix.os == 'ubuntu-26.04' run: cargo run --bin generate_config_schema && git diff --exit-code schemas/codspeed.schema.json tests: + needs: prime-rust-cache runs-on: ubuntu-26.04 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -47,6 +76,9 @@ jobs: submodules: true - uses: ./.github/actions/install-rust + with: + shared-key: ubuntu-26.04 + save-cache: false - uses: ./.github/actions/install-bpf-deps @@ -79,16 +111,21 @@ jobs: # CODSPEED_VALGRIND_REF: my-valgrind-branch exec-harness-tests: - runs-on: ubuntu-latest + needs: prime-rust-cache + runs-on: ubuntu-26.04 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: submodules: true - uses: ./.github/actions/install-rust + with: + shared-key: ubuntu-26.04 + save-cache: false - name: Run tests run: cargo test -p exec-harness basic-run-test: + needs: prime-rust-cache runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -105,6 +142,8 @@ jobs: - uses: ./.github/actions/install-rust with: cache-key: ${{ matrix.os }} + shared-key: ${{ matrix.os == 'ubuntu-26.04' && 'ubuntu-26.04' || '' }} + save-cache: ${{ matrix.os != 'ubuntu-26.04' }} - uses: ./.github/actions/install-bpf-deps - name: Run tests run: cargo run -- exec ${{ matrix.extra-args }} -m simulation,walltime,memory --warmup-time 0s --max-rounds 5 -- sleep 1 @@ -123,6 +162,7 @@ jobs: run: cargo run -- exec -m walltime --skip-upload --warmup-time 0s --max-rounds 5 -- ls -la bpf-tests: + needs: prime-rust-cache runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -158,7 +198,8 @@ jobs: with: # Test shards share their dependencies, so one cache per OS is enough. cache-key: ${{ matrix.os }} - save-cache: ${{ matrix.test == 'c_tests' }} + shared-key: ${{ matrix.os == 'ubuntu-26.04' && 'ubuntu-26.04' || '' }} + save-cache: ${{ matrix.os != 'ubuntu-26.04' && matrix.test == 'c_tests' }} - uses: ./.github/actions/install-bpf-deps - name: Install additional allocators @@ -299,6 +340,7 @@ jobs: runs-on: ubuntu-latest if: always() needs: + - prime-rust-cache - lint - tests - executor-tests