Skip to content

Commit f76cb23

Browse files
committed
Emit a per-job sccache statistics table to the GitHub job summary
KISS analogue of upstream llama.cpp's ccache-action "CCache Statistics" table, but for this repo's sccache-over-Depot cache (ccache-action can't be dropped in: it manages its own ccache + actions/cache backend, conflicting with the Depot WebDAV design). build.sh/build.bat already print `sccache --show-stats` to the log; now, when running in CI (GITHUB_STEP_SUMMARY set) and sccache was actually the launcher, they also parse those stats and append a small markdown table: ### sccache statistics | Cache hits | Requests | Hit rate | |------------|----------|----------| | 589 | 600 | 98.2% | Per-job (GitHub does not merge job summaries), covering every native build job uniformly — build.sh handles the dockcross/native-Linux/aarch64/vulkan-linux and macOS jobs; build.bat the Windows jobs. Parses the text stats (top-level "Compile requests" = total, top-level "Cache hits" = hits; the per-language "Cache hits (C/C++)" line is skipped by the digit-anchored regex). Best-effort: skipped silently if the numbers can't be parsed or there were no requests, and never emitted for local runs (no GITHUB_STEP_SUMMARY) — so local builds are untouched. Verified the build.sh parse end-to-end against a realistic sccache --show-stats sample (req=600, hits=589 -> 98.2%, with the "Compile requests executed" line correctly excluded); build.sh passes bash -n. The Windows batch path (integer math with rounding, escaped pipes/parens) is validated by CI on the Windows runners. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HL7d4uQ3cKR5HwYFPvZvv7
1 parent 14df14a commit f76cb23

3 files changed

Lines changed: 51 additions & 2 deletions

File tree

.github/build.bat

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,28 @@ REM was wired in as the launcher.
6060
if defined LAUNCH (
6161
echo build.bat: sccache --show-stats
6262
sccache --show-stats
63+
REM KISS per-job cache summary in the GitHub Actions job summary (like upstream llama.cpp's
64+
REM ccache-action table). Parse the text stats: the top-level "Compile requests" line is the
65+
REM total and the top-level "Cache hits" line is the hits (the per-language "Cache hits (C/C++)"
66+
REM line has "(" after the label, so the digit-anchored findstr regex skips it). Only in CI
67+
REM (GITHUB_STEP_SUMMARY set); local runs are untouched. Best-effort -- skipped if the two
68+
REM numbers can't be parsed or there were no requests. Integer math with rounding to one decimal.
69+
if defined GITHUB_STEP_SUMMARY (
70+
set "SCC_REQ="
71+
set "SCC_HITS="
72+
for /f "tokens=3" %%a in ('sccache --show-stats 2^>nul ^| findstr /r /c:"^Compile requests *[0-9]"') do set "SCC_REQ=%%a"
73+
for /f "tokens=3" %%a in ('sccache --show-stats 2^>nul ^| findstr /r /c:"^Cache hits *[0-9]"') do set "SCC_HITS=%%a"
74+
if defined SCC_REQ if defined SCC_HITS if !SCC_REQ! gtr 0 (
75+
set /a SCC_RATE10=^(!SCC_HITS! * 1000 + !SCC_REQ! / 2^) / !SCC_REQ!
76+
set /a SCC_WHOLE=!SCC_RATE10! / 10
77+
set /a SCC_DEC=!SCC_RATE10! %% 10
78+
>>"%GITHUB_STEP_SUMMARY%" echo ### sccache statistics
79+
>>"%GITHUB_STEP_SUMMARY%" echo.
80+
>>"%GITHUB_STEP_SUMMARY%" echo ^| Cache hits ^| Requests ^| Hit rate ^|
81+
>>"%GITHUB_STEP_SUMMARY%" echo ^|------------^|----------^|----------^|
82+
>>"%GITHUB_STEP_SUMMARY%" echo ^| !SCC_HITS! ^| !SCC_REQ! ^| !SCC_WHOLE!.!SCC_DEC!%% ^|
83+
)
84+
)
6385
)
6486

6587
REM Propagate a build failure as a non-zero exit (a prior bug let a failed `cmake

.github/build.sh

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,5 +160,26 @@ rm -f "$build_log"
160160
# crashing sccache (or the mid-build retry disabled it), re-invoking it here would just repeat
161161
# the crash output (harmless but noisy).
162162
if [ -n "$LAUNCH" ] && command -v sccache >/dev/null 2>&1; then
163-
sccache --show-stats || true
163+
sccache_stats="$(sccache --show-stats 2>/dev/null || true)"
164+
printf '%s\n' "$sccache_stats"
165+
# KISS per-job cache summary in the GitHub Actions job summary (like upstream llama.cpp's
166+
# ccache-action table). Parse the text stats: the top-level "Compile requests" line is the
167+
# total and the top-level "Cache hits" line is the hits (the per-language "Cache hits (C/C++)"
168+
# line has "(" after the label, so the digit-anchored regex skips it). Only runs in CI
169+
# (GITHUB_STEP_SUMMARY set); local runs are untouched. Best-effort — skips silently if the two
170+
# numbers can't be parsed or there were no requests.
171+
if [ -n "${GITHUB_STEP_SUMMARY:-}" ] && [ -n "$sccache_stats" ]; then
172+
sccache_req="$(printf '%s\n' "$sccache_stats" | awk '/^Compile requests[[:space:]]+[0-9]/{print $NF; exit}')"
173+
sccache_hits="$(printf '%s\n' "$sccache_stats" | awk '/^Cache hits[[:space:]]+[0-9]/{print $NF; exit}')"
174+
if [ -n "$sccache_req" ] && [ -n "$sccache_hits" ] && [ "$sccache_req" -gt 0 ] 2>/dev/null; then
175+
sccache_rate="$(awk "BEGIN{printf \"%.1f\", ($sccache_hits/$sccache_req)*100}")"
176+
{
177+
echo "### sccache statistics"
178+
echo ""
179+
echo "| Cache hits | Requests | Hit rate |"
180+
echo "|------------|----------|----------|"
181+
echo "| ${sccache_hits} | ${sccache_req} | ${sccache_rate}% |"
182+
} >> "$GITHUB_STEP_SUMMARY"
183+
fi
184+
fi
164185
fi

CLAUDE.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,13 @@ jobs therefore set `BUILD_JOBS: 2` to bound peak memory.
358358
**`sccache` → Depot Cache — shared compiler cache.** When `USE_CACHE=true` **and** `sccache`
359359
plus a cache token are present, `build.sh` adds
360360
`-DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache` and prints
361-
`sccache --show-stats`. The cache lives in **Depot Cache** over sccache's **WebDAV** backend:
361+
`sccache --show-stats`. **Per-job cache summary:** when running in CI (`GITHUB_STEP_SUMMARY` set),
362+
`build.sh`/`build.bat` also parse those stats and append a small `### sccache statistics` table
363+
(`Cache hits | Requests | Hit rate`) to the job summary — the sccache/Depot analogue of upstream
364+
llama.cpp's `ccache-action` "CCache Statistics" table, per-job (GitHub does not merge job
365+
summaries). It is best-effort (skipped silently if the numbers can't be parsed) and only emitted
366+
when sccache was actually the launcher; local runs (no `GITHUB_STEP_SUMMARY`) are untouched. The
367+
cache lives in **Depot Cache** over sccache's **WebDAV** backend:
362368

363369
- `SCCACHE_WEBDAV_ENDPOINT: https://cache.depot.dev`
364370
- `SCCACHE_WEBDAV_TOKEN: ${{ secrets.DEPOT_TOKEN }}` — a Depot **organization** token, stored

0 commit comments

Comments
 (0)