Skip to content

perf(xtask): speed up in-session precommit (combined test warmup, optimized syntax stack) - #8397

Merged
EffortlessSteven merged 1 commit into
mainfrom
claude/project-thread-5f3hgf
Oct 17, 2026
Merged

EffortlessSteven merged 1 commit into
mainfrom
claude/project-thread-5f3hgf

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Requested by Steven · project thread

Before: a cold cargo xtask precommit spent about 4 minutes in check-file-policy compiling 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-language 156s on one run, check-no-panic-family 32s, check-rust-source-role-authority and check-public-api ~20s each).

After: the covered_by selectors that are plain -p/--bin/--test builds are warmed by one combined cargo test --no-run so 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_args in xtask/src/policy/file_policy.rs (unit-tested; non-plain selectors such as --doc or --workspace are left alone) and [profile.dev.package.*] entries in Cargo.toml.

Verified: cargo test -p xtask --bin xtask policy::file_policy (28 pass), cargo xtask precommit passes (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

…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
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@EffortlessSteven EffortlessSteven self-assigned this Oct 17, 2026
@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 61 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: 990335f2-dd8e-4f26-b611-a81c70130bb2
📥 Commits

Reviewing files that changed from the base of the PR and between e2cb5a9 and 306cd52.

📒 Files selected for processing: 2
  • Cargo.toml
  • xtask/src/policy/file_policy.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Copy link
Copy Markdown
Member Author

In-session proof on head 306cd52:

  • cargo xtask precommit: pass (624s, included workspace Clippy because Cargo.toml changed).
  • cargo test -p xtask --bin xtask policy::file_policy: 28 pass.
  • Independent review (fresh Sonnet 5.5 subagent, since CodeRabbit and Gemini are quota-limited): no blocking findings. Confirmed the combined build is a cache fill whose failure is non-fatal, per-selector build/list/fail path unchanged, Windows-only selectors skipped on Unix, all eight dev-profile package names exist in Cargo.lock (duplicate hashbrown/rustc-hash versions covered). Noted non-blocking: a selector with no target flags merged with --bin/--test ones makes the prewarm partial (lost optimization only).
  • Not verified: a fully cold end-to-end run after this change.

Generated by Claude Code

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 17, 2026 06:13
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants