ruff
2bb936cb - Stabilize generated rule code for incremental builds (#25726)

Commit
11 hours ago
Stabilize generated rule code for incremental builds (#25726) ## Summary I found this while looking at some changes in `rust` itself. `map_codes` groups rules in a `HashMap` and previously emitted the `Rule::noqa_code` match arms in hash iteration order. Since that order is randomized between compiler processes, an unrelated edit could change the generated function and invalidate a `ruff_linter` codegen unit even when the rule mapping itself was unchanged! On main, touching then rebuilding only reused 255 of 256 `ruff_linter` ThinLTO modules (and recompiled the module containing `Rule::noqa_code`); with this change, `rustc` reused all 256 modules. This can make incremental rebuilds ~10-15% faster! Here's the output of `hyperfine --warmup 3 --runs 10 --prepare 'touch crates/ruff_linter/src/codes.rs' 'env CARGO_INCREMENTAL=1 CARGO_TARGET_DIR=... cargo build -p ruff_linter'`: ``` Revision Pass 1 Pass 2 Combined mean ━━━━━━━━━━ ━━━━━━━━━━━━━━━━━ ━━━━━━━━━━━━━━━━━ ━━━━━━━━━━━━━━━ HEAD 2.667s ± 0.052s 2.597s ± 0.042s 2.632s ────────── ───────────────── ───────────────── ─────────────── HEAD^ 3.093s ± 0.043s 3.038s ± 0.038s 3.066s ```
Author
Parents
Loading