Skip to content

Cleanup and optimize render_impls#157540

Open
yotamofek wants to merge 1 commit into
rust-lang:mainfrom
yotamofek:pr/rustdoc/render_all_impls-cleanup
Open

Cleanup and optimize render_impls#157540
yotamofek wants to merge 1 commit into
rust-lang:mainfrom
yotamofek:pr/rustdoc/render_all_impls-cleanup

Conversation

@yotamofek
Copy link
Copy Markdown
Contributor

@yotamofek yotamofek commented Jun 6, 2026

  • take ownership of the Vec<&Impl> instead of copying into another alloc
  • reuse ImplString to do natural sort ordering
  • lazy formatting

Somewhat of a follow-up to #157233 and #157179 (cc @nnethercote - thanks!)
This kinda undoes f7c8bc2 but IMHO it makes more sense to be explicit about negative impl ordering, and also seems kinda wasteful to "render" the negativity into a string and rely on however ASCII decided to order characters. I can also undo this part, I think this PR is still a positive change even without it.

r? @GuillaumeGomez

LLM disclosure:
I used LLM for reviewing my changes and making sure some assumptions I was making were correct (i.e. that render_impls will not render anything IFF the list of traits passed to it is empty)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Jun 6, 2026
@yotamofek
Copy link
Copy Markdown
Contributor Author

yotamofek commented Jun 6, 2026

I doubt it'll register on perf, but I do think this should be an optimization (albeit a small one) so let's run perf anyways

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 6, 2026
rust-bors Bot pushed a commit that referenced this pull request Jun 6, 2026
…, r=<try>

Cleanup and optimize `render_impls`
@rust-log-analyzer

This comment has been minimized.

@yotamofek
Copy link
Copy Markdown
Contributor Author

A job failed! Check out the build log: (web) (plain enhanced) (plain)
Click to see the possible cause of the failure (guessed by this bot)

Docker error
hopefully try build will still work

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Jun 6, 2026

☀️ Try build successful (CI)
Build commit: 19872c0 (19872c0f5e198bd2f48c9898b0b0e83f77aa8dbf, parent: 8954863c81df429ebf96ea38a16c76f209995833)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (19872c0): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

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

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.2% [-0.5%, -0.1%] 8
Improvements ✅
(secondary)
-0.2% [-0.3%, -0.2%] 3
All ❌✅ (primary) -0.2% [-0.5%, -0.1%] 8

Max RSS (memory usage)

Results (primary 0.6%, secondary 2.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
7.0% [6.8%, 7.1%] 2
Regressions ❌
(secondary)
3.9% [2.6%, 6.0%] 4
Improvements ✅
(primary)
-3.6% [-5.2%, -2.6%] 3
Improvements ✅
(secondary)
-2.0% [-2.0%, -2.0%] 1
All ❌✅ (primary) 0.6% [-5.2%, 7.1%] 5

Cycles

Results (primary 3.4%, secondary 3.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
3.4% [1.5%, 6.0%] 102
Regressions ❌
(secondary)
3.5% [2.1%, 7.0%] 90
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.4% [1.5%, 6.0%] 102

Binary size

Results (primary 0.0%, secondary 0.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.0% [0.0%, 0.1%] 30
Regressions ❌
(secondary)
0.0% [0.0%, 0.1%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [0.0%, 0.1%] 30

Bootstrap: 514.086s -> 513.359s (-0.14%)
Artifact size: 400.74 MiB -> 400.64 MiB (-0.03%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 6, 2026
- take ownership of the `Vec<&Impl>` instead of copying into another alloc
- reuse `ImplString` to do natural sort ordering
- lazy formatting
@yotamofek yotamofek force-pushed the pr/rustdoc/render_all_impls-cleanup branch from 1b36eaf to 183502d Compare June 6, 2026 21:25
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jun 6, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@yotamofek
Copy link
Copy Markdown
Contributor Author

Perf results are a pleasant surprise! 🦆
Force pushed without any changes to trigger new CI run

@GuillaumeGomez
Copy link
Copy Markdown
Member

Nice, well done! r=me once CI pass.

@rust-log-analyzer
Copy link
Copy Markdown
Collaborator

The job aarch64-gnu-llvm-21-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

---- [rustdoc-html] tests/rustdoc-html/macro/const-rendering-macros-33302.rs stdout ----
------python3 stdout------------------------------

------python3 stderr------------------------------
29: has check failed
 `XPATH PATTERN` did not match
         //@ has - '//*[@id="associatedconstant.C"]' 'const C: [i32; 16]'
45: has check failed
 `XPATH PATTERN` did not match
         //@ has - '//*[@id="associatedconstant.C-2"]' 'const C: (i32, i32)'

Encountered 2 errors

------------------------------------------

error: htmldocck failed!
status: exit status: 1
command: "/usr/bin/python3" "/checkout/src/etc/htmldocck.py" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/rustdoc-html/macro/const-rendering-macros-33302" "/checkout/tests/rustdoc-html/macro/const-rendering-macros-33302.rs"
stdout: none
--- stderr -------------------------------
29: has check failed
 `XPATH PATTERN` did not match
         //@ has - '//*[@id="associatedconstant.C"]' 'const C: [i32; 16]'
45: has check failed
 `XPATH PATTERN` did not match
         //@ has - '//*[@id="associatedconstant.C-2"]' 'const C: (i32, i32)'

Encountered 2 errors
------------------------------------------

---- [rustdoc-html] tests/rustdoc-html/macro/const-rendering-macros-33302.rs stdout end ----

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants