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

rustdoc: reduce number of copies when using parallel IO #88219

Merged
merged 1 commit into from
Sep 16, 2021

Conversation

jyn514
Copy link
Member

@jyn514 jyn514 commented Aug 22, 2021

This is Windows-only for now; I was getting really bad slowdowns from this on linux for some reason.

Helps with #82741. Follow-up to #60971.

@jyn514 jyn514 added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. labels Aug 22, 2021
@rust-highfive
Copy link
Collaborator

r? @GuillaumeGomez

(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 Aug 22, 2021
@jyn514
Copy link
Member Author

jyn514 commented Aug 22, 2021

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 22, 2021
@bors
Copy link
Contributor

bors commented Aug 22, 2021

⌛ Trying commit a8956557448a362f90e454eaaf915ecc8d2af9b9 with merge 853cac83440612cc4564f31c8b0ea39ef4389bf1...

@bors
Copy link
Contributor

bors commented Aug 22, 2021

☀️ Try build successful - checks-actions
Build commit: 853cac83440612cc4564f31c8b0ea39ef4389bf1 (853cac83440612cc4564f31c8b0ea39ef4389bf1)

@rust-timer
Copy link
Collaborator

Queued 853cac83440612cc4564f31c8b0ea39ef4389bf1 with parent 9faa714, future comparison URL.

// A possible future enhancement after more detailed profiling would
// be to create the file sync so errors are reported eagerly.
let path = path.as_ref().to_path_buf();
let contents = contents.as_ref().to_vec();
let sender = self.errors.clone().expect("can't write after closing");
rayon::spawn(move || {
Copy link
Member

Choose a reason for hiding this comment

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

Rayon isn't designed for use with blocking IO (https://docs.rs/rayon/1.5.1/rayon/fn.join.html#warning-about-blocking-io). I think it would be a good idea to change this to use a threadpool.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahhh, that explains why it was so much slower locally. Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

Wait, I'm confused - that warning is specifically on join, and spawn says it already uses a threadpool:

Fires off a task into the Rayon threadpool in the “static” or “global” scope.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (853cac83440612cc4564f31c8b0ea39ef4389bf1): comparison url.

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

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

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf -perf-regression

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 22, 2021
Copy link
Member Author

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

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

Looks like this was not a perf improvement, although I'm not sure why ... I'll change this to only land the first commit for now (Remove unnecessary copies when using parallel IO) and come back to this once it uses the updated version of DocFS rustup is using: #60971 (comment)

src/librustdoc/html/render/write_shared.rs Outdated Show resolved Hide resolved
@jyn514 jyn514 force-pushed the parallel-io branch 2 times, most recently from ff16450 to 77a5f5a Compare August 22, 2021 15:38
@jyn514 jyn514 changed the title [experiment] rustdoc: use parallel IO on all platforms, not just windows rustdoc: reduce number of copies when using parallel IO Aug 22, 2021
@jyn514 jyn514 marked this pull request as ready for review August 22, 2021 15:40
src/librustdoc/docfs.rs Outdated Show resolved Hide resolved
Previously, rustdoc was making lots of copies of temporary owned values.
Now, it uses the owned value wherever possible.
@jyn514 jyn514 removed the S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. label Aug 26, 2021
@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 13, 2021
@jyn514
Copy link
Member Author

jyn514 commented Sep 16, 2021

ping @GuillaumeGomez - do you know when you'll get a chance to review this?

@GuillaumeGomez
Copy link
Member

I was waiting for a new perf run. Reviewing anyway. :)

@jyn514
Copy link
Member Author

jyn514 commented Sep 16, 2021

@GuillaumeGomez this change has no effect on Linux, so I can't test it using perf.rlo.

@bors r=GuillaumeGomez

@bors
Copy link
Contributor

bors commented Sep 16, 2021

📌 Commit 5651192 has been approved by GuillaumeGomez

@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 Sep 16, 2021
@bors
Copy link
Contributor

bors commented Sep 16, 2021

⌛ Testing commit 5651192 with merge d1d8145...

@bors
Copy link
Contributor

bors commented Sep 16, 2021

☀️ Test successful - checks-actions
Approved by: GuillaumeGomez
Pushing d1d8145 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 16, 2021
@bors bors merged commit d1d8145 into rust-lang:master Sep 16, 2021
@rustbot rustbot added this to the 1.57.0 milestone Sep 16, 2021
@jyn514 jyn514 deleted the parallel-io branch September 16, 2021 16:56
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (d1d8145): comparison url.

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

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

@rustbot label: -perf-regression

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-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants