GH-50046: [CI][C++] Improve ccache reuse by saving to cache only from main#50047
Draft
rok wants to merge 1 commit into
Draft
GH-50046: [CI][C++] Improve ccache reuse by saving to cache only from main#50047rok wants to merge 1 commit into
rok wants to merge 1 commit into
Conversation
|
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors C++ CI cache handling to improve ccache reuse. Instead of using actions/cache with cache keys that include hashFiles('cpp/**'), it splits cache restore/save into separate steps, uses github.run_id as the unique save key, and only saves new caches when running on main. This avoids creating new cache entries per PR (which can cause eviction) while still letting PR builds benefit from the stable restore prefix.
Changes:
- Replace
actions/cache@v5with pairedactions/cache/restore@v5andactions/cache/save@v5steps across C++ workflows. - Drop
hashFiles('cpp/**')from cache keys; use${{ github.run_id }}as the save key and a stable prefix as the restore-key. - Gate
Savesteps withif: github.ref == 'refs/heads/main'so only main pushes write new cache entries.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| .github/workflows/cpp.yml | Splits Docker volume and ccache caching into restore/save pairs for docker, macOS, and MinGW jobs; saves only from main. |
| .github/workflows/cpp_windows.yml | Splits Windows ccache caching into restore/save; saves only from main. |
| .github/workflows/cpp_extra.yml | Same restore/save split applied to docker-extra, JNI (linux + macOS), ODBC linux/macOS/MSVC jobs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
C++ CI jobs currently key
ccache/Docker volume caches withhashFiles('cpp/**'). This creates new immutable GitHub Actions cache entries whenever any C++ file changes, even thoughccachealready handles per-file invalidation internally.Recent CI logs show that when caches are restored, C++ jobs get high ccache hit rates, but GitHub cache restore misses are common and cause large runtime regressions.
What changes are included in this PR?
actions/cachewith explicitactions/cache/restoreandactions/cache/save.hashFiles('cpp/**')from C++ cache keys.main, using uniquegithub.run_idkeys.Are these changes tested?
By CI?
Are there any user-facing changes?
CI users should see faster builds..