chore: stop xtask from bloating target/ and slowing the gate#306
Merged
Conversation
The local quality gate (cargo xtask check) was taking 18+ minutes on long-lived working copies, even though the actual compile + test work was only ~2 minutes. The root cause was the workspace target/ directory growing to 160+ GB / 1.1M+ files from accumulated incremental compilation state and per-feature fingerprint variants. Cargo then spent most of every subsequent invocation just stat'ing fingerprint files. Two changes: * Force `CARGO_INCREMENTAL=0` on every cargo invocation that xtask spawns. xtask never runs an inner edit-compile loop — every cargo call it makes (gate steps, examples build, bench, E2E, packaging) is one-shot, so incremental compilation just produces garbage that cargo then has to scan on the next run. CI was already immune to this via Swatinem/rust-cache@v2 (which sets the same env). Real inner-loop development with `cargo build` / `cargo test` outside xtask is unaffected. * Switch the gate's bench-validate step to `--profile=dev`. The step exists only to run criterion's `--test` smoke path, but the default bench profile inherits the release profile's `lto = true, codegen-units = 1`, so it was recompiling the entire `microsoft-webui` graph with full LTO just to assert criterion's entry point loads. Dev profile reuses unit-test artifacts and drops that step from ~44s to ~2s. Real benchmark measurements via `cargo xtask bench` still use the unchanged bench profile, so reported numbers remain accurate. Measured on a working copy where target/ had grown organically: ``` before (bloated target/, 160 GB): 18m23s after (bloated target/, 160 GB): N/A — change forces clean rebuild after (clean target/): 42s (first run) after (clean target/): 35s (subsequent runs, no growth) ``` bench-validate step alone: ``` before: ~44s (bench profile, LTO + codegen-units=1) after: ~2-3s (dev profile, reuses test artifacts) ``` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
The local quality gate (cargo xtask check) was taking 18+ minutes on long-lived working copies, even though the actual compile + test work was only ~2 minutes. The root cause was the workspace target/ directory growing to 160+ GB / 1.1M+ files from accumulated incremental compilation state and per-feature fingerprint variants. Cargo then spent most of every subsequent invocation just stat'ing fingerprint files.
Two changes:
Force
CARGO_INCREMENTAL=0on every cargo invocation that xtask spawns. xtask never runs an inner edit-compile loop — every cargo call it makes (gate steps, examples build, bench, E2E, packaging) is one-shot, so incremental compilation just produces garbage that cargo then has to scan on the next run. CI was already immune to this via Swatinem/rust-cache@v2 (which sets the same env). Real inner-loop development withcargo build/cargo testoutside xtask is unaffected.Switch the gate's bench-validate step to
--profile=dev. The step exists only to run criterion's--testsmoke path, but the default bench profile inherits the release profile'slto = true, codegen-units = 1, so it was recompiling the entiremicrosoft-webuigraph with full LTO just to assert criterion's entry point loads. Dev profile reuses unit-test artifacts and drops that step from ~44s to ~2s. Real benchmark measurements viacargo xtask benchstill use the unchanged bench profile, so reported numbers remain accurate.Measured on a working copy where target/ had grown organically:
bench-validate step alone: