Enable ccache in GitHub Actions cmake builds (#5157)

Summary:
Pull Request resolved: https://github.com/facebookresearch/faiss/pull/5157

TLDR
-
ccache is like how BUCK works with partial cached artifacts for builds, but in the OSS world.

https://github.com/facebookresearch/faiss/actions/runs/25118621287/job/73635614448?pr=5157 it sped up the jobs a lot, cuVS down to 40 minutes!

AI stuff
-

Add ccache to the `build_cmake` composite action to speed up CI builds. Uses `hendrikmuhs/ccache-action@v1` to install ccache, restore/save caches keyed by build configuration (OS, arch, opt level, GPU, cuVS, ROCm, SVS), and set a 2GB max cache size. Passes `CMAKE_C_COMPILER_LAUNCHER`, `CMAKE_CXX_COMPILER_LAUNCHER`, and `CMAKE_CUDA_COMPILER_LAUNCHER` to cmake so all C, C++, and CUDA compilations go through ccache.

On first run the cache will be cold and there is no speedup. Subsequent runs on the same branch (or PRs against main) will see cache hits for unchanged translation units, which should significantly reduce build times for incremental CI runs.

Reviewed By: junjieqi

Differential Revision: D102926935

fbshipit-source-id: b8808a3a48edee271547a0421960261aba6ff425
This commit is contained in:
Michael Norris
2026-04-29 12:15:42 -07:00
committed by meta-codesync[bot]
parent c7f07bbc0a
commit 44c1972aec
+9
View File
@@ -159,6 +159,12 @@ runs:
if: inputs.gpu == 'ON' && inputs.rocm == 'ON'
shell: bash
run: rocm-smi
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1
with:
key: ${{ runner.os }}-${{ runner.arch }}-${{ inputs.opt_level }}-gpu${{ inputs.gpu }}-cuvs${{ inputs.cuvs }}-rocm${{ inputs.rocm }}-svs${{ inputs.svs }}
max-size: 2G
update-package-index: true
- name: Build all targets
shell: bash
run: |
@@ -176,6 +182,9 @@ runs:
-DFAISS_ENABLE_C_API=ON \
-DPYTHON_EXECUTABLE=$CONDA/bin/python \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_CUDA_COMPILER_LAUNCHER=ccache \
-DBLA_VENDOR=${{ runner.arch == 'X64' && 'Intel10_64_dyn' || '' }} \
-DCMAKE_CUDA_FLAGS=${{ runner.arch == 'X64' && '"-gencode arch=compute_75,code=sm_75"' || '' }} \
.