Skip to content

Merge DocContext.{ty,lt,ct}_substs into one map #90443

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

Merged
merged 3 commits into from
Nov 9, 2021

Conversation

camelid
Copy link
Member

@camelid camelid commented Oct 31, 2021

It should be impossible to have more than one entry with a particular
key across the three maps, so they should be one map. In addition to
making it impossible for multiple entries to exist, this should improve
memory usage since now only one map is allocated on the stack and heap.

r? @GuillaumeGomez

@camelid camelid added C-cleanup Category: PRs that clean code up or issues documenting cleanup. I-compilemem Issue: Problems and improvements with respect to memory usage during compilation. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Oct 31, 2021
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 31, 2021
@camelid
Copy link
Member Author

camelid commented Oct 31, 2021

It's probably best to review this commit-by-commit, and potentially with whitespace hidden.

@@ -222,7 +222,7 @@ impl Clean<Lifetime> for hir::Lifetime {
| rl::Region::Free(_, node_id),
) = def
{
if let Some(lt) = cx.lt_substs.get(&node_id).cloned() {
if let Some(lt) = cx.substs.get(&node_id).and_then(|p| p.as_lt()).cloned() {
Copy link
Member Author

Choose a reason for hiding this comment

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

I could've made this unwrap the Option returned by as_lt since it's a rustdoc bug for it to be None here, but it seemed simpler to just use and_then. Let me know if you want me to use unwrap as a sort of assertion. (Likewise with as_ty below.)

Copy link
Member

Choose a reason for hiding this comment

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

I guess it's fine... Maybe add a FIXME on it so we can come back to it later on?

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's either leave it as-is or switch it to unwrap. I don't think it's worth a FIXME either way, and it's not actionable.

@camelid
Copy link
Member Author

camelid commented Oct 31, 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 Oct 31, 2021
@bors
Copy link
Collaborator

bors commented Oct 31, 2021

⌛ Trying commit 85d93c66d09ac8f793166ad190c1e3ba29cff528 with merge 57ef206d81386eab59b1c32b9e291ae1010c7f8e...

@rust-log-analyzer

This comment has been minimized.

@camelid
Copy link
Member Author

camelid commented Oct 31, 2021

Hmm, somehow I left trailing whitespace...

It should be impossible to have more than one entry with a particular
key across the three maps, so they should be one map. In addition to
making it impossible for multiple entries to exist, this should improve
memory usage since now only one map is allocated on the stack and heap.
@bors
Copy link
Collaborator

bors commented Oct 31, 2021

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

@rust-timer
Copy link
Collaborator

Queued 57ef206d81386eab59b1c32b9e291ae1010c7f8e with parent 68b554e, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (57ef206d81386eab59b1c32b9e291ae1010c7f8e): 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. 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 removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 31, 2021
@camelid camelid added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Nov 1, 2021
@GuillaumeGomez
Copy link
Member

There doesn't seem to have any memory usage to be displayed in the performance comparison... Kinda hard to judge if your PR has an impact on it haha.

@GuillaumeGomez
Copy link
Member

Otherwise the code looks good to me, but I'd be really interested about the RSS usage change.

@camelid
Copy link
Member Author

camelid commented Nov 1, 2021

@GuillaumeGomez There's a max-rss comparison on the page rust-timer links to: https://perf.rust-lang.org/compare.html?start=68b554e6af18726fe6fa8de2134c59c441e0b019&end=57ef206d81386eab59b1c32b9e291ae1010c7f8e&stat=max-rss. There are some regressions for whatever reason, but it says they are all insignificant.

@GuillaumeGomez
Copy link
Member

Oh right, I forgot it was "hidden". So that still seems surprising that the memory usage grows in here...

@camelid
Copy link
Member Author

camelid commented Nov 1, 2021

Oh right, I forgot it was "hidden". So that still seems surprising that the memory usage grows in here...

I wonder if it's because an enum is being stored, so there's an extra tag? We should probably find a way to get rid of these tables at some point too.

@camelid camelid removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Nov 2, 2021
@GuillaumeGomez
Copy link
Member

Looks good to me, thanks! We can look for a way to remove the tables in another PR.

@bors: r+

@bors
Copy link
Collaborator

bors commented Nov 8, 2021

📌 Commit 5a77f30 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 Nov 8, 2021
@camelid
Copy link
Member Author

camelid commented Nov 8, 2021

@bors rollup=never (just in case the max-rss changes are real)

@bors
Copy link
Collaborator

bors commented Nov 8, 2021

⌛ Testing commit 5a77f30 with merge 5154727...

@bors
Copy link
Collaborator

bors commented Nov 9, 2021

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 9, 2021
@bors bors merged commit 5154727 into rust-lang:master Nov 9, 2021
@rustbot rustbot added this to the 1.58.0 milestone Nov 9, 2021
@camelid camelid deleted the rustdoc-subst branch November 9, 2021 01:01
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (5154727): comparison url.

Summary: This change led to moderate relevant regressions 😿 in compiler performance.

  • Moderate regression in instruction counts (up to 0.5% on full builds of deeply-nested-async)

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 Nov 9, 2021
@camelid
Copy link
Member Author

camelid commented Nov 9, 2021

The instruction count regressions that were reported are spurious—this change doesn't touch the compiler.

Good news: no significant max-rss changes, so the regression reported previously was probably spurious.

@camelid camelid added I-compilemem Issue: Problems and improvements with respect to memory usage during compilation. and removed I-compilemem Issue: Problems and improvements with respect to memory usage during compilation. perf-regression Performance regression. labels Nov 9, 2021
@camelid
Copy link
Member Author

camelid commented Nov 9, 2021

A bunch of very small instruction count improvements for doc builds though!

image

@rylev
Copy link
Member

rylev commented Nov 9, 2021

I'm adding back the perf-regression as its currently our only way of tracking interesting perf related cases. Don't worry about actually looking into this. The perf team will want to investigate why this change to rustdoc led to fairly significant changes in non-noisy test cases. We should not be spurious changes that are this large.

@rustbot label: +perf-regression

cc @Mark-Simulacrum

@rustbot rustbot added the perf-regression Performance regression. label Nov 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. 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.

8 participants