about summary refs log tree commit diff
path: root/library/std/src/fs.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-03-21 21:03:49 +0000
committerbors <bors@rust-lang.org>2025-03-21 21:03:49 +0000
commit48b36c9d5943a4aef49aa04b8059b92d65ff31a9 (patch)
tree5c0c4be8b5a7dc98914aea80c6cffcb18e3f3d58 /library/std/src/fs.rs
parentbe73c1f4617c97bce81b2694a767353300a75072 (diff)
parente21502cf9ed247bbf879132b8c62e423d959bd38 (diff)
downloadrust-48b36c9d5943a4aef49aa04b8059b92d65ff31a9.tar.gz
rust-48b36c9d5943a4aef49aa04b8059b92d65ff31a9.zip
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
Diffstat (limited to 'library/std/src/fs.rs')
0 files changed, 0 insertions, 0 deletions