Repository navigation
ci: speed up coverage build with mold linker + debug-info trim - #484
Merged
Merged
Conversation
The merged test+coverage job (PR #476) is the sole driver of PR wall-clock — ~3m21s out of ~4m end-to-end on a recent successful run (25562733813), with the `Run tests` step alone consuming 2m20s of that. Other jobs all parallelize within ~50s. Three step-scoped changes attack the build/link phase: * Install `mold` and route the final link through it via `-C link-arg=-fuse-ld=mold`. Workspace links ~8 instrumented test binaries (alloy/iroh/tokio/aws-sdk dep tree); mold is typically 5–10× faster at the link step than ld. * `-C debuginfo=1` (line-tables-only). cargo-llvm-cov only needs the `.debug_line` section to map counters to source lines for the SF/DA records in lcov.info; full DWARF type/variable info is unnecessary. Documented as the recommended setting in cargo-llvm-cov. * `-C split-debuginfo=unpacked` puts debug info in side files instead of inline in object files; smaller .o files mean faster linking and a smaller cached target tree. Plus `CARGO_INCREMENTAL=0` (incremental files bloat the cache for no gain on a single CI run) and `--no-clean` on `cargo llvm-cov nextest` (explicit "trust the cached target", matches modern default). All knobs are scoped to the `Run tests` step's env block on purpose: Swatinem/rust-cache hashes env into its key, so this only invalidates `shared-key: coverage` on the merge run. The clippy/doc/msrv shared keys stay warm — keeping the steady-state PR wall-clock as the goal, not the one-time merge cost. Coverage is preserved as a blocking PR signal; no changes to ci-success `needs:` or `allowed-skips`. The post-processing (LCOV diff, sticky comment) is unaffected. Expected: `Run tests` 2m20s → ~1m45s–2m, full PR wall-clock ~4m → ~3m–3m15s. Sub-2m would need a paid larger runner, deferred. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
Note Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported. |
There was a problem hiding this comment.
Pull request overview
This PR aims to reduce the wall-clock time of the CI test job (which runs cargo llvm-cov nextest) by speeding up linking and trimming debug info, while keeping the optimizations scoped to the coverage step to avoid invalidating other Swatinem/rust-cache partitions.
Changes:
- Install
moldin thetestjob to accelerate linking. - Scope
RUSTFLAGSto the coverage test step to enablemold, usedebuginfo=1, and enablesplit-debuginfo=unpacked. - Disable incremental compilation for that step and add
--no-cleantocargo llvm-cov nextest.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage reportTotal: 87.90% (was 87.89%, ▲ +0.01%) — 11851/13483 lines No Rust files changed in this PR. History
|
Per review feedback on PR #484: clippy/doc/msrv jobs do still link build scripts and proc-macro cdylibs, even though they don't link the final test binaries. Reword the comment to reflect what the scoping decision is actually about — mold's wall-clock impact is dominated by the test job's many large instrumented binaries — instead of overstating that other jobs don't link at all. No behavior change. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Self-review caught real issues that flowed from the original commit's comments into the actual flag choice. Fixing: * RUSTFLAGS bug: was `-C debuginfo=1`, now `-C debuginfo=line-tables-only`. Per `rustc -C help`, `=1` is the alias for "limited", which still emits subprogram DIEs and inlined-call info. `=line-tables-only` is strictly tighter — exactly the `.debug_line`-only output the comment block claimed we were already producing. Behavior change: build now actually emits less debug info than before. * Swatinem/rust-cache mechanism comment was wrong. The original wording said setting RUSTFLAGS at step level "invalidates the coverage shared- key." That's not what happens: the rust-cache step runs earlier in the job and doesn't observe this step-level env, so the cache key isn't invalidated at all. The actual mechanism is cargo's per-artifact fingerprint detecting the RUSTFLAGS change and recompiling affected crates within the restored target/. Conclusion (clippy/doc/msrv stay warm) still holds, but for a different reason. * `--no-clean` comment was inverted. cargo-llvm-cov runs `cargo clean --package <each>` per invocation by default; --no-clean actively suppresses that. Without it, the rust-cache restore would be wiped by cargo-llvm-cov before the build started. The flag is doing real work, not just being defensive. Also dropped rot-prone counts from the comments (8-crate, ~8 binaries, specific dep names). The reasoning stands without them and they go stale every time a crate is added. No semantic change to the linker (still mold), the split-debuginfo setting, the cache-disable knob, or the --no-clean flag itself. Only the debuginfo level changes: limited → line-tables-only. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Step-level env was the wrong scope. Evidence from PR #484's first three runs (all ~7m50s for the test job, vs ~2m20s baseline): Run 1 (cold): "Cache hit for: v0-rust-coverage-...-ae62368c-b23bd388" — restored main's old-RUSTFLAGS target. Build: starts compiling proc-macro2/quote/syn/serde from scratch — cargo's per-artifact fingerprint saw the new RUSTFLAGS in step env and invalidated everything in the restored target/. Post: "Cache up-to-date." — Swatinem skipped the save because its cache key (computed without seeing the step env) matched an existing entry. Run 2 & 3: same key, same restore, same full rebuild, same skipped save. Groundhog Day. Fix: hoist RUSTFLAGS and CARGO_INCREMENTAL from the `Run tests` step's env to the job's env. rust-cache's `Swatinem/rust-cache` step then runs inside this env, hashes RUST*/CARGO* env into its cache key (per its config.ts), and gives the `coverage` partition a key that actually reflects the build configuration. First post-merge run misses cleanly once and saves the new target; every subsequent run hits warm. The env is bounded to this job's `env:` block, so other jobs (clippy/doc/msrv) still don't inherit it. Their warm caches are preserved — that property was already verified on the prior runs (clippy ~45s, doc ~45s, MSRV ~43s, unchanged from baseline). Comment block at the previous step-level `env:` location moves to the job-level `env:` and is rewritten to reflect the actual mechanism. The narrative comment at the `Run tests` step is shortened — it no longer needs to re-explain RUSTFLAGS scoping, only the `--no-clean` rationale. No semantic change to mold, debuginfo level, split-debuginfo, or CARGO_INCREMENTAL=0; only the env's *scope* changes. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
No-op commit to force a CI run that hits the freshly-saved v0-rust-coverage-Linux-x64-d64fc7f4-b23bd388 cache cleanly. The preceding run (6a00c37) was a one-time cache miss after the cache-key fix landed; this run is the actual wall-clock measurement. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Merged
3 of 4 tasks
thiras
added a commit
that referenced
this pull request
Jul 23, 2026
…d/debuginfo tuning (#1417) The single anvil-e2e job was compile-dominated (~17m cold: settlement ~6m, build daemon+CLI ~4m, journeys ~5m). The three decdn-node compiles are genuinely distinct build contexts cargo can't share, so the redundancy can't be dissolved in-place. Two orthogonal wins instead: - Split into `anvil-e2e-settlement` (in-process settlement e2e, no bin build) and `anvil-e2e-journeys` (bins + cross-layer journeys), running concurrently so the two independent compiles overlap. Distinct rust-cache shared-keys; ci-success gate updated in both `needs` and `allowed-skips`. - Apply the `test` job's proven tuning to both: mold linker + `debuginfo=line-tables-only` + `split-debuginfo=unpacked` + `CARGO_INCREMENTAL=0` at job level (so rust-cache keys it, per the PR #484 pattern). The job links ~16 binaries with the system linker and full debuginfo today. Settlement bound sized at 60m for the cold-cache first run (new key, nothing to restore); journeys keeps 130m. Corrected the relocated journeys timeout inventory to the actual 16 tests / 13 files (summing to 218m, ~109m balanced): dropped the phantom G-ORIGIN-04, added the G-GOV-02 and G-NODE-08 journeys. Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The merged
test+coveragejob (#476) is the sole wall-clock driver on PR CI: ~3m21s of a ~4m run, with theRun testsstep alone at 2m20s. Every other job finishes in under a minute and parallelizes off the critical path. This PR attacks the build/link phase of that step with three knobs:moldlinker via-C link-arg=-fuse-ld=mold— installed via apt at job start, routed throughRUSTFLAGS. Faster final link of the workspace's instrumented test binaries.-C debuginfo=line-tables-only— emits only the.debug_lineDWARF section, which is whatcargo-llvm-covreads to map counters to source lines forSF/DArecords inlcov.info. Strips subprogram DIEs and all type/variable info.-C split-debuginfo=unpacked— side-file debug info, smaller.ofiles, faster relinking, smaller cachedtarget/.Plus
CARGO_INCREMENTAL=0(incremental files bloat the cache for no gain on a single CI run) and--no-cleanoncargo llvm-cov nextest(suppresses cargo-llvm-cov's per-packagecargo cleanthat would otherwise wipe the rust-cache restore).Env scope (job-level, not step-level)
RUSTFLAGSandCARGO_INCREMENTALlive at the test job'senv:block. This is load-bearing:Swatinem/rust-cachereadsprocess.envat the moment its own step runs, and hashesCARGO_*/RUST_*env vars into its cache key. With job-level scope, rust-cache sees the new RUSTFLAGS, gives thecoveragepartition a key that uniquely reflects the build configuration, and the post-job step actually saves the freshly-built target.An earlier draft of this PR scoped the env at the step level — which made rust-cache invisible to it. The result was the wrong-cache-restore-then-skip-save trap: rust-cache restored
main's old-flag target, cargo's per-artifact fingerprint detected the new RUSTFLAGS at compile time and rebuilt everything from scratch (~6m), then the post-step skipped the save with "Cache up-to-date" because the unchanged key already existed. The freshly-built target was thrown away every run. See commit6a00c37for the fix.The job-level scope is bounded — other jobs (
clippy,doc,msrv) are in their own job blocks and don't inherit this env, so their warm caches are preserved.What is not changing
ci-successneeds:orallowed-skips.coverage-diff.pyand the sticky-comment plumbing are untouched.Cargo.tomlchanges; other jobs (clippy,doc,msrv,deny) are untouched.release.ymlstill usessccachefor native binary builds (separate path, separate cache).Measured impact (warm-cache run
25566849732on commit45bfabc)25562733813)Run testssteptarget/)Install moldtestjob totalOther jobs (
clippy54s,doc75s,msrv41s,deny55s) are within CI runtime variance of their baselines — env scoping kept their caches isolated.Cold-cache penalty (one-time, on merge to
main):coverageshared-key invalidates because the cache key changed; the merge run will rebuild from scratch (~7m30s for the test job) and save the new cache. Every subsequent PR hits warm.Sub-2m wall-clock would require a paid larger GitHub-hosted runner (e.g.
ubuntu-latest-4-core, ~2× minute multiplier for ~2× cores). Deferred — current numbers meet the goal.Test plan
v0-rust-coverage-Linux-x64-d64fc7f4-b23bd388, hash differs from baseline…ae62368c…).25566274171: "Saving cache…", 751MB upload).25566849732:Run tests85s vs 139s baseline;testjob 156s vs 201s baseline).debuginfo=line-tables-onlyretained line tables).lcov.infoartifact format unchanged: coverage diff comment shows87.90%consistent with baseline.clippy,doc,msrvjob durations remain near baseline — env scoping kept their caches warm.🤖 Generated with Claude Code