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

Parallelize initial Rust download in bootstrap #110427

Merged
merged 4 commits into from
Apr 30, 2023

Conversation

Noratrieb
Copy link
Member

Parallelize the initial download of Rust in bootstrap.py

time ./x.py --help after rm -r build
Before: 33s
After: 27s

@rustbot
Copy link
Collaborator

rustbot commented Apr 16, 2023

r? @albertlarsan68

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Apr 16, 2023
@Noratrieb
Copy link
Member Author

Apparently we want to be python 2 compatible here, I'll fix that tomorrow.

@Noratrieb Noratrieb marked this pull request as draft April 16, 2023 20:20
@jyn514
Copy link
Member

jyn514 commented Apr 16, 2023

I think we might be able to drop python2 compat in bootstrap.py proper now that the x.py shim reexecs itself with python3.

@Noratrieb
Copy link
Member Author

I wasn't able to see this on my fast internet connection, but testing this on a slower one shows that the progress bars get pretty broken by the parallel download which is not ideal.

@Noratrieb
Copy link
Member Author

I made it Python 2.7 compatible and tested it manually using python2.7 x.py (patching x.py to not exec Python 3).

@Noratrieb Noratrieb marked this pull request as ready for review April 17, 2023 12:09
@albertlarsan68
Copy link
Member

Is the progress bar mess fixed?

@Noratrieb
Copy link
Member Author

Noratrieb commented Apr 17, 2023

Not really, I'm unsure about the best approach to it. I can try whether parallel downloads are faster on a fast internet connection (I wouldn't expect them to be faster on a slow one) and if no, just keep this part serial. If they are am advantage, I'll try find something.

@albertlarsan68 albertlarsan68 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 Apr 18, 2023
@Noratrieb
Copy link
Member Author

Inserting an exit() before building bootstrap

with a fast (480MiB/s) internet connection
serial download, parallel unpacking: 11s
parallel download, parallel unpacking: 10s
serial download, serial unpacking: 16s

with a less fast (60MiB/s) internet connection
serial download, parallel unpacking: 16s
parallel download, parallel unpacking: 22s (the terminal output from the download progress bars is completely broken)
serial download, serial unpacking: 26s

so the parallel download is actually worse for slow connections, probably because it reduces parallelism for the extraction phase since the downloads don't all complete at the same time

@Noratrieb Noratrieb 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 Apr 30, 2023
Copy link
Member

@albertlarsan68 albertlarsan68 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just one question/nit/potential improvement.

@Noratrieb Noratrieb force-pushed the parallel-bootstrap-startup branch from 38eb5a5 to e829adc Compare April 30, 2023 16:06
@albertlarsan68
Copy link
Member

Thanks for the PR!
@bors r+ rollup=iffy (touches core bootstrap code)

@bors
Copy link
Collaborator

bors commented Apr 30, 2023

📌 Commit e829adc819c55c0736bcdce948c53f2920adf5b1 has been approved by albertlarsan68

It is now in the queue for this repository.

@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 Apr 30, 2023
@bors
Copy link
Collaborator

bors commented Apr 30, 2023

⌛ Testing commit e829adc819c55c0736bcdce948c53f2920adf5b1 with merge 0a92164116464c739fa27fe5e2b820e598bdd7ca...

@Noratrieb
Copy link
Member Author

@bors r-

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 30, 2023
This is quite slow and embarassingly parallel, even in python.

This speeds up the initial bootstrap build by about 5-10s.
@rust-cloud-vms rust-cloud-vms bot force-pushed the parallel-bootstrap-startup branch from e829adc to a98968e Compare April 30, 2023 19:59
@Noratrieb
Copy link
Member Author

I quickly tested it locally again and it worked.
@bors r=albertlarsan68

@bors
Copy link
Collaborator

bors commented Apr 30, 2023

📌 Commit a98968e has been approved by albertlarsan68

It is now in the queue for this repository.

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 30, 2023
@bors
Copy link
Collaborator

bors commented Apr 30, 2023

⌛ Testing commit a98968e with merge 9ecda8d...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Apr 30, 2023

☀️ Test successful - checks-actions
Approved by: albertlarsan68
Pushing 9ecda8d to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 30, 2023
@bors bors merged commit 9ecda8d into rust-lang:master Apr 30, 2023
@rustbot rustbot added this to the 1.71.0 milestone Apr 30, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (9ecda8d): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.5% [-1.5%, -1.5%] 1
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

@823984418 823984418 mentioned this pull request May 1, 2023
@Zalathar
Copy link
Contributor

Zalathar commented May 1, 2023

This seems to be causing bootstrap to get stuck in a loop and unable to proceed on some systems.

I'm seeing problems on macOS, and #111046 reports similar problems on Windows.

@Zalathar
Copy link
Contributor

Zalathar commented May 1, 2023

It seems that multiprocessing requires the program's entry point to have been guarded by the if __name__ == '__main__': idiom.

(bootstrap.py uses that idiom, but x.py itself currently does not.)

If I edit x.py to wrap all the code in that if statement, bootstrap seems to work fine again.

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. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants