Skip to content

GH-50046: [CI][C++] Improve ccache reuse by saving to cache only from main#50047

Draft
rok wants to merge 1 commit into
apache:mainfrom
rok:change_ccache_keys
Draft

GH-50046: [CI][C++] Improve ccache reuse by saving to cache only from main#50047
rok wants to merge 1 commit into
apache:mainfrom
rok:change_ccache_keys

Conversation

@rok
Copy link
Copy Markdown
Member

@rok rok commented May 26, 2026

Rationale for this change

C++ CI jobs currently key ccache/Docker volume caches with hashFiles('cpp/**'). This creates new immutable GitHub Actions cache entries whenever any C++ file changes, even though ccache already 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?

  • Replace actions/cache with explicit actions/cache/restore and actions/cache/save.
  • Remove hashFiles('cpp/**') from C++ cache keys.
  • Use stable restore prefixes per job/config.
  • Save updated caches only from main, using unique github.run_id keys.

Are these changes tested?

By CI?

Are there any user-facing changes?

CI users should see faster builds..

Copilot AI review requested due to automatic review settings May 26, 2026 21:01
@github-actions github-actions Bot added the awaiting committer review Awaiting committer review label May 26, 2026
@github-actions
Copy link
Copy Markdown

⚠️ GitHub issue #50046 has been automatically assigned in GitHub to PR creator.

@github-actions github-actions Bot added the CI: Extra: C++ Run extra C++ CI label May 26, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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@v5 with paired actions/cache/restore@v5 and actions/cache/save@v5 steps 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 Save steps with if: 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.

@rok rok force-pushed the change_ccache_keys branch from 9776486 to 1711a31 Compare May 26, 2026 23:11
Copilot AI review requested due to automatic review settings May 26, 2026 23:12
@rok rok force-pushed the change_ccache_keys branch from 1711a31 to fa05f88 Compare May 26, 2026 23:12
@rok rok requested a review from kou May 26, 2026 23:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread .github/workflows/cpp_extra.yml
@rok rok force-pushed the change_ccache_keys branch from fa05f88 to 4a893c1 Compare May 26, 2026 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting committer review Awaiting committer review CI: Extra: C++ Run extra C++ CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants