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: Merge source code pages HTML elements together #100429

Merged
merged 3 commits into from
Aug 14, 2022

Conversation

GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented Aug 11, 2022

We realized that the HTML generated for the source code pages could be improved quite a lot. This PR is a first pass toward this goal. Some explanations: it merges similar classes elements (even when there are white characters in between).

There is an exception to this: if this is an ident, I also merged it with "unclassified" elements. This part is up to debate and can be very easily removed as the check is performed in one place (in the can_merge function).

EDIT: The ident is now only kept in the code for the span it contains but it is not rendered into the HTML.

So now some numbers:

For these ones, on each page, I run this JS: document.getElementsByTagName('*').length. The goal is to count the number of DOM elements. I took some pages that seemed big, but don't hesitate to check some others.

file name before this PR with this PR diff without ident diff
std/lib.rs.html (source link on std crate page) 3455 2776 20.7% 2387 31%
alloc/vec/mod.rs.html (source on Vec type page) 11012 8084 26.6% 6682 39.4%
alloc/string.rs.html (source on String type page) 10800 8214 24% 6712 37.9%
std/sync/mutex.rs.html (source on Mutex type page) 2953 2403 18.7% 2139 27.6%

You can test it here.

cc @jsha
r? @notriddle

@GuillaumeGomez GuillaumeGomez added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-rustdoc-ui Area: rustdoc UI (generated HTML) labels Aug 11, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 11, 2022
@GuillaumeGomez GuillaumeGomez changed the title rustdoc: Merge HTML elements together rustdoc: Merge source code pages HTML elements together Aug 11, 2022
@notriddle
Copy link
Contributor

Is this blocked on #100409, or does it replace that PR?

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
Copy link
Member Author

Is this blocked on #100409, or does it replace that PR?

It's a separate one, but I'll need to fix conflicts on the tests if it is merged first.

@GuillaumeGomez
Copy link
Member Author

Fixed the format issue.

@rustbot
Copy link
Collaborator

rustbot commented Aug 12, 2022

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

@jsha
Copy link
Contributor

jsha commented Aug 12, 2022

Are there some unrelated changes in here related to type aliases?

@GuillaumeGomez
Copy link
Member Author

Yes completely, I was working on something else and pushed to the wrong branch. It is now fixed.

@rustbot
Copy link
Collaborator

rustbot commented Aug 12, 2022

A change occurred in the Ayu theme.

cc @Cldfire

@GuillaumeGomez
Copy link
Member Author

I updated the online demo, added the new numbers. So in short: we need to keep Class::Ident around because we need the Span but I don't render it into the HTML anymore. The difference in the DOM size is quite big.

@GuillaumeGomez GuillaumeGomez force-pushed the merge-html-elements-together branch 2 times, most recently from e799af3 to efa9532 Compare August 12, 2022 18:46
@bors
Copy link
Contributor

bors commented Aug 12, 2022

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

@GuillaumeGomez
Copy link
Member Author

Fixed the merge conflict with the op class removal.

@notriddle
Copy link
Contributor

@bors r+ rollup=never

@bors
Copy link
Contributor

bors commented Aug 13, 2022

📌 Commit 8ed674c0f5161ff189d8a073a405ba8610056545 has been approved by notriddle

It is now in the queue for this repository.

@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 Aug 13, 2022
@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Aug 14, 2022
@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez
Copy link
Member Author

@bors r=notriddle

@bors
Copy link
Contributor

bors commented Aug 14, 2022

📌 Commit 6e574e1 has been approved by notriddle

It is now in the queue for this repository.

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

bors commented Aug 14, 2022

⌛ Testing commit 6e574e1 with merge 801821d...

@bors
Copy link
Contributor

bors commented Aug 14, 2022

☀️ Test successful - checks-actions
Approved by: notriddle
Pushing 801821d to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 14, 2022
@bors bors merged commit 801821d into rust-lang:master Aug 14, 2022
@rustbot rustbot added this to the 1.65.0 milestone Aug 14, 2022
@GuillaumeGomez GuillaumeGomez deleted the merge-html-elements-together branch August 14, 2022 16:58
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (801821d): comparison url.

Instruction count

  • Primary benchmarks: ❌ relevant regressions found
  • Secondary benchmarks: ❌ relevant regressions found
mean1 max count2
Regressions ❌
(primary)
0.6% 1.4% 12
Regressions ❌
(secondary)
1.8% 3.1% 8
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.6% 1.4% 12

Max RSS (memory usage)

Results
  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: mixed results
mean1 max count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.5% 1.5% 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.3% -2.3% 1
All ❌✅ (primary) - - 0

Cycles

Results
  • Primary benchmarks: ❌ relevant regression found
  • Secondary benchmarks: ❌ relevant regression found
mean1 max count2
Regressions ❌
(primary)
3.7% 3.7% 1
Regressions ❌
(secondary)
3.1% 3.1% 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.7% 3.7% 1

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
cc @rust-lang/wg-compiler-performance

Footnotes

  1. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 2 3

@rustbot rustbot added the perf-regression Performance regression. label Aug 14, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 21, 2022
…otriddle

rustdoc: Merge source code pages HTML elements together v2

This is the follow-up of rust-lang#100429.

I strongly recommend to review it one commit at a time because otherwise it's a lot at once.

For these ones, on each page, I run this JS: `document.getElementsByTagName('*').length`. The goal is to count the number of DOM elements. I took some pages that seemed big, but don't hesitate to check some others. I also added the "starting point" because it's quite nice to see how much the page was reduced thanks to these two PRs.

| file name | before rust-lang#100429 | before this PR | with this PR | diff |
|-|-|-|-|-|
| std/lib.rs.html (source link on std crate page) | 3455 | 2332 | 1772 | 24% |
| alloc/vec/mod.rs.html (source on Vec type page) | 11012 | 5982 | 5833 | 2.5% |
| alloc/string.rs.html (source on String type page) | 10800 | 6010 | 5822 | 3.2% |
| std/sync/mutex.rs.html (source on Mutex type page) | 2953 | 2041 | 2038 | 0.1% |

So unsurprisingly, the more attributes you have, the bigger the difference.

You can test it [here](https://rustdoc.crud.net/imperio/reduce-span-v2/src/std/lib.rs.html).

cc `@jsha`
r? `@notriddle`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 21, 2022
…otriddle

rustdoc: Merge source code pages HTML elements together v2

This is the follow-up of rust-lang#100429.

I strongly recommend to review it one commit at a time because otherwise it's a lot at once.

For these ones, on each page, I run this JS: `document.getElementsByTagName('*').length`. The goal is to count the number of DOM elements. I took some pages that seemed big, but don't hesitate to check some others. I also added the "starting point" because it's quite nice to see how much the page was reduced thanks to these two PRs.

| file name | before rust-lang#100429 | before this PR | with this PR | diff |
|-|-|-|-|-|
| std/lib.rs.html (source link on std crate page) | 3455 | 2332 | 1772 | 24% |
| alloc/vec/mod.rs.html (source on Vec type page) | 11012 | 5982 | 5833 | 2.5% |
| alloc/string.rs.html (source on String type page) | 10800 | 6010 | 5822 | 3.2% |
| std/sync/mutex.rs.html (source on Mutex type page) | 2953 | 2041 | 2038 | 0.1% |

So unsurprisingly, the more attributes you have, the bigger the difference.

You can test it [here](https://rustdoc.crud.net/imperio/reduce-span-v2/src/std/lib.rs.html).

cc ``@jsha``
r? ``@notriddle``
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 21, 2022
…otriddle

rustdoc: Merge source code pages HTML elements together v2

This is the follow-up of rust-lang#100429.

I strongly recommend to review it one commit at a time because otherwise it's a lot at once.

For these ones, on each page, I run this JS: `document.getElementsByTagName('*').length`. The goal is to count the number of DOM elements. I took some pages that seemed big, but don't hesitate to check some others. I also added the "starting point" because it's quite nice to see how much the page was reduced thanks to these two PRs.

| file name | before rust-lang#100429 | before this PR | with this PR | diff |
|-|-|-|-|-|
| std/lib.rs.html (source link on std crate page) | 3455 | 2332 | 1772 | 24% |
| alloc/vec/mod.rs.html (source on Vec type page) | 11012 | 5982 | 5833 | 2.5% |
| alloc/string.rs.html (source on String type page) | 10800 | 6010 | 5822 | 3.2% |
| std/sync/mutex.rs.html (source on Mutex type page) | 2953 | 2041 | 2038 | 0.1% |

So unsurprisingly, the more attributes you have, the bigger the difference.

You can test it [here](https://rustdoc.crud.net/imperio/reduce-span-v2/src/std/lib.rs.html).

cc ```@jsha```
r? ```@notriddle```
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 21, 2022
…otriddle

rustdoc: Merge source code pages HTML elements together v2

This is the follow-up of rust-lang#100429.

I strongly recommend to review it one commit at a time because otherwise it's a lot at once.

For these ones, on each page, I run this JS: `document.getElementsByTagName('*').length`. The goal is to count the number of DOM elements. I took some pages that seemed big, but don't hesitate to check some others. I also added the "starting point" because it's quite nice to see how much the page was reduced thanks to these two PRs.

| file name | before rust-lang#100429 | before this PR | with this PR | diff |
|-|-|-|-|-|
| std/lib.rs.html (source link on std crate page) | 3455 | 2332 | 1772 | 24% |
| alloc/vec/mod.rs.html (source on Vec type page) | 11012 | 5982 | 5833 | 2.5% |
| alloc/string.rs.html (source on String type page) | 10800 | 6010 | 5822 | 3.2% |
| std/sync/mutex.rs.html (source on Mutex type page) | 2953 | 2041 | 2038 | 0.1% |

So unsurprisingly, the more attributes you have, the bigger the difference.

You can test it [here](https://rustdoc.crud.net/imperio/reduce-span-v2/src/std/lib.rs.html).

cc ````@jsha````
r? ````@notriddle````
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 21, 2022
…otriddle

rustdoc: Merge source code pages HTML elements together v2

This is the follow-up of rust-lang#100429.

I strongly recommend to review it one commit at a time because otherwise it's a lot at once.

For these ones, on each page, I run this JS: `document.getElementsByTagName('*').length`. The goal is to count the number of DOM elements. I took some pages that seemed big, but don't hesitate to check some others. I also added the "starting point" because it's quite nice to see how much the page was reduced thanks to these two PRs.

| file name | before rust-lang#100429 | before this PR | with this PR | diff |
|-|-|-|-|-|
| std/lib.rs.html (source link on std crate page) | 3455 | 2332 | 1772 | 24% |
| alloc/vec/mod.rs.html (source on Vec type page) | 11012 | 5982 | 5833 | 2.5% |
| alloc/string.rs.html (source on String type page) | 10800 | 6010 | 5822 | 3.2% |
| std/sync/mutex.rs.html (source on Mutex type page) | 2953 | 2041 | 2038 | 0.1% |

So unsurprisingly, the more attributes you have, the bigger the difference.

You can test it [here](https://rustdoc.crud.net/imperio/reduce-span-v2/src/std/lib.rs.html).

cc `````@jsha`````
r? `````@notriddle`````
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 21, 2022
…otriddle

rustdoc: Merge source code pages HTML elements together v2

This is the follow-up of rust-lang#100429.

I strongly recommend to review it one commit at a time because otherwise it's a lot at once.

For these ones, on each page, I run this JS: `document.getElementsByTagName('*').length`. The goal is to count the number of DOM elements. I took some pages that seemed big, but don't hesitate to check some others. I also added the "starting point" because it's quite nice to see how much the page was reduced thanks to these two PRs.

| file name | before rust-lang#100429 | before this PR | with this PR | diff |
|-|-|-|-|-|
| std/lib.rs.html (source link on std crate page) | 3455 | 2332 | 1772 | 24% |
| alloc/vec/mod.rs.html (source on Vec type page) | 11012 | 5982 | 5833 | 2.5% |
| alloc/string.rs.html (source on String type page) | 10800 | 6010 | 5822 | 3.2% |
| std/sync/mutex.rs.html (source on Mutex type page) | 2953 | 2041 | 2038 | 0.1% |

So unsurprisingly, the more attributes you have, the bigger the difference.

You can test it [here](https://rustdoc.crud.net/imperio/reduce-span-v2/src/std/lib.rs.html).

cc ``````@jsha``````
r? ``````@notriddle``````
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Aug 26, 2022
…m-size, r=notriddle

Reduce right-side DOM size

This is another follow-up of rust-lang#100429 but not in code blocks this time.

So the idea is: if there is only one element in the `.rightside` element, there is no need to wrap it, we can just create one node.

On each page, I run this JS: `document.getElementsByTagName('*').length`. Important to note: the bigger the number of elements inside the page, the greater the gain. It also doesn't work very nicely on std docs because there are a lot of version annotations. So with this PR, It allows to get the following results:

| file name | before this PR | with this PR | diff |
|-|-|-|-|
| std/default/trait.Default.html | 2189 | 1331 | 39.2% |
| std/vec/struct.Vec.html | 14073 | 13842 | 1.7% |
| std/fmt/trait.Debug.html | 5313 | 4907 | 7.7% |
| std/ops/trait.Index.html | 642 | 630 | 1.9% |
| gtk4/WidgetExt | 3269 | 3061 | 6.4% |

You can test it [here](https://rustdoc.crud.net/imperio/reduce-rightsize-dom-size/gtk4/prelude/trait.WidgetExt.html).

r? `@notriddle`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-ui Area: rustdoc UI (generated HTML) 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.

None yet

9 participants