Skip to content

Commit a94cf0a

Browse files
committed
build(ci): cap macOS build parallelism + wire shared sccache/Depot compiler cache
Two complementary fixes for the macOS build, behind a new `use_cache` workflow_dispatch input (default true). Phase 1 = macOS only. BUILD_JOBS knob (previously investigated, never landed): build.sh now honors $BUILD_JOBS for the cmake -j level (default = all cores; portable nproc/sysctl detection), and the 3 macOS build jobs set BUILD_JOBS=2. GitHub's ~7 GB macOS arm64 runners OOM under -j$(nproc) when the 16.6k-line httplib.cpp co-schedules with the model TUs; the runner is then killed as SIGTERM/143 ("received a shutdown signal") — not a real timeout. Capping concurrent compiles bounds peak memory. sccache -> Depot Cache (WebDAV): build.sh routes the compiler through sccache (-DCMAKE_*_COMPILER_LAUNCHER) only when USE_CACHE=true AND sccache + a cache token are present, then prints `sccache --show-stats`. The 3 macOS jobs brew-install sccache and set SCCACHE_WEBDAV_ENDPOINT=https://cache.depot.dev + SCCACHE_WEBDAV_TOKEN=${{ secrets.DEPOT_TOKEN }}. Because llama.cpp is pinned, the ~280 upstream object files are content-identical every run, so a warm cache recompiles only changed files — staying -O3, bit-identical and release-safe. Depot's cache is shared across all branches, so every branch builds incrementally (and warm builds also cut the macOS memory pressure further). Safety: inert until the DEPOT_TOKEN secret exists and on fork PRs (secrets hidden) — those just compile normally; the install step is continue-on-error and use_cache=false forces a clean from-scratch build. build.sh gating verified locally across all four cases (warm / Linux-untouched / no-token / explicit-off). Phase 2 (later): dockcross Linux/Android/CUDA (needs the token + sccache binary passed into the container), Windows, and the Linux-host test-cpp job. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JdLpWD8nedY7LwNnHefZLF
1 parent fae2b90 commit a94cf0a

2 files changed

Lines changed: 61 additions & 2 deletions

File tree

.github/build.sh

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,33 @@
66
# SPDX-License-Identifier: MIT
77

88
mkdir -p build
9-
cmake -Bbuild $@ || exit 1
10-
cmake --build build --config Release -j$(nproc) || exit 1
9+
10+
# Build parallelism. Defaults to all cores; RAM-limited CI runners (notably GitHub's
11+
# ~7 GB macOS arm64) export BUILD_JOBS lower (e.g. 2) so the large httplib.cpp + the 134
12+
# llama.cpp model TUs do not exhaust memory and get the runner OOM-killed mid-compile
13+
# (which surfaces as a SIGTERM / "runner received a shutdown signal", not a clean timeout).
14+
JOBS="${BUILD_JOBS:-}"
15+
if [ -z "$JOBS" ]; then
16+
JOBS="$( { command -v nproc >/dev/null 2>&1 && nproc; } || sysctl -n hw.ncpu 2>/dev/null || echo 4 )"
17+
fi
18+
19+
# Optional shared compiler cache: sccache fronting Depot Cache (WebDAV). Enabled only when
20+
# USE_CACHE is true AND sccache + a cache token are present, so it stays inert before the
21+
# DEPOT_TOKEN secret is configured and on fork PRs (secrets hidden) — those just compile
22+
# normally. sccache is content-addressed, so a cache hit is bit-identical to a fresh -O3
23+
# compile (release-safe), and it degrades to direct compilation if the cache is unreachable.
24+
LAUNCH=""
25+
if [ "${USE_CACHE:-true}" = "true" ] && command -v sccache >/dev/null 2>&1 \
26+
&& [ -n "${SCCACHE_WEBDAV_TOKEN:-}${SCCACHE_GHA_ENABLED:-}" ]; then
27+
LAUNCH="-DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache"
28+
echo "build.sh: sccache ON (endpoint=${SCCACHE_WEBDAV_ENDPOINT:-default}), building with -j${JOBS}"
29+
else
30+
echo "build.sh: sccache OFF, building with -j${JOBS}"
31+
fi
32+
33+
cmake -Bbuild $LAUNCH $@ || exit 1
34+
cmake --build build --config Release -j"${JOBS}" || exit 1
35+
36+
if command -v sccache >/dev/null 2>&1; then
37+
sccache --show-stats || true
38+
fi

.github/workflows/publish.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ on:
1515
description: "Deploy to Maven Central (snapshot if -SNAPSHOT, release if a vX.Y.Z tag)"
1616
type: boolean
1717
default: false
18+
use_cache:
19+
description: "Use the shared sccache/Depot compiler cache (faster incremental builds)"
20+
type: boolean
21+
default: true
1822
env:
1923
JAVA_VERSION: '21'
2024
MODEL_URL: "https://huggingface.co/TheBloke/CodeLlama-7B-GGUF/resolve/main/codellama-7b.Q2_K.gguf"
@@ -308,6 +312,11 @@ jobs:
308312
name: Build and Test macOS 15 arm64 (no Metal)
309313
needs: [startgate, build-webui]
310314
runs-on: macos-15
315+
env:
316+
BUILD_JOBS: 2
317+
USE_CACHE: ${{ github.event_name != 'workflow_dispatch' || inputs.use_cache }}
318+
SCCACHE_WEBDAV_ENDPOINT: https://cache.depot.dev
319+
SCCACHE_WEBDAV_TOKEN: ${{ secrets.DEPOT_TOKEN }}
311320
steps:
312321
- uses: actions/checkout@v6
313322
- name: Download shared WebUI assets
@@ -327,6 +336,10 @@ jobs:
327336
echo ""
328337
echo "=== Processor Details ==="
329338
system_profiler SPHardwareDataType
339+
- name: Install sccache (shared compiler cache)
340+
if: env.USE_CACHE == 'true'
341+
continue-on-error: true
342+
run: brew install sccache
330343
- name: Build libraries
331344
shell: bash
332345
run: |
@@ -344,6 +357,11 @@ jobs:
344357
name: Build and Test macOS 14 arm64 (Metal)
345358
needs: [startgate, build-webui]
346359
runs-on: macos-14
360+
env:
361+
BUILD_JOBS: 2
362+
USE_CACHE: ${{ github.event_name != 'workflow_dispatch' || inputs.use_cache }}
363+
SCCACHE_WEBDAV_ENDPOINT: https://cache.depot.dev
364+
SCCACHE_WEBDAV_TOKEN: ${{ secrets.DEPOT_TOKEN }}
347365
steps:
348366
- uses: actions/checkout@v6
349367
- name: Download shared WebUI assets
@@ -363,6 +381,10 @@ jobs:
363381
echo ""
364382
echo "=== Processor Details ==="
365383
system_profiler SPHardwareDataType
384+
- name: Install sccache (shared compiler cache)
385+
if: env.USE_CACHE == 'true'
386+
continue-on-error: true
387+
run: brew install sccache
366388
- name: Build libraries
367389
shell: bash
368390
run: |
@@ -476,6 +498,11 @@ jobs:
476498
name: Build and Test macOS 15 arm64 (Metal)
477499
needs: [startgate, build-webui]
478500
runs-on: macos-15
501+
env:
502+
BUILD_JOBS: 2
503+
USE_CACHE: ${{ github.event_name != 'workflow_dispatch' || inputs.use_cache }}
504+
SCCACHE_WEBDAV_ENDPOINT: https://cache.depot.dev
505+
SCCACHE_WEBDAV_TOKEN: ${{ secrets.DEPOT_TOKEN }}
479506
steps:
480507
- uses: actions/checkout@v6
481508
- name: Download shared WebUI assets
@@ -495,6 +522,10 @@ jobs:
495522
echo ""
496523
echo "=== Processor Details ==="
497524
system_profiler SPHardwareDataType
525+
- name: Install sccache (shared compiler cache)
526+
if: env.USE_CACHE == 'true'
527+
continue-on-error: true
528+
run: brew install sccache
498529
- name: Build libraries
499530
shell: bash
500531
run: |

0 commit comments

Comments
 (0)