-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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 rustdoc rendering #82741
Comments
This is a duplicate of #82294 I think. |
Maybe I'll add this issue description to the description of the other one? |
I would like to have a check-list of things to do before we can parallelize. |
Personally I think because this is blocked on |
Okay, that makes sense 👍 |
jobserver and/or |
@the8472 hmm, I'm not sure -j makes sense in this context - normally -j is intended for cpu-bound tasks, like compiling. But this is almost purely IO, so we should be able to potentially have thousands of files being written at once without too much resource contention. |
Oh, I might be misunderstanding - @camelid are you using "rendering" to mean "generating the HTML" or "writing the HTML to disk"? I was assuming the latter. |
Both, but mainly generating the HTML. |
Ok, in that case |
That's weird! |
I would note that exceeding available work actors for any dimension will cause queuing or thrashing, whether that is IO or CPU; -j as a cap should be set to min(CPUs, maxconcurrentIOs) - more or less; unless more sophisticated things are available - so treating -j as 'CPU only' is likely to be problematic - particularly on esoteric machines where IO requires CPU to perform. |
rustdoc: reduce number of copies when using parallel IO This is Windows-only for now; I was getting really bad slowdowns from this on linux for some reason. Helps with rust-lang#82741. Follow-up to rust-lang#60971.
Note that this was actually a performance regression on linux for some reason: https://perf.rust-lang.org/compare.html?start=9faa714154dbc03faa174a7d4f72d6bbbfd61f7c&end=853cac83440612cc4564f31c8b0ea39ef4389bf1 |
That link shows total CPU instructions spent, across all cores. That's expected to get worse when you parallelize things due to communication overhead. But wall-time should go down, which didn't happen if you switch to those results. But that PR only parallelizes IO, right? I.e. it doesn't parallelize the CPU-heavy parts, like querying the compiler internals or perhaps compression (if any). Write IO is fast on linux because it all goes into the page-cache and written out in the background by separate kernel threads. You're not actually waiting on disk IO. So there's not much to gain from parallelizing that. Windows might be different due to anti-virus running synchronously when you write files. |
Oh! I didn't realize writes happen asychronously. Yeah, this probably doesn't have much benefit on Linux then (maybe MacOS would benefit though?) |
I and others would like to parallelize rustdoc rendering. It is "embarrassingly parallel" ... except that rustdoc has some technical debt in the form of global mutable state that will have to be dealt with first.
Steps
CURRENT_DEPTH
thread-local (rustdoc: Get rid ofCURRENT_DEPTH
thread-local variable #82742)Span
etc. Send and SyncRwLock
instead ofRefCell
forSharedContext
fields (or makeContext
, and by extensionSharedContext
, Send and Sync some other way)rayon
cc @rylev @jyn514
cc https://rust-lang.zulipchat.com/#narrow/stream/247081-t-compiler.2Fperformance/topic/windows-rs.20perf/near/226957262 (was going to open this issue anyway, but noticed this discussion so thought I'd link to it)
The text was updated successfully, but these errors were encountered: