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: Stop textually replacing Self in doc links before resolving them #93805

Merged
merged 3 commits into from
Mar 6, 2022

Conversation

petrochenkov
Copy link
Contributor

Resolve it directly to a type / def-id instead.

Also never pass Self to Resolver, it is useless because it's guaranteed that no resolution will be found.

This is a pre-requisite for #83761.

@rustbot rustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Feb 9, 2022
@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 Feb 9, 2022
@GuillaumeGomez
Copy link
Member

Looks good to me, thanks! Better have @camelid take a look too.

@rust-log-analyzer

This comment has been minimized.

@petrochenkov
Copy link
Contributor Author

r? @camelid

@camelid
Copy link
Member

camelid commented Feb 9, 2022

Thanks for doing this! I've been wanting to fix this hack for a while. I'll review this soon.

@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 Feb 11, 2022
…g them

Resolve it directly to a type / def-id instead.

Also never pass `Self` to `Resolver`, it is useless because it's guaranteed that no resolution will be found.
@petrochenkov
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot 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 Feb 13, 2022
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.

Sorry this took so long. I only have one question; other than that, this looks great!

@@ -343,6 +346,7 @@ impl ItemFragment {

#[derive(Clone, Debug, Hash, PartialEq, Eq)]
struct ResolutionInfo {
item_id: ItemId,
module_id: DefId,
Copy link
Member

Choose a reason for hiding this comment

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

Just wondering, could we remove module_id now that we have item_id? Not necessary to address now, but I wanted to bring it up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not without replacing it with some extra data, I tried it but wasn't able to do it right away.

The first issue is that rustdoc (unlike rustc) resolves paths differently in inner and outer attributes.
So item_id will be the same for inner and outer paths, but their module_ids will be different.

There are also may be nuances with how item_id and module_id are assigned for reexports, but I didn't investigate it.

I agree that ideally we would have an item_id and some additional orthogonal flags here instead of the module_id.

@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 Mar 3, 2022
@petrochenkov petrochenkov 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 Mar 4, 2022
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.

Thanks again!

@camelid
Copy link
Member

camelid commented Mar 6, 2022

@bors r=camelid,GuillaumeGomez

@bors
Copy link
Contributor

bors commented Mar 6, 2022

📌 Commit 25c5e39 has been approved by camelid,GuillaumeGomez

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (1661e4c): comparison url.

Summary: This benchmark run shows 13 relevant regressions 😿 to instruction counts.

  • Arithmetic mean of relevant regressions: 0.3%
  • Arithmetic mean of all relevant changes: 0.3%
  • Largest regression in instruction counts: 1.0% on full builds of serde doc

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

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression

@rustbot rustbot added the perf-regression Performance regression. label Mar 6, 2022
@camelid
Copy link
Member

camelid commented Mar 6, 2022

Wow, that regression is way higher than I expected. I thought this PR might improve perf. I still think this change is worth the regression, but do you know what caused the regression? Maybe the extra item_id fields?

@petrochenkov
Copy link
Contributor Author

I'll try to benchmark this, but not earlier than landing the last part of #83761.

@pnkfelix
Copy link
Member

pnkfelix commented Mar 9, 2022

It looks to me like collect_intra_doc_links got 8.8% slower on serde doc. It took 0.137 s before this PR, and 0.149 s after this PR.

If I had to guess, I would assume the slowdown is due to the extra item_id field that was added to ResolutionInfo; the latter is used as a key in a hashtable in the LinkCollector. (maybe the size of ResolutionInfo passed some threshold that causes cache line problems? Just guessing at this point.)

Its funny that the slowdown only registered on serde doc though.

If you want to look further, @petrochenkov , then that would be great. But I don't think we need to spend too much time dissecting this, and I'm going to treat it as triaged.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Mar 9, 2022
@camelid
Copy link
Member

camelid commented Mar 10, 2022

ResolutionInfo did increase from 64 bytes to 80 bytes, so the cache line theory sounds quite plausible (e.g., since it's no longer a power of two).

camelid added a commit to camelid/rust that referenced this pull request Aug 10, 2022
This issue was most likely fixed by rust-lang#93805.
compiler-errors added a commit to compiler-errors/rust that referenced this pull request Aug 10, 2022
Add regression test for rust-lang#93205

Closes rust-lang#93205.

This issue was most likely fixed by rust-lang#93805.
MarijnS95 added a commit to ash-rs/ash that referenced this pull request Aug 11, 2022
The report at rust-lang/rust#93205 was closed
as it has presumably been fixed in
rust-lang/rust#93805 which has long trickled
down into stable releases, and I cannot reproduce the issue on `1.62.1`
anymore (latest stable as of writing) 🎉

This workaround was originally added in #559.
Ralith pushed a commit to ash-rs/ash that referenced this pull request Aug 11, 2022
The report at rust-lang/rust#93205 was closed
as it has presumably been fixed in
rust-lang/rust#93805 which has long trickled
down into stable releases, and I cannot reproduce the issue on `1.62.1`
anymore (latest stable as of writing) 🎉

This workaround was originally added in #559.
MarijnS95 added a commit to ash-rs/ash that referenced this pull request Aug 11, 2022
The report at rust-lang/rust#93205 was closed
as it has presumably been fixed in
rust-lang/rust#93805 which has long trickled
down into stable releases, and I cannot reproduce the issue on `1.62.1`
anymore (latest stable as of writing) 🎉

This workaround was originally added in #559.
MarijnS95 added a commit to ash-rs/ash that referenced this pull request Aug 12, 2022
The report at rust-lang/rust#93205 was closed
as it has presumably been fixed in
rust-lang/rust#93805 which has long trickled
down into stable releases, and I cannot reproduce the issue on `1.62.1`
anymore (latest stable as of writing) 🎉

This workaround was originally added in #559.
MarijnS95 added a commit to ash-rs/ash that referenced this pull request Sep 5, 2022
The report at rust-lang/rust#93205 was closed
as it has presumably been fixed in
rust-lang/rust#93805 which has long trickled
down into stable releases, and I cannot reproduce the issue on `1.62.1`
anymore (latest stable as of writing) 🎉

This workaround was originally added in #559.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Mar 21, 2023
…omez

rustdoc: Cleanup parent module tracking for doc links

Keep ids of the documented items themselves, not their parent modules. Parent modules can be retreived from those ids when necessary.

Fixes rust-lang#108501.
That issue could be fixed in a more local way, but this refactoring is something that I wanted to do since rust-lang#93805 anyway.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 21, 2023
…omez

rustdoc: Cleanup parent module tracking for doc links

Keep ids of the documented items themselves, not their parent modules. Parent modules can be retreived from those ids when necessary.

Fixes rust-lang#108501.
That issue could be fixed in a more local way, but this refactoring is something that I wanted to do since rust-lang#93805 anyway.
Noratrieb added a commit to Noratrieb/rust that referenced this pull request Mar 21, 2023
…omez

rustdoc: Cleanup parent module tracking for doc links

Keep ids of the documented items themselves, not their parent modules. Parent modules can be retreived from those ids when necessary.

Fixes rust-lang#108501.
That issue could be fixed in a more local way, but this refactoring is something that I wanted to do since rust-lang#93805 anyway.
Noratrieb added a commit to Noratrieb/rust that referenced this pull request Mar 21, 2023
…omez

rustdoc: Cleanup parent module tracking for doc links

Keep ids of the documented items themselves, not their parent modules. Parent modules can be retreived from those ids when necessary.

Fixes rust-lang#108501.
That issue could be fixed in a more local way, but this refactoring is something that I wanted to do since rust-lang#93805 anyway.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Mar 21, 2023
…omez

rustdoc: Cleanup parent module tracking for doc links

Keep ids of the documented items themselves, not their parent modules. Parent modules can be retreived from those ids when necessary.

Fixes rust-lang#108501.
That issue could be fixed in a more local way, but this refactoring is something that I wanted to do since rust-lang#93805 anyway.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Mar 22, 2023
…omez

rustdoc: Cleanup parent module tracking for doc links

Keep ids of the documented items themselves, not their parent modules. Parent modules can be retreived from those ids when necessary.

Fixes rust-lang#108501.
That issue could be fixed in a more local way, but this refactoring is something that I wanted to do since rust-lang#93805 anyway.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Mar 22, 2023
…omez

rustdoc: Cleanup parent module tracking for doc links

Keep ids of the documented items themselves, not their parent modules. Parent modules can be retreived from those ids when necessary.

Fixes rust-lang#108501.
That issue could be fixed in a more local way, but this refactoring is something that I wanted to do since rust-lang#93805 anyway.
oli-obk pushed a commit to oli-obk/miri that referenced this pull request Mar 23, 2023
rustdoc: Cleanup parent module tracking for doc links

Keep ids of the documented items themselves, not their parent modules. Parent modules can be retreived from those ids when necessary.

Fixes rust-lang/rust#108501.
That issue could be fixed in a more local way, but this refactoring is something that I wanted to do since rust-lang/rust#93805 anyway.
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. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. 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