Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make "Assemble stage1 compiler" orders of magnitude faster #96803

Merged
merged 1 commit into from
May 10, 2022

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented May 7, 2022

This used to take upwards of 5 seconds for me locally. I found that the culprit was copying the downloaded LLVM shared object:

[22:28:03] Install "/home/jnelson/rust-lang/rust/build/x86_64-unknown-linux-gnu/ci-llvm/lib/libLLVM-14-rust-1.62.0-nightly.so" to "/home/jnelson/rust-lang/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libLLVM-14-rust-1.62.0-nightly.so"
[22:28:09]   c Sysroot { compiler: Compiler { stage: 1, host: x86_64-unknown-linux-gnu(x86_64-unknown-linux-gnu) } }

It turned out that install() used full copies unconditionally. Change it to try using a hard-link before falling back to copying.

@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 7, 2022
@Mark-Simulacrum
Copy link
Member

@bors try

I'm also going to kick off a try build and would appreciate you downloading and checking that all the files are there as expected -- in particular the rust-docs tarball is of concern to me, since IIRC we use symlinks to get rustdoc to generate files right for that and this will make it such that we're producing symlinks in the 'image' directory that's uplifted into the tarball I believe.

@bors
Copy link
Contributor

bors commented May 7, 2022

⌛ Trying commit 52298d7dbb3328e2260b0e144fefa62aab9b3bb4 with merge be7cf4e1c0cda74138f4984a7ffe048b0af38e44...

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 7, 2022
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented May 7, 2022

💔 Test failed - checks-actions

@jyn514 jyn514 force-pushed the faster-assemble branch from 52298d7 to 007b3da Compare May 9, 2022 03:38
@rust-log-analyzer

This comment has been minimized.

This used to take upwards of 5 seconds for me locally. I found that the culprit was copying the downloaded LLVM shared object:
```
[22:28:03] Install "/home/jnelson/rust-lang/rust/build/x86_64-unknown-linux-gnu/ci-llvm/lib/libLLVM-14-rust-1.62.0-nightly.so" to "/home/jnelson/rust-lang/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libLLVM-14-rust-1.62.0-nightly.so"
[22:28:09]   c Sysroot { compiler: Compiler { stage: 1, host: x86_64-unknown-linux-gnu(x86_64-unknown-linux-gnu) } }
```

It turned out that `install()` used full copies unconditionally. Change it to try using a hard-link before falling back to copying.
@jyn514 jyn514 force-pushed the faster-assemble branch from 007b3da to 5f4b174 Compare May 9, 2022 03:43
@oli-obk
Copy link
Contributor

oli-obk commented May 9, 2022

@bors try

@bors
Copy link
Contributor

bors commented May 9, 2022

⌛ Trying commit 5f4b174 with merge 28bece3f394dc1aee54d00d6bb81b388ef6225ea...

@bors
Copy link
Contributor

bors commented May 9, 2022

☀️ Try build successful - checks-actions
Build commit: 28bece3f394dc1aee54d00d6bb81b388ef6225ea (28bece3f394dc1aee54d00d6bb81b388ef6225ea)

@jyn514
Copy link
Member Author

jyn514 commented May 10, 2022

@Mark-Simulacrum I downloaded https://ci-artifacts.rust-lang.org/rustc-builds/28bece3f394dc1aee54d00d6bb81b388ef6225ea/rust-docs-nightly-x86_64-unknown-linux-gnu.tar.xz and everything looks roughly right, I don't see any symbolic links in the archive and there are plenty of files in rust-docs/share/doc/rust/html/core. Is there something in particular I should be looking for?

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 10, 2022
@Mark-Simulacrum
Copy link
Member

No, not really. I was thinking you'd diff against the parent commit file list.

Anyway, cursory check seems good enough to me to go ahead, we can go further.

@bors r+

@bors
Copy link
Contributor

bors commented May 10, 2022

📌 Commit 5f4b174 has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 10, 2022
@jyn514
Copy link
Member Author

jyn514 commented May 10, 2022

ah, this is why symlinks didn't regress - we already dereference the link:

let link = t!(fs::read_link(src));

@bors
Copy link
Contributor

bors commented May 10, 2022

⌛ Testing commit 5f4b174 with merge 87fd70c...

@bors
Copy link
Contributor

bors commented May 10, 2022

☀️ Test successful - checks-actions
Approved by: Mark-Simulacrum
Pushing 87fd70c to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 10, 2022
@bors bors merged commit 87fd70c into rust-lang:master May 10, 2022
@rustbot rustbot added this to the 1.62.0 milestone May 10, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (87fd70c): comparison url.

Summary: This benchmark run did not return any relevant results.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

@jyn514 jyn514 deleted the faster-assemble branch May 10, 2022 07:37
bors added a commit to rust-lang-ci/rust that referenced this pull request May 10, 2022
…r=Mark-Simulacrum

Revert "Make "Assemble stage1 compiler" orders of magnitude faster"

Reverts rust-lang#96803. This caused `llvm-tools-nightly` to fail when installing with `rustup-toolchain-install-master` because of the presence of symlinks. I'm not sure how the symlinks got in there, but revert the PR for now while I figure it out.

r? `@Mark-Simulacrum` cc `@RalfJung`
@jyn514 jyn514 restored the faster-assemble branch May 11, 2022 04:54
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 19, 2022
…crum

Make "Assemble stage1 compiler" orders of magnitude faster (take 2)

This used to take upwards of 5 seconds for me locally. I found that the culprit was copying the downloaded LLVM shared object:
```
[22:28:03] Install "/home/jnelson/rust-lang/rust/build/x86_64-unknown-linux-gnu/ci-llvm/lib/libLLVM-14-rust-1.62.0-nightly.so" to "/home/jnelson/rust-lang/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libLLVM-14-rust-1.62.0-nightly.so"
[22:28:09]   c Sysroot { compiler: Compiler { stage: 1, host: x86_64-unknown-linux-gnu(x86_64-unknown-linux-gnu) } }
```

It turned out that `install()` used full copies unconditionally. Change it to try using a hard-link before falling back to copying.

- Panic if we generate a symbolic link in a tarball
- Change install to use copy internally, like in my previous PR
- Change copy to dereference symbolic links, which avoids the previous regression in rust-lang#96803.

I also took the liberty of fixing `x dist llvm-tools` to work even if you don't call `x build` previously.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants