diff --git a/xtask/src/main.rs b/xtask/src/main.rs index ee399901..db6cbabe 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -567,6 +567,14 @@ impl Step { const BENCH_VALIDATE: Self = Self { name: "bench (validate)", run: || { + // Use the dev profile (not the default bench profile) for the + // criterion `--test` smoke run. The bench profile inherits the + // release profile's `lto = true, codegen-units = 1`, which spends + // ~40s compiling the full graph just to assert criterion's + // `--test` entry point runs once. The dev profile reuses the + // already-built unit-test artifacts and finishes in seconds. Real + // benchmark measurements (via `cargo xtask bench`) continue to + // use the unchanged bench profile so their numbers stay accurate. run_command_quiet( "cargo", &[ @@ -575,6 +583,7 @@ impl Step { "microsoft-webui", "--bench", "contact_book_bench", + "--profile=dev", "--", "--test", ], diff --git a/xtask/src/util.rs b/xtask/src/util.rs index 931fc592..6b636b0b 100644 --- a/xtask/src/util.rs +++ b/xtask/src/util.rs @@ -72,7 +72,25 @@ pub fn run_command_quiet(cmd: &str, args: &[&str], cwd: Option<&Path>) -> Result /// On Windows `CreateProcessW` cannot launch `.cmd`/`.bat` scripts directly. /// This function uses `which` to resolve the executable path and, when the /// target is a shell script, wraps it in `cmd.exe /c `. +/// +/// For cargo invocations, this also forces `CARGO_INCREMENTAL=0`. xtask is +/// only used for one-shot work (gate, examples, bench, packaging, E2E) and +/// never for an inner edit-compile loop, so incremental compilation provides +/// no benefit. Leaving it on causes the workspace `target/` dir to balloon +/// (the incremental cache and per-feature fingerprint variants grow into the +/// tens of gigabytes), which then makes every subsequent cargo invocation pay +/// huge startup time scanning hundreds of thousands of stale fingerprint +/// files. Disabling it here keeps `cargo xtask check` reliably fast on +/// long-lived working copies. pub fn build_command(cmd: &str, args: &[&str]) -> Command { + let mut command = build_command_inner(cmd, args); + if cmd == "cargo" { + command.env("CARGO_INCREMENTAL", "0"); + } + command +} + +fn build_command_inner(cmd: &str, args: &[&str]) -> Command { #[cfg(windows)] { resolve_windows_command(cmd, args)