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 precompiles generation II #48049

Merged

Conversation

petvana
Copy link
Member

@petvana petvana commented Dec 30, 2022

This follows up #47983 and introduce asynchronous read for repl precompiles. In contrast to IanButterworth@5ee671a?w=1 from @IanButterworth , it uses readavailable and BufferStream to handle end of lines correctly. It saves only a few seconds, but improves the fancy printing for impatient developers.

@petvana petvana added the domain:building Build system, or building Julia or its dependencies label Dec 30, 2022
@IanButterworth
Copy link
Sponsor Member

It saves only a few seconds

For me the gains are bigger

before #47983

Generating REPL precompile statements... 40/40
Executing precompile statements... 1756/1760
Precompilation complete. Summary:
Generation ──  77.218106 seconds 79.4016%
Execution ───  20.031916 seconds 20.5984%
Total ───────  97.250022 seconds

#47983

Collecting and executing precompile statements
└ Collect (Basic: ✓ 730, REPL 40/40: ✓ 1659) => Execute ✓ 1751
Precompilation complete. Summary:
Total ───────  80.336407 seconds

This PR

Collecting and executing precompile statements
└ Collect (Basic: ✓ 730, REPL 40/40: ✓ 1657) => Execute ✓ 1750
Precompilation complete. Summary:
Total ───────  64.902187 seconds

@petvana
Copy link
Member Author

petvana commented Dec 30, 2022

For me the gains are bigger

Half a minute, as advertised in the original PR 😉

@IanButterworth
Copy link
Sponsor Member

Seems good to me.

Does the switch to serial mode for debugging with stdout rather than devnull still work?

@petvana
Copy link
Member Author

petvana commented Dec 30, 2022

Does the switch to serial mode for debugging with stdout rather than devnull still work?

Not sure, what you mean by stdout rather than devnull, but the switch still works and those 3 steps are done in serial order.

@IanButterworth
Copy link
Sponsor Member

IanButterworth commented Dec 30, 2022

I just grouped all the debug options together at the top of the file to make it clearer. Seems to work for me, if you disable pretty printing, disable parallel, and enable repl input viewing.

edit: Had to move them to inside the module after stdout had been reinitialized

Copy link
Sponsor Member

@IanButterworth IanButterworth left a comment

Choose a reason for hiding this comment

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

Seems good to me, but might be good to have a @vtjnash review too

@IanButterworth
Copy link
Sponsor Member

Out of curiosity I reordered repl_script to have Profile then Pkg then the ones in this file and saw 5 seconds faster.

Not sure if it's worth doing as it breaks the ordering (could be a followup PR), but at least it makes sense that doing the larger workloads first helps parallelization

Collecting and executing precompile statements
└ Collect (Basic: ✓ 730, REPL 40/40: ✓ 1661) => Execute ✓ 1753
Precompilation complete. Summary:
Total ───────  60.710451 seconds

@giordano
Copy link
Contributor

what you mean by stdout rather than devnull

debug_output = devnull # or stdout

@petvana
Copy link
Member Author

petvana commented Dec 31, 2022

Out of curiosity I reordered repl_script to have Profile then Pkg then the ones in this file and saw 5 seconds faster.

I'm kind of surprised, it saved you so much time. I believe, we can reorder repl script as we want because it will remain deterministic.

@IanButterworth
Copy link
Sponsor Member

ok! Pushed

@IanButterworth
Copy link
Sponsor Member

Windows failures are unrelated. @vtjnash does this look ok to you?

@IanButterworth
Copy link
Sponsor Member

I'll merge as this appears to work as designed. If @vtjnash has any issue with the buffering design that can be addressed in a followup

@IanButterworth IanButterworth merged commit 4831361 into JuliaLang:master Jan 3, 2023
@maleadt
Copy link
Member

maleadt commented Jan 3, 2023

EDIT: I can't reproduce this, so let's hope it was a fluke 🙂


I just had a build hang (wasn't using the changes from this PR yet):

Collecting and executing precompile statements
└ Collect (Basic: ✓ 730, REPL 39/40: ◒ ) => Execute ◒ 494^C^C^C

As there was no CPU usage, but the main process was still happily spinning, I suspect this may be related to these parallel precompilation changes. The process also wasn't interruptible, i.e., CTRL-C is ignored (as you can see in the output). Are either of these issues known?

@StefanKarpinski
Copy link
Sponsor Member

We really need to get better at making ctrl-C work. I know that @vtjnash will tell me that it can't be made to work completely reliably, which, sucks, sure, but it can be made to work much better than it does and we should do that.

@IanButterworth
Copy link
Sponsor Member

@maleadt if you do hit it again, can you SIGINFO/SIGUSR1 profile it to see what it's doing. That's probably more reliable than getting a trace from an interrupt

@petvana
Copy link
Member Author

petvana commented Jan 3, 2023

I just had a build hang (wasn't using the changes from this PR yet):

I've noticed a hang when building without stdlibs, i.e., stdlibs = [] in sysimg.jl. It is reproduceble, but happened even before #47983. Thankfully, this can be fixed easily by disabling the whole REPL collection as have_repl = false.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Jan 9, 2023

LGTM. Copying streams (as done here) is one of the best actual use cases for readavailable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:building Build system, or building Julia or its dependencies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants