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: avoid many Symbol to String conversions. #91948

Merged
merged 7 commits into from
Jan 15, 2022

Conversation

nnethercote
Copy link
Contributor

@nnethercote nnethercote commented Dec 15, 2021

Particularly when constructing file paths and fully qualified paths.
This avoids a lot of allocations, speeding things up on almost all
examples.

r? @GuillaumeGomez

@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Dec 15, 2021
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 15, 2021
@nnethercote
Copy link
Contributor Author

In local measurements I see the following rustdoc improvements on rustc-perf:

  • instructions: up to 5% better
  • cycles: up to 8% better
  • wall-time: up to 10% better

@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 Dec 15, 2021
@bors
Copy link
Contributor

bors commented Dec 15, 2021

⌛ Trying commit ac09b579d88c408116eb91a197850a86e6fb7aed with merge c35f8646bbfb5c225d701c6fd49948b853c27202...

@camelid
Copy link
Member

camelid commented Dec 15, 2021

I guess we had the same idea at the same time: #91876 :P

I'll close that one since the tests are failing and this covers it.

src/librustdoc/clean/inline.rs Outdated Show resolved Hide resolved
src/librustdoc/html/format.rs Outdated Show resolved Hide resolved
src/librustdoc/html/format.rs Outdated Show resolved Hide resolved
src/librustdoc/html/render/print_item.rs Outdated Show resolved Hide resolved
src/librustdoc/html/tests.rs Outdated Show resolved Hide resolved
src/librustdoc/visit_ast.rs Outdated Show resolved Hide resolved
@camelid camelid self-assigned this Dec 15, 2021
@camelid camelid 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 Dec 15, 2021
@bors
Copy link
Contributor

bors commented Dec 15, 2021

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

@rust-timer
Copy link
Collaborator

Queued c35f8646bbfb5c225d701c6fd49948b853c27202 with parent 2f4da62, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (c35f8646bbfb5c225d701c6fd49948b853c27202): comparison url.

Summary: This change led to large relevant improvements 🎉 in compiler performance.

  • Large improvement in instruction counts (up to -3.7% on full builds of futures)

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. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR led to changes in compiler perf.

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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Dec 15, 2021
@nnethercote
Copy link
Contributor Author

Instruction counts and cycles show clear wins, smaller than I got locally, probably because I was profiling without jemalloc enabled. Wall times show no improvement in the default view, but if you show "insignificant" changes you can see up to 7%; I guess the wall times are so noisy in general that any non-huge change is considered insignificant.

@nnethercote
Copy link
Contributor Author

I have pushed an update that addresses most of the comments.

@GuillaumeGomez
Copy link
Member

This is super cool, thanks! Let's wait for @camelid's confirmation as well.

@camelid
Copy link
Member

camelid commented Dec 15, 2021

I'll review this soon.

Copy link
Member

@camelid camelid left a comment

Choose a reason for hiding this comment

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

Overall, this looks good, but I have some code quality concerns.

src/librustdoc/clean/inline.rs Outdated Show resolved Hide resolved
src/librustdoc/html/format.rs Outdated Show resolved Hide resolved
src/librustdoc/html/format.rs Outdated Show resolved Hide resolved
src/librustdoc/html/format.rs Outdated Show resolved Hide resolved
src/librustdoc/html/format.rs Outdated Show resolved Hide resolved
src/librustdoc/visit_ast.rs Outdated Show resolved Hide resolved
@camelid camelid removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 17, 2021
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jan 13, 2022
@camelid
Copy link
Member

camelid commented Jan 13, 2022

I just realized that I forgot to delete an outdated comment from an earlier commit (the one about 64 bytes is covers 99.9%+ of cases). Done.

@bors r=GuillaumeGomez rollup=never

@bors
Copy link
Contributor

bors commented Jan 13, 2022

📌 Commit 4848d5a059a242e9d691f94b070863d76a520a24 has been approved by GuillaumeGomez

@bors
Copy link
Contributor

bors commented Jan 14, 2022

☔ The latest upstream changes (presumably #92844) made this pull request unmergeable. Please resolve the merge conflicts.

@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 Jan 14, 2022
@camelid
Copy link
Member

camelid commented Jan 14, 2022

@bors p=1 (this is really conflict-prone)

nnethercote and others added 7 commits January 14, 2022 11:57
Particularly when constructing file paths and fully qualified paths.
This avoids a lot of allocations, speeding things up on almost all
examples.
I seem to recall that in general, it's best to request an allocation
with a size that's a power of 2. The low estimate of 5 was probably a
little too low as well.
@camelid
Copy link
Member

camelid commented Jan 14, 2022

@bors r=GuillaumeGomez rollup=never

@bors
Copy link
Contributor

bors commented Jan 14, 2022

📌 Commit c7147e4 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 14, 2022
@bors
Copy link
Contributor

bors commented Jan 14, 2022

⌛ Testing commit c7147e4 with merge b0ec3e0...

@bors
Copy link
Contributor

bors commented Jan 15, 2022

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 15, 2022
@bors bors merged commit b0ec3e0 into rust-lang:master Jan 15, 2022
@rustbot rustbot added this to the 1.60.0 milestone Jan 15, 2022
@nnethercote nnethercote deleted the rustdoc-more-Symbols branch January 15, 2022 00:41
@nnethercote nnethercote restored the rustdoc-more-Symbols branch January 15, 2022 00:41
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b0ec3e0): comparison url.

Summary: This change led to very large relevant improvements 🎉 in compiler performance.

  • Very large improvement in instruction counts (up to -5.5% on full builds of issue-46449)

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

@rustbot label: -perf-regression

@nnethercote nnethercote deleted the rustdoc-more-Symbols branch February 25, 2022 02:59
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-compiler Relevant to the compiler team, which will review and decide on the PR/issue. 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