From b5262919317d7ddd6f7eca52664f092712b944cd Mon Sep 17 00:00:00 2001 From: jgrusewski Date: Fri, 1 May 2026 01:00:52 +0200 Subject: [PATCH] ci(argo): wire sccache into compile-and-deploy-template MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mount the existing sccache-cpu PVC and set RUSTC_WRAPPER=sccache for the regular service-build pipeline. Previously only train-template and train-multi-seed-template used sccache; the production CI build had zero rustc-level caching, so every CI run rebuilt every dep from scratch. Also set CARGO_INCREMENTAL=0 to override the workspace-wide [build] incremental = true in .cargo/config.toml. sccache documented limitation: cannot cache incremental rustc output. Local dev keeps incremental via config.toml unchanged. Print sccache --show-stats at end of build for visibility into cache hit rates. Mirror of train-template.yaml's sccache pattern; uses the sccache-cpu PVC (20Gi, scw-bssd-retain) which was already provisioned but unmounted. Expected impact: rustc cache hit rate jumps from 0% → 50-90% on subsequent CI runs. --- .../k8s/argo/compile-and-deploy-template.yaml | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/infra/k8s/argo/compile-and-deploy-template.yaml b/infra/k8s/argo/compile-and-deploy-template.yaml index 4759b0d98..f49526dc6 100644 --- a/infra/k8s/argo/compile-and-deploy-template.yaml +++ b/infra/k8s/argo/compile-and-deploy-template.yaml @@ -44,6 +44,9 @@ spec: - name: cargo-target-cpu persistentVolumeClaim: claimName: cargo-target-cpu + - name: sccache + persistentVolumeClaim: + claimName: sccache-cpu templates: - name: pipeline @@ -179,6 +182,21 @@ spec: value: /cargo-target - name: CARGO_HOME value: /cargo-target/cargo-home + # sccache: rustc wrapper that content-hashes compile inputs and reuses + # object output across pods/commits via the sccache-cpu PVC. Survives + # cargo's incremental-cache invalidation from git checkout mtime touches. + - name: RUSTC_WRAPPER + value: sccache + - name: SCCACHE_DIR + value: /sccache-cache + - name: SCCACHE_CACHE_SIZE + value: 20G + # Required: workspace `.cargo/config.toml` sets [build] incremental = true, + # which forces incremental compilation even on --release. sccache cannot + # cache incremental rustc output (documented limitation). Override here + # so sccache actually catches. Local dev keeps incremental via config.toml. + - name: CARGO_INCREMENTAL + value: "0" - name: GITLAB_PAT valueFrom: secretKeyRef: @@ -197,6 +215,8 @@ spec: readOnly: true - name: cargo-target-cpu mountPath: /cargo-target + - name: sccache + mountPath: /sccache-cache args: - | set -e @@ -312,6 +332,9 @@ spec: "${GITLAB}/api/v4/projects/1/packages/generic/foxhunt-services/latest/${BIN_NAME}" || true done + echo "=== sccache stats ===" + sccache --show-stats || true + echo "=== Service compile + upload done ($SERVICE_PKGS) ===" # ── upload-release: create GitLab Release with package links ──