ci: identical sources rebuild from scratch every run — fingerprints never survive checkout #1352

Open
opened 2026-09-21 18:31:28 +00:00 by enricobuehler · 1 comment
Owner

Measured on windows-host run 35051 (push 7968ada1), but the mechanism applies repo-wide — see the required sweep below.

What we observed

The package legs take 24–29 min each even when nothing changed between runs. The x64 leg's cargo build -p punktfunk-host ran 11m07s and emitted Compiling for all ~500 crates, registry deps included — despite a persistent CARGO_TARGET_DIR=C:\t and a healthy sccache daemon reporting 89.5% hits (4,284/4,815).

So the cache exists and works, but cargo never reuses it at the fingerprint level: every unit is dirty every run, and sccache only rescues the compile step (~1–2s/crate in hash+fetch overhead instead of a full compile). The rest of the leg is real work that can't be cached: the leaf punktfunk-host build (~8 min alone under codegen-units = 1 + thin LTO), clippy×8, tests, pf-vkhdr-layer, the WDK drivers pack, bun bundle, Inno pack, four Azure Trusted Signing calls, installer smoke, publish. Both arch legs then serialize on the single windows-amd64 runner → ~53 min/run.

Why every unit is dirty

  1. The checkout itself. Each job deletes and re-clones into a different act workspace path (act\9f3b26f218a8fe73\hostexecutor vs act\2c1ac3245b631ac6\hostexecutor between the two legs of the same run). Fresh mtimes dirty every path dep; the absolute path also lands in -C metadata/dep-info, so even a byte-identical tree at a different path misses.
  2. The version stamp is a guaranteed leaf miss by design. PUNKTFUNK_BUILD_VERSION=0.39.<run_number> changes every run → cargo:rerun-if-env-changed in punktfunk-host/build.rs → the most expensive crate in the graph can never be a cache hit.
  3. Persistent C:\t can't compensate for (1) — fingerprints are dead on arrival. This is also the documented reason the package job can't restore a saved target dir (WDK builds in-tree, act paths rotate).

What this costs

Every push, PR sync and tag re-pays the full compile surface. On the release day this burned ~50 min/run of Windows-runner time across many runs of identical trees; the same pattern likely repeats on other lanes.

Required: sweep the whole CI

Audit every workflow in .gitea/workflows/ for the same disease, not just windows-host.yml. For each job, answer:

  • Does a run with unchanged sources recompile crates at all? (Compare Compiling counts between two consecutive runs on the same commit.)
  • Where does CARGO_TARGET_DIR live, does it persist across runs, and do fingerprints actually match (path + mtime sensitivity)?
  • Is sccache configured, does the daemon start (the preflight can silently drop RUSTC_WRAPPER on a backend failure), and what's the hit rate?
  • Does anything inject a per-run value into the build (version env, OUT_DIR content, generated files) that busts the leaf or the whole graph?
  • Are parallel matrix legs serializing on one runner?

Produce a table of findings per workflow, then fix per workflow — the fixes differ (checkout path pinning, fingerprint-stable paths, version-stamp isolation, sccache preflight hardening).

Candidate fixes (Windows host, the measured case)

  • Isolate the version stamp: put env!("PUNKTFUNK_VERSION") behind a tiny leaf crate so punktfunk-host's codegen units stay byte-identical across runs — sccache can then hit them; only the (uncacheable) link reruns. Est. −4–6 min/leg.
  • Fold the 8 clippy invocations into one workspace-scoped run. −1–2 min.
  • Investigate a stable checkout path on the act runner so dep-info/-C metadata paths match between runs; without this the persistent target dir is dead weight.
  • Keep in mind the runner's disk-cleanup task can purge C:\t entirely — cold legs then also lose the audiopus_sys cmake configure cache (documented failure mode, 2026-07-17).

Done when

  • The sweep table exists and each workflow has either a fix merged or a documented reason it can't be cached further.
  • A no-change rerun of the windows-host package leg is materially faster than 20–25 min (or the remaining floor is measured and accepted in the workflow comments).
Measured on windows-host run 35051 (push `7968ada1`), but the mechanism applies repo-wide — see the required sweep below. ## What we observed The `package` legs take 24–29 min each even when nothing changed between runs. The x64 leg's `cargo build -p punktfunk-host` ran 11m07s and emitted `Compiling` for **all ~500 crates**, registry deps included — despite a persistent `CARGO_TARGET_DIR=C:\t` and a healthy sccache daemon reporting 89.5% hits (4,284/4,815). So the cache exists and works, but cargo never reuses it at the fingerprint level: every unit is dirty every run, and sccache only rescues the compile step (~1–2s/crate in hash+fetch overhead instead of a full compile). The rest of the leg is real work that can't be cached: the leaf `punktfunk-host` build (~8 min alone under `codegen-units = 1` + thin LTO), clippy×8, tests, pf-vkhdr-layer, the WDK drivers pack, bun bundle, Inno pack, four Azure Trusted Signing calls, installer smoke, publish. Both arch legs then serialize on the single windows-amd64 runner → ~53 min/run. ## Why every unit is dirty 1. **The checkout itself.** Each job deletes and re-clones into a *different* act workspace path (`act\9f3b26f218a8fe73\hostexecutor` vs `act\2c1ac3245b631ac6\hostexecutor` between the two legs of the same run). Fresh mtimes dirty every path dep; the absolute path also lands in `-C metadata`/dep-info, so even a byte-identical tree at a different path misses. 2. **The version stamp is a guaranteed leaf miss by design.** `PUNKTFUNK_BUILD_VERSION=0.39.<run_number>` changes every run → `cargo:rerun-if-env-changed` in `punktfunk-host/build.rs` → the most expensive crate in the graph can never be a cache hit. 3. Persistent `C:\t` can't compensate for (1) — fingerprints are dead on arrival. This is also the documented reason the package job can't restore a saved target dir (WDK builds in-tree, act paths rotate). ## What this costs Every push, PR sync and tag re-pays the full compile surface. On the release day this burned ~50 min/run of Windows-runner time across many runs of identical trees; the same pattern likely repeats on other lanes. ## Required: sweep the whole CI Audit **every** workflow in `.gitea/workflows/` for the same disease, not just windows-host.yml. For each job, answer: - [ ] Does a run with unchanged sources recompile crates at all? (Compare `Compiling` counts between two consecutive runs on the same commit.) - [ ] Where does `CARGO_TARGET_DIR` live, does it persist across runs, and do fingerprints actually match (path + mtime sensitivity)? - [ ] Is sccache configured, does the daemon start (the preflight can silently drop `RUSTC_WRAPPER` on a backend failure), and what's the hit rate? - [ ] Does anything inject a per-run value into the build (version env, `OUT_DIR` content, generated files) that busts the leaf or the whole graph? - [ ] Are parallel matrix legs serializing on one runner? Produce a table of findings per workflow, then fix per workflow — the fixes differ (checkout path pinning, fingerprint-stable paths, version-stamp isolation, sccache preflight hardening). ## Candidate fixes (Windows host, the measured case) - **Isolate the version stamp**: put `env!("PUNKTFUNK_VERSION")` behind a tiny leaf crate so `punktfunk-host`'s codegen units stay byte-identical across runs — sccache can then hit them; only the (uncacheable) link reruns. Est. −4–6 min/leg. - **Fold the 8 clippy invocations** into one workspace-scoped run. −1–2 min. - **Investigate a stable checkout path** on the act runner so dep-info/-C metadata paths match between runs; without this the persistent target dir is dead weight. - Keep in mind the runner's disk-cleanup task can purge `C:\t` entirely — cold legs then also lose the audiopus_sys cmake configure cache (documented failure mode, 2026-07-17). ## Done when - The sweep table exists and each workflow has either a fix merged or a documented reason it can't be cached further. - A no-change rerun of the windows-host package leg is materially faster than 20–25 min (or the remaining floor is measured and accepted in the workflow comments).
Author
Owner

Measured on main run 35815, after the 09-22 runner disk fix:

  • Both package legs log src-mtimes: 4158 of 4170 paths kept their mtime (0 of 4139 before).
  • The x64 host build compiled 8 workspace crates (the changed ones and their dependents) and no registry crates: 8m05s, where the cold build was 11m32s with about 700 units.
  • Legs: arm64 16m48s, x64 21m20s (were 24–29 min).

What's left of a leg is fixed cost: the host leaf under thin LTO when host code changed (~8 min), installer pack plus Azure signing (~5 min), and Windows tests (~3 min). A push with no Rust change skips the host build, so a leg should take about 11–12 min.

The per-workflow table is on #1367. Its three follow-ups are in progress now: the drivers workspace still builds cold in-tree, deb host and client still rebuild on PUNKTFUNK_BUILD_VERSION, and Android has no persistent target. This stays open until those land.

Measured on main run 35815, after the 09-22 runner disk fix: - Both package legs log `src-mtimes: 4158 of 4170 paths kept their mtime` (0 of 4139 before). - The x64 host build compiled 8 workspace crates (the changed ones and their dependents) and no registry crates: 8m05s, where the cold build was 11m32s with about 700 units. - Legs: arm64 16m48s, x64 21m20s (were 24–29 min). What's left of a leg is fixed cost: the host leaf under thin LTO when host code changed (~8 min), installer pack plus Azure signing (~5 min), and Windows tests (~3 min). A push with no Rust change skips the host build, so a leg should take about 11–12 min. The per-workflow table is on #1367. Its three follow-ups are in progress now: the drivers workspace still builds cold in-tree, deb host and client still rebuild on `PUNKTFUNK_BUILD_VERSION`, and Android has no persistent target. This stays open until those land.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: unom/punktfunk#1352