Repository navigation
perf(xtask): speed up in-session precommit (combined test warmup, optimized syntax stack) - #8397
Conversation
…mize the syntax stack in dev check-file-policy warmed xtask's and ripr's test targets with separate cargo calls that serialize on the target-dir lock (~2m + ~2m cold). One combined --no-run call lets Cargo schedule them together; failures are ignored there and still surface in each selector's own spawn. Unoptimized rowan/ra_ap_syntax dominated the source scans. Optimizing that small stack drops check-static-language 156s->3s, check-public-api and source-role-authority 20s->3s, check-no-panic-family 32s->8s warm. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J3KUnhhKPXLyZHb2mHiFbC
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Next included review available in 9 minutes. View limit details
Comment |
|
In-session proof on head 306cd52:
Generated by Claude Code |
There was a problem hiding this comment.
Confirmed findings
- xtask/src/policy/file_policy.rs:239 — combined_preparation_args treats every non-flag word as mergeable, including positional test name filters. cargo test --no-run ignores positionals (only builds), but if a future selector passes an extra positional (e.g. integration args), behavior stays correct today; worth a comment or test asserting positionals beyond the recognized set still produce a non-mergeable decision when their semantic differs.
- xtask/src/policy/file_policy.rs:262 — covered_by_combined_preparation_merges_only_plain_build_shapes does not assert behavior when packages is empty but mergeable selectors contribute only --bin/--test (no -p). Current code returns None via the
command_packages.is_empty()branch, which matches the README claim but is currently untested. Add a regression line.
Verification questions
- Confirm xtask/src/policy/file_policy.rs:260 — When <2 selectors merge, combined_preparation_args returns None but the per-selector path still runs. Confirmed; no-op is fine. However, when merged==0 the function still scans every selector; minor wasted work, not a correctness issue.
- Confirm combined_preparation_args merge gate is plausible: when collected packages is empty or <2 selectors merge, returns None. Test covers single-selector empty path; ≥2 path is exercised by the new test with two non-Windows mergeable selectors plus Windows-skipped one.
- Confirm pR claims ~4min→negligible improvement but admits a fully cold end-to-end run is not verified; warm-cache numbers only.
- Confirm combined_preparation_args re-tokenizes selector strings independently of the existing build-shape classifier (is_cargo_test_command + per-selector spawn path). Two parsers of the same grammar is duplication risk; a non-flag value starting with '-' (e.g. '--feature=foo') or a future flag will desynchronize the prewarm from the actual spawn.
- Confirm host filter relies on selector.host.is_some_and(...) == host; a selector with host=Windows is correctly excluded on Unix, but the host comparison uses PartialEq on an enum; verify no Other variant leaks.
- Confirm targeted unit test asserts only plain -p/--bin/--test (with --locked/--offline allowed) are merged; --workspace and --doc excluded.
Refuted
- Dev-profile opt-level=2 on rowan/ra_ap_syntax could mask panic-UB or aliasing bugs in debug builds that policy gates rely on.; refuted because: The 8 listed crates are pure parsing/syntactic utilities with well-tested opt-independent behavior; opt-level=2 on parsing crates only affects speed, not source language rules checked by file-policy.
- entries for top-level dep names could fail to resolve on platforms/feature combos where Cargo.lock has duplicate versions (e.g. hashbrown, rustc-hash per author note).; refuted because: Cargo spec resolution for profile overrides uses crate name and applies to all versions in the dep graph; duplicate hashes get the same opt-level. Author subagent review verified Cargo.lock entry existence. No workspace member is overridden, so no rename ambiguity.
- Combined build failure could silently skip per-selector build/list/fail and drop coverage; refuted because: The diff only adds diagnostics.push on failure and still runs validate_test_covered_by_recorded_with which spawns per-selector cargo; per PR body and code, every selector still builds, lists and fails under its own spawn.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Requested by Steven · project thread
Before: a cold
cargo xtask precommitspent about 4 minutes incheck-file-policycompiling xtask's test target and then ripr's test targets in two serial cargo calls, and ran the source scans on an unoptimized rust-analyzer syntax stack (check-static-language156s on one run,check-no-panic-family32s,check-rust-source-role-authorityandcheck-public-api~20s each).After: the covered_by selectors that are plain
-p/--bin/--testbuilds are warmed by one combinedcargo test --no-runso Cargo compiles them together, and the small parsing stack (ra_ap_syntax, ra_ap_parser, rustc_lexer, rowan, hashbrown, rustc-hash, memchr, smol_str) builds at opt-level 2 in the dev profile. Warm scan times measured here: static-language 3s, source-role 3s, public-api 2.7s, no-panic 8s.The combined build is a cache fill only: its failure is ignored and every selector still builds, lists and fails under its own spawn, so no coverage is dropped (the diagnostic row is recorded in the file-policy report).
How:
combined_preparation_argsinxtask/src/policy/file_policy.rs(unit-tested; non-plain selectors such as--docor--workspaceare left alone) and[profile.dev.package.*]entries inCargo.toml.Verified:
cargo test -p xtask --bin xtask policy::file_policy(28 pass),cargo xtask precommitpasses (624s, included workspace Clippy because Cargo.toml changed). Not verified: a truly cold end-to-end run after this change (deps were partly cached), and the combined build's wall-clock saving on a cold 4-core box. Hosted CI not involved; workflow files untouched (CI speedups belong to #4984).Generated by Claude Code