Commit 1986ad7
committed
Auto merge of rust-lang#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 rust-lang#64291 and rust-lang#1375601 file changed
+14
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
106 | 107 | | |
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| 113 | + | |
112 | 114 | | |
113 | 115 | | |
114 | 116 | | |
| |||
381 | 383 | | |
382 | 384 | | |
383 | 385 | | |
| 386 | + | |
384 | 387 | | |
385 | 388 | | |
386 | 389 | | |
| |||
437 | 440 | | |
438 | 441 | | |
439 | 442 | | |
| 443 | + | |
440 | 444 | | |
441 | 445 | | |
442 | 446 | | |
| |||
460 | 464 | | |
461 | 465 | | |
462 | 466 | | |
| 467 | + | |
463 | 468 | | |
464 | 469 | | |
465 | | - | |
| 470 | + | |
466 | 471 | | |
467 | 472 | | |
468 | 473 | | |
469 | 474 | | |
470 | 475 | | |
471 | | - | |
472 | | - | |
| 476 | + | |
| 477 | + | |
473 | 478 | | |
474 | 479 | | |
475 | 480 | | |
476 | | - | |
| 481 | + | |
477 | 482 | | |
478 | | - | |
| 483 | + | |
479 | 484 | | |
480 | 485 | | |
481 | 486 | | |
| |||
487 | 492 | | |
488 | 493 | | |
489 | 494 | | |
| 495 | + | |
490 | 496 | | |
491 | | - | |
| 497 | + | |
492 | 498 | | |
493 | 499 | | |
494 | 500 | | |
495 | 501 | | |
496 | 502 | | |
497 | 503 | | |
498 | 504 | | |
| 505 | + | |
499 | 506 | | |
500 | 507 | | |
501 | 508 | | |
| |||
637 | 644 | | |
638 | 645 | | |
639 | 646 | | |
| 647 | + | |
640 | 648 | | |
641 | 649 | | |
642 | 650 | | |
| |||
0 commit comments