Skip to content

Commit c764998

Browse files
authored
perf(ci): pin Rust deps with a GC root so the sticky disk keeps them (#1274)
The linux native build rebuilt the entire crate dependency set (~190s) on every run, even though the `ccusage-deps` derivation hash is identical across runs. The crane cargoArtifacts path has no GC root once the final binary is built, so the Blacksmith sticky disk drops it on commit and the next run recompiles all deps from scratch. Expose the static build's `cargoArtifacts` via passthru and, after the build, pin it with a GC root under the mounted Nix store (`/nix/ccusage-ci-gcroots/deps`). The root persists with the sticky disk, so the deps stay warm and subsequent runs should reuse them instead of rebuilding.
1 parent b80d71b commit c764998

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

‎.github/actions/build-linux-native-package/action.yaml‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,23 @@ runs:
2626
nix build .#ccusage-static --print-build-logs
2727
fi
2828
29+
# Pin the deps-only artifacts with a GC root that lives on the mounted Nix
30+
# store (the Blacksmith sticky disk). Without a root the crane cargoArtifacts
31+
# path is unreferenced once the binary is built, so the sticky disk drops it
32+
# and the next run rebuilds all dependencies (~190s). The root persists with
33+
# the disk, keeping the deps warm across runs.
34+
- name: Pin dependency cache root
35+
shell: bash
36+
env:
37+
NIX_GITHUB_TOKEN: ${{ inputs.nix-github-token }}
38+
run: |
39+
mkdir -p /nix/ccusage-ci-gcroots
40+
if [ "$NIX_GITHUB_TOKEN" = "false" ]; then
41+
NIX_CONFIG="access-tokens =" nix build '.#ccusage-static.cargoArtifacts' --out-link /nix/ccusage-ci-gcroots/deps
42+
else
43+
nix build '.#ccusage-static.cargoArtifacts' --out-link /nix/ccusage-ci-gcroots/deps
44+
fi
45+
2946
- name: Verify Linux binary is static
3047
shell: bash
3148
env:

‎nix/static-package.nix‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ in
7272
staticCommonArgs
7373
// {
7474
cargoArtifacts = staticCargoArtifacts;
75+
# Expose the deps-only artifacts so CI can pin them with a GC root and
76+
# keep them on the Blacksmith sticky disk across runs; otherwise the
77+
# store path is unreferenced once the binary is built and gets pruned,
78+
# forcing a full ~190s dependency rebuild on every run.
79+
passthru = {
80+
cargoArtifacts = staticCargoArtifacts;
81+
};
7582
# A PT_INTERP header means the binary requests a dynamic loader,
7683
# so it would not run on end-user machines without the build-time
7784
# loader path. READELF is exported by the cross bintools wrapper.

0 commit comments

Comments
 (0)