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 cloning html render context #100271

Closed
wants to merge 1 commit into from

Conversation

Wardenfar
Copy link
Contributor

The issue was about cleaning the shared context in html rendering.
The problem was that the Context was clone for each item rendered.

I change the rendering process to not clone the context so the shared context do not require anymore to be in a std::rc::Rc

Feel free to give me feedback
This PR may impact performance: should we run perf-test ?

Resolves #82381

@rustbot rustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Aug 8, 2022
@rust-highfive
Copy link
Collaborator

r? @CraftSpider

(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 8, 2022
@rust-log-analyzer

This comment has been minimized.

@Kobzol
Copy link
Contributor

Kobzol commented Aug 8, 2022

@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 8, 2022
@bors
Copy link
Contributor

bors commented Aug 8, 2022

⌛ Trying commit 89c1ed6e040ff3e811ed1715404ece966238c3e7 with merge b4cf7bf90d47893ae5c2eb77817f496726eb8678...

@bors
Copy link
Contributor

bors commented Aug 8, 2022

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

@rust-timer
Copy link
Collaborator

Queued b4cf7bf90d47893ae5c2eb77817f496726eb8678 with parent f03ce30, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b4cf7bf90d47893ae5c2eb77817f496726eb8678): comparison url.

Instruction count

  • Primary benchmarks: 😿 relevant regressions found
  • Secondary benchmarks: no relevant changes found
mean1 max count2
Regressions 😿
(primary)
0.9% 1.9% 3
Regressions 😿
(secondary)
N/A N/A 0
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
N/A N/A 0
All 😿🎉 (primary) 0.9% 1.9% 3

Max RSS (memory usage)

Results
  • Primary benchmarks: 🎉 relevant improvement found
  • Secondary benchmarks: 🎉 relevant improvements found
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
N/A N/A 0
Improvements 🎉
(primary)
-1.8% -1.8% 1
Improvements 🎉
(secondary)
-1.8% -1.8% 2
All 😿🎉 (primary) -1.8% -1.8% 1

Cycles

Results
  • Primary benchmarks: 😿 relevant regressions found
  • Secondary benchmarks: no relevant changes found
mean1 max count2
Regressions 😿
(primary)
5.5% 7.8% 2
Regressions 😿
(secondary)
N/A N/A 0
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
N/A N/A 0
All 😿🎉 (primary) 5.5% 7.8% 2

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 may lead to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

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

Footnotes

  1. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 2 3

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Aug 8, 2022
@jyn514 jyn514 changed the title Rustfoc : stop cloning html render context Rustdoc : stop cloning html render context Aug 9, 2022
@Wardenfar
Copy link
Contributor Author

Do I have to do something ?

@jyn514
Copy link
Member

jyn514 commented Aug 20, 2022

r? @camelid

@rust-highfive rust-highfive assigned camelid and unassigned CraftSpider Aug 20, 2022
@bors
Copy link
Contributor

bors commented Aug 24, 2022

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

@camelid
Copy link
Member

camelid commented Aug 26, 2022

Thanks for doing this! I will do my best to look at soon. :)

@rustbot rustbot added the A-rustdoc-json Area: Rustdoc JSON backend label Aug 27, 2022
@bors
Copy link
Contributor

bors commented Aug 31, 2022

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

@camelid
Copy link
Member

camelid commented Sep 6, 2022

I was able to look at this today, and overall it looks very good! I will give it a full review within a few days.

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 for taking so long to review this!

My one concern is that you added several RefCells and Cells to the new ContextItemFrame struct and changed &mut Context to &Context everywhere. I don't see why this is necessary, and we've been trying really hard to move away from interior mutability. Is it possible to directly mutate ContextItemFrame through &mut Context instead?

If that's not possible, please let me know and we'll figure out how to go forward.

@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 Sep 14, 2022
@Wardenfar
Copy link
Contributor Author

Wardenfar commented Sep 15, 2022

@camelid
In a lot of places, when removing RefCell<Shared> the code no longer compiles with the borrow checker.
In the rendering/printing process, only the ContextItemFrame is mutated. To remove completely RefCell / Cell, you need to remove the ContextItemFrame from the Context struct (to allow &Context and &mut ContextItemFrame at the same time)

I tried today but Context is everywhere. This is why i choose to keep RefCell (but in a smaller part of the struct)

The other way is to rewrite places where the borrow checker fail, but this is a lot of time.

Thank you for your time !

@camelid
Copy link
Member

camelid commented Sep 17, 2022

Thanks for your reply!

Why do we need &Context and &mut ContextItemFrame simultaneously? Can't we have &mut Context and use that to get the item frames? I haven't looked at this code in a while, so apologies if I'm missing something.

@bors
Copy link
Contributor

bors commented Sep 20, 2022

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

@JohnCSimon
Copy link
Member

@Wardenfar
Ping from triage:
Can you address the comment from the reviewer and fix the merge conflicts?

FYI: when a PR is ready for review, send a message containing
@rustbot ready to switch to S-waiting-on-review so the PR is in the reviewer's backlog.

@Wardenfar
Copy link
Contributor Author

@JohnCSimon
Sorry I don't have time to work on it
Should I close the PR ?

@JohnCSimon
Copy link
Member

@JohnCSimon Sorry I don't have time to work on it Should I close the PR ?

I'll close it for you.
Please reopen when you are ready to continue with this.
Note: if you do please open the PR BEFORE you push to it, else you won't be able to reopen - this is a quirk of github.
Thanks for your contribution.

@rustbot label: +S-inactive

@JohnCSimon JohnCSimon closed this Nov 27, 2022
@rustbot rustbot added the S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. label Nov 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-json Area: Rustdoc JSON backend perf-regression Performance regression. S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

rustdoc: Get rid of shared mutable state in Context