rust/compiler/rustc_codegen_ssa/src
bors 48b36c9d59 Auto merge of #128320 - saethlin:link-me-maybe, r=compiler-errors
Avoid no-op unlink+link dances in incr comp

Incremental compilation scales quite poorly with the number of CGUs. This PR improves one reason for that.

The incr comp process hard-links all the files from an old session into a new one, then it runs the backend, which may just hard-link the new session files into the output directory. Then codegen hard-links all the output files back to the new session directory.

This PR (perhaps unimaginatively) fixes the silliness that ensues in the last step. The old `link_or_copy` implementation would be passed pairs of paths which are already the same inode, then it would blindly delete the destination and re-create the hard-link that it just deleted. This PR lets us skip both those operations. We don't skip the other two hard-links.

`cargo +stage1 b && touch crates/core/main.rs && strace -cfw -elink,linkat,unlink,unlinkat cargo +stage1 b` before and then after on `ripgrep-13.0.0`:
```
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 52.56    0.024950          25       978       485 unlink
 34.38    0.016318          22       727           linkat
 13.06    0.006200          24       249           unlinkat
------ ----------- ----------- --------- --------- ----------------
100.00    0.047467          24      1954       485 total
```
```
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 42.83    0.014521          57       252           unlink
 38.41    0.013021          26       486           linkat
 18.77    0.006362          25       249           unlinkat
------ ----------- ----------- --------- --------- ----------------
100.00    0.033904          34       987           total
```

This reduces the number of hard-links that are causing perf troubles, noted in https://github.com/rust-lang/rust/issues/64291 and https://github.com/rust-lang/rust/issues/137560
2025-03-21 21:03:49 +00:00
..
back Auto merge of #128320 - saethlin:link-me-maybe, r=compiler-errors 2025-03-21 21:03:49 +00:00
debuginfo Flatten ifs in rustc_codegen_ssa 2025-03-17 18:56:52 +00:00
mir Flatten ifs in rustc_codegen_ssa 2025-03-17 18:56:52 +00:00
traits Auto merge of #137586 - nnethercote:SetImpliedBits, r=bjorn3 2025-03-11 12:05:16 +00:00
assert_module_sources.rs Move methods from Map to TyCtxt, part 4. 2025-03-12 08:55:37 +11:00
base.rs Auto merge of #128320 - saethlin:link-me-maybe, r=compiler-errors 2025-03-21 21:03:49 +00:00
codegen_attrs.rs Rollup merge of #138627 - EnzymeAD:autodiff-cleanups, r=oli-obk 2025-03-21 15:48:55 +01:00
common.rs Test fixing raw-dylib 2024-09-24 10:10:31 -07:00
errors.rs Stop relying on rustc_type_ir in non-type-system crates 2025-03-15 06:42:48 +00:00
lib.rs Auto merge of #128320 - saethlin:link-me-maybe, r=compiler-errors 2025-03-21 21:03:49 +00:00
meth.rs More assertions, tests, and miri coverage 2025-01-30 17:44:28 +00:00
mono_item.rs Make a fake body to store typeck results for global_asm 2025-02-22 00:12:07 +00:00
size_of_val.rs Set both nuw and nsw in slice size calculation 2025-02-13 21:26:48 -08:00
target_features.rs Simplify implied_target_features. 2025-03-05 09:20:28 +11:00