Skip to content

ci: add ccache support to C/C++ workflow - #892

Merged
mrjimenez merged 5 commits into
masterfrom
ci/ccache
Jun 7, 2026
Merged

ci: add ccache support to C/C++ workflow#892
mrjimenez merged 5 commits into
masterfrom
ci/ccache

Conversation

@mrjimenez

@mrjimenez mrjimenez commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Install ccache on macOS (brew) and MSYS2 (mingw-w64-x86_64-ccache); it is pre-installed on ubuntu-latest
  • Persist the ccache directory across runs with actions/cache@v4, keyed on OS + build type + hash of CMake files
  • save-always: true ensures the cache is written back even on exact key hits or when a later step (e.g. tests) fails
  • No cmake flags needed: CMakeLists.txt already calls find_program(CCACHE_PROGRAM ccache) and sets CMAKE_C_COMPILER_LAUNCHER / CMAKE_CXX_COMPILER_LAUNCHER automatically

Correction

  • ccache is not pre-installed on ubuntu-latest, it did not failed in the first run because CMakeLists.txt fails gracefully on ccache absence and just prints a message and does not use it.

Test plan

  • Ubuntu Debug and Release jobs show ccache cache restore/save steps
  • macOS Debug and Release jobs install and use ccache via Homebrew
  • mingw-w64 Debug and Release jobs install and use ccache via MSYS2
  • Subsequent CI runs show reduced build times on cache hits

This PR stays in draft until after we release 3.0.0.

mrjimenez added 5 commits June 6, 2026 18:37
Install ccache on macOS and MSYS2 (pre-installed on ubuntu-latest),
persist the cache directory across runs with actions/cache@v4, and
enable save-always so the cache is updated even on exact hits or when
a later step (e.g. tests) fails. CMakeLists.txt already auto-detects
ccache and sets the compiler launcher, so no cmake flags are needed.
actions/cache save-always is deprecated and will be removed. Use
separate actions/cache/restore and actions/cache/save steps instead,
with if: always() on the save so it runs even when tests fail.
Use github.run_id in the save key so every run writes a fresh cache
entry; restore still falls back via restore-keys to the most recent
one. Add a ccache --show-stats step (if: always) after each build to
make hit/miss rates visible in the CI logs.
ccache is not pre-installed on ubuntu-latest; add it to the apt deps list.
ccache --show-stats reports cumulative totals including stats saved
from previous runs. Zero the counters just before make so the reported
hit rate reflects only the current build.
@mrjimenez

Copy link
Copy Markdown
Contributor Author

Commits

  • c1: add ccache support
  • c2: replace deprecated save-always
  • c3: use run_id key + print stats
  • c4: install ccache on Ubuntu
  • c5: zero stats before build

Build Times per Run

Run Commit Event Ubuntu Debug Ubuntu Release MacOS Debug MacOS Release mingw Debug mingw Release
#1 c1 push 11m20s 13m41s 10m48s 8m20s 15m37s 15m03s
#2 c1 pr 11m30s 13m11s 8m46s 8m07s 15m20s 11m07s
#3 c2 push 11m31s 13m24s 2m38s 2m30s 3m38s 4m41s
#4 c2 pr 10m45s 11m48s 2m07s 1m57s 5m08s 3m05s
#5 c3 push FAIL FAIL 2m15s 2m30s 4m46s 5m01s
#6 c3 pr FAIL FAIL 2m47s 2m57s 4m44s 3m12s
#7 c4 push 13m28s 13m07s 3m00s 2m05s 5m20s 4m56s
#8 c4 pr 14m39s 15m39s 2m10s 3m12s 4m41s 3m47s
#9 c5 push 2m49s 2m50s 2m19s 1m55s 4m57s 4m10s
#10 c5 pr 2m45s 2m54s 2m54s 2m30s 4m32s 4m34s

Cold vs Warm Summary

Comparing runs 1–2 (cold cache) against runs 9–10 (warm cache), successful jobs only.

Platform Build type Cold avg Warm avg Saved Reduction
Ubuntu Debug 11.4 min 2.8 min 8.6 min 76%
Ubuntu Release 13.4 min 2.9 min 10.6 min 79%
MacOS Debug 9.8 min 2.6 min 7.2 min 73%
MacOS Release 8.2 min 2.2 min 6.0 min 73%
mingw Debug 15.5 min 4.8 min 10.7 min 69%
mingw Release 13.1 min 4.4 min 8.7 min 67%

@mrjimenez

Copy link
Copy Markdown
Contributor Author
ci_build_times

@got3nks

got3nks commented Jun 7, 2026

Copy link
Copy Markdown
Contributor
ci_build_times

Great job! 👏

@mrjimenez

Copy link
Copy Markdown
Contributor Author

@got3nks , I didn't think this would be ready before release. If you think this is safe and ok, and since you are working in stuff today, we can merge this to spare us some precious compilation time, what do you think?

@got3nks

got3nks commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Reviewed end-to-end — the diff is clean and the last four CI runs (c4-c5 across all six job × build_type cells) all went green in 3-5 minutes, matching the warm-cache numbers in your table. Verified locally that CMakeLists.txt:38-46 already wires ccache via COMPILER_LAUNCHER, so this PR is pure CI plumbing.

The asymmetric run_id-on-save / hashFiles-on-restore pattern is the right call (avoids two-workflow write races on the same key), and if: always() on save is good — partial caches survive even on test failures.

Blast radius is CI-only; if anything regresses, a revert is one click. Safe to merge before 3.0.0 in my book — and it'll measurably speed up the rest of our pre-release iteration loop.

Approve.

got3nks

This comment was marked as resolved.

@mrjimenez
mrjimenez marked this pull request as ready for review June 7, 2026 11:54
@mrjimenez
mrjimenez merged commit 01c39f1 into master Jun 7, 2026
14 checks passed
@mrjimenez
mrjimenez deleted the ci/ccache branch June 7, 2026 11:54
got3nks added a commit to got3nks/amule that referenced this pull request Jun 7, 2026
…ule-project#912)

Extends existing categories (preferring extensions over new lines):
- Performance/Upload: amule-project#898 SlotAllocation default raised.
- Networking & Discovery: wire-parser hardening list extended with
  amule-project#879/amule-project#882/amule-project#890/amule-project#886; new amuleweb security hardening bullet
  consolidating ngosang's amule-project#869-amule-project#874 triage (all landed in amule-project#875);
  amulegui list extended with amule-project#857; shared-folder watcher extended
  with amule-project#858.
- Packaging: Windows installer i18n line extended with amule-project#899.
- Internals & Refactoring: new docs-polish + code-quality bullets
  covering amule-project#851/amule-project#855/amule-project#862/amule-project#888/amule-project#900/amule-project#866/amule-project#867/amule-project#895 and amule-project#909/amule-project#910/amule-project#912.
- Translations: new pre-release final-wave bullet covering amule-project#847/amule-project#856/
  amule-project#891/amule-project#908/amule-project#860/amule-project#904/amule-project#859/amule-project#863/amule-project#861/amule-project#880/amule-project#911/amule-project#901/amule-project#902/amule-project#889/amule-project#868/amule-project#853.
- Bug Fixes & Stability: amule-project#850/amule-project#854/amule-project#878/amule-project#906.
- CI: ccache wiring (amule-project#892, amule-project#903) + CodeQL binutils-dev (amule-project#907).

Contributors footer gains mifritscher and nguyenhoangminhhieu2004-gif
(both first-time contributors).

PR index extended through amule-project#912.
mrjimenez pushed a commit that referenced this pull request Jun 8, 2026
Extends existing categories (preferring extensions over new lines):
- Performance/Upload: #898 SlotAllocation default raised.
- Networking & Discovery: wire-parser hardening list extended with
  #879/#882/#890/#886; new amuleweb security hardening bullet
  consolidating ngosang's #869-#874 triage (all landed in #875);
  amulegui list extended with #857; shared-folder watcher extended
  with #858.
- Packaging: Windows installer i18n line extended with #899.
- Internals & Refactoring: new docs-polish + code-quality bullets
  covering #851/#855/#862/#888/#900/#866/#867/#895 and #909/#910/#912.
- Translations: new pre-release final-wave bullet covering #847/#856/
  #891/#908/#860/#904/#859/#863/#861/#880/#911/#901/#902/#889/#868/#853.
- Bug Fixes & Stability: #850/#854/#878/#906.
- CI: ccache wiring (#892, #903) + CodeQL binutils-dev (#907).

Contributors footer gains mifritscher and nguyenhoangminhhieu2004-gif
(both first-time contributors).

PR index extended through #912.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants