Skip to content

Commit 4f08b5f

Browse files
committed
perf(ci): improve build cache diagnostics
- enable ccache PCH caching for the Ubuntu installed build - configure ccache for Xcode compilation on macOS - inspect restored Cargo targets and compiler fingerprints - add Xcode compiler wrappers with cache-compatible PCH flags - report detailed ccache statistics for trial build legs
1 parent 1ae83b8 commit 4f08b5f

1 file changed

Lines changed: 75 additions & 2 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,18 @@ jobs:
255255
with:
256256
key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.flavor }}-${{ env.BUILD_TYPE }}
257257

258+
# CI-perf trial (stage A), one leg only. Every TU that force-includes
259+
# the CMake PCH was "uncacheable" -- 493 of 824 calls -- so a warm cache
260+
# still recompiled core, ui and test. ccache caches PCH users and the
261+
# .gch itself only under these sloppiness flags; the objects are the
262+
# same, the checks relaxed are about timestamps and __DATE__ defines.
263+
- name: Allow ccache To Cache PCH Users (trial)
264+
run: |
265+
ccache --set-config=sloppiness=pch_defines,time_macros,include_file_mtime,include_file_ctime
266+
ccache --set-config=max_size=2G
267+
ccache -p | grep -E 'sloppiness|max_size'
268+
if: matrix.os == 'ubuntu-22.04' && matrix.flavor == 'installed'
269+
258270
- name: Install Dependence (Linux)
259271
run: |
260272
sudo apt-get update
@@ -328,6 +340,14 @@ jobs:
328340
cache-on-failure: true
329341
if: runner.os == 'Linux'
330342

343+
# CI-perf trial (stage A): every leg compiled all ~196 crates despite
344+
# an exact rust-cache hit. Show what the restore actually put back.
345+
- name: Show Restored Cargo Target (trial)
346+
run: |
347+
du -sh build/cargo 2>/dev/null || echo "build/cargo was not restored"
348+
find build/cargo -maxdepth 4 -type d 2>/dev/null | head -40 || true
349+
if: matrix.os == 'ubuntu-22.04' && matrix.flavor == 'installed'
350+
331351
# rust-cache cannot locate the msys2/mingw cargo, so cache the registry and
332352
# Corrosion's target dir directly for the Windows build.
333353
- name: Cache Cargo (Windows)
@@ -396,6 +416,9 @@ jobs:
396416
if: runner.os == 'Linux'
397417

398418
- name: Build GpgFrontend (Linux)
419+
env:
420+
# CI-perf trial (stage A): cargo names why each crate is dirty.
421+
CARGO_LOG: ${{ (matrix.os == 'ubuntu-22.04' && matrix.flavor == 'installed') && 'cargo::core::compiler::fingerprint=info' || '' }}
399422
run: |
400423
export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64:$LD_LIBRARY_PATH
401424
# Native binding is REQUIRED here and OFF by default, which is the
@@ -430,7 +453,7 @@ jobs:
430453
--config ${{ env.BUILD_TYPE }} \
431454
--parallel \
432455
--verbose
433-
ccache -s
456+
ccache -s -v 2>/dev/null || ccache -s
434457
if: runner.os == 'Linux'
435458

436459
# The AppDir is an ordinary install tree.
@@ -1153,6 +1176,17 @@ jobs:
11531176
with:
11541177
key: ${{ github.job }}-${{ matrix.os }}-${{ env.BUILD_TYPE }}
11551178

1179+
# CI-perf trial (stage A), one leg only. See "Build GpgFrontend": the
1180+
# Xcode generator ignores CMAKE_<LANG>_COMPILER_LAUNCHER, so until now
1181+
# only GpgME ever went through ccache here. clang_index_store and
1182+
# ivfsoverlay cover flags Xcode adds to every compile line.
1183+
- name: Allow ccache To Cache Xcode Compiles (trial)
1184+
run: |
1185+
ccache --set-config=sloppiness=pch_defines,time_macros,include_file_mtime,include_file_ctime,clang_index_store,ivfsoverlay,modules
1186+
ccache --set-config=max_size=2G
1187+
ccache -p | grep -E 'sloppiness|max_size'
1188+
if: matrix.os == 'macos-15-intel'
1189+
11561190
- name: Install Qt6
11571191
uses: jurplel/install-qt-action@48d3ad6db93f3627c8ee7a0454bc6f3744f7e730 # v4.3.1
11581192
with:
@@ -1178,6 +1212,13 @@ jobs:
11781212
shared-key: rust-${{ runner.os }}-${{ matrix.os }}-${{ env.BUILD_TYPE }}
11791213
cache-on-failure: true
11801214

1215+
# CI-perf trial (stage A): see the same step in the build job.
1216+
- name: Show Restored Cargo Target (trial)
1217+
run: |
1218+
du -sh build/cargo 2>/dev/null || echo "build/cargo was not restored"
1219+
find build/cargo -maxdepth 4 -type d 2>/dev/null | head -40 || true
1220+
if: matrix.os == 'macos-15-intel'
1221+
11811222
- name: Build GpgME
11821223
run: |
11831224
cd ${{github.workspace}}/third_party/gpgme
@@ -1206,6 +1247,10 @@ jobs:
12061247
run: ${{github.workspace}}/scripts/check_entitlements_sync.sh
12071248

12081249
- name: Build GpgFrontend
1250+
env:
1251+
# CI-perf trial (stage A): cargo names why each crate is dirty.
1252+
CARGO_LOG: ${{ matrix.os == 'macos-15-intel' && 'cargo::core::compiler::fingerprint=info' || '' }}
1253+
CCACHE_XCODE_TRIAL: ${{ matrix.os == 'macos-15-intel' && '1' || '' }}
12091254
run: |
12101255
MACOS_MAJOR=$(sw_vers -productVersion | cut -d. -f1)
12111256
MACOS_MINOR=$(sw_vers -productVersion | cut -d. -f2)
@@ -1244,6 +1289,29 @@ jobs:
12441289
# well as the identity: src/CMakeLists.txt bakes a profile specifier
12451290
# into the project, and Xcode would otherwise try to resolve a profile
12461291
# this job has no business holding.
1292+
#
1293+
# ccache, as xcodebuild build settings rather than a CMake launcher,
1294+
# which the Xcode generator ignores. CC/CXX go through a wrapper;
1295+
# LD/LDPLUSPLUS stay the plain driver so links never see a
1296+
# compile-only flag. -fno-pch-timestamp: Xcode precompiles the prefix
1297+
# header itself, and a .pch restored from the cache would otherwise
1298+
# be refused against this checkout's header mtimes. The index store
1299+
# is an IDE feature and only adds an uncacheable output.
1300+
XCODE_CCACHE=()
1301+
if [[ -n "${CCACHE_XCODE_TRIAL:-}" ]]; then
1302+
WRAP="$RUNNER_TEMP/ccache-xcode"
1303+
mkdir -p "$WRAP"
1304+
REAL_CC="$(xcrun -f clang)"
1305+
REAL_CXX="$(xcrun -f clang++)"
1306+
printf '#!/bin/sh\nexec ccache "%s" -Xclang -fno-pch-timestamp "$@"\n' "$REAL_CC" > "$WRAP/clang"
1307+
printf '#!/bin/sh\nexec ccache "%s" -Xclang -fno-pch-timestamp "$@"\n' "$REAL_CXX" > "$WRAP/clang++"
1308+
chmod +x "$WRAP/clang" "$WRAP/clang++"
1309+
XCODE_CCACHE=(CC="$WRAP/clang" CXX="$WRAP/clang++" \
1310+
LD="$REAL_CC" LDPLUSPLUS="$REAL_CXX" \
1311+
COMPILER_INDEX_STORE_ENABLE=NO)
1312+
ccache -z
1313+
fi
1314+
12471315
cd ${{github.workspace}}/build/
12481316
xcodebuild -project ${{github.workspace}}/build/GpgFrontend.xcodeproj \
12491317
-scheme GpgFrontend \
@@ -1254,7 +1322,12 @@ jobs:
12541322
CODE_SIGNING_REQUIRED=NO \
12551323
CODE_SIGNING_ALLOWED=NO \
12561324
DEVELOPMENT_TEAM="" \
1257-
PROVISIONING_PROFILE_SPECIFIER=""
1325+
PROVISIONING_PROFILE_SPECIFIER="" \
1326+
${XCODE_CCACHE[@]+"${XCODE_CCACHE[@]}"}
1327+
1328+
if [[ -n "${CCACHE_XCODE_TRIAL:-}" ]]; then
1329+
ccache -s -v
1330+
fi
12581331
12591332
# Skip -exportArchive: the generated ExportOptions.plist is
12601333
# method=developer-id with signingStyle=manual, so exporting demands a

0 commit comments

Comments
 (0)