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: Optimize impl sorting during rendering #109399

Merged
merged 1 commit into from
Mar 25, 2023

Conversation

petrochenkov
Copy link
Contributor

This should fix the perf regression on bitmaps-3.1.0 from #107765.

The bitmaps crate has a lot of impls:

impl Bits for BitsImpl<1> { ... }
impl Bits for BitsImpl<2> { ... }
// ...
impl Bits for BitsImpl<1023> { ... }
impl Bits for BitsImpl<1024> { ... }

and the logic in fn print_item sorts them in natural order.

Before #107765 the impls came in source order, which happened to be already sorted in the necessary way.
So the comparison function was called fewer times.

After #107765 the impls came in "stable" order (based on def path hash).
So the comparison function was called more times to sort them.

The comparison function was terribly inefficient, so it caused a large perf regression.
This PR attempts to make it more efficient by using cached keys during sorting.

@rustbot
Copy link
Collaborator

rustbot commented Mar 20, 2023

r? @jsha

(rustbot has picked a reviewer for you, use r? to override)

@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. labels Mar 20, 2023
@petrochenkov
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 20, 2023
@bors
Copy link
Contributor

bors commented Mar 20, 2023

⌛ Trying commit 4d55aff with merge 27184c344642b1a44cda998413b1b72972b11c05...

@bors
Copy link
Contributor

bors commented Mar 20, 2023

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

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (27184c344642b1a44cda998413b1b72972b11c05): comparison URL.

Overall result: ✅ improvements - no action needed

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.

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

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.8% [-10.1%, -0.4%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -3.8% [-10.1%, -0.4%] 3

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.5% [0.5%, 0.5%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.6% [-0.6%, -0.6%] 1
Improvements ✅
(secondary)
-2.9% [-4.1%, -1.7%] 8
All ❌✅ (primary) 0.2% [-0.6%, 0.5%] 4

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.6% [-6.7%, -0.6%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.6% [-6.7%, -0.6%] 3

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 20, 2023
@GuillaumeGomez
Copy link
Member

Thanks!

@bors r+ rollup=never

@bors
Copy link
Contributor

bors commented Mar 21, 2023

📌 Commit 4d55aff has been approved by GuillaumeGomez

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 Mar 21, 2023
@bors
Copy link
Contributor

bors commented Mar 24, 2023

⌛ Testing commit 4d55aff with merge d13a19801c0a45c55c11f0cdb582b8b7da4f4f9d...

@bors
Copy link
Contributor

bors commented Mar 24, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 24, 2023
@lqd
Copy link
Member

lqd commented Mar 24, 2023

C:\a\rust\rust\mingw64\bin\ranlib.exe: could not create temporary file whilst writing archive: no more archived files

@bors retry #108227

@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 Mar 24, 2023
@rust-log-analyzer

This comment was marked as outdated.

@bors
Copy link
Contributor

bors commented Mar 24, 2023

⌛ Testing commit 4d55aff with merge f63fb86b6aeb292fd6a86ae476f1156b7c674b4f...

@bors
Copy link
Contributor

bors commented Mar 24, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 24, 2023
@ehuss
Copy link
Contributor

ehuss commented Mar 24, 2023

@bors retry

github incident

@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 Mar 24, 2023
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

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

@bors
Copy link
Contributor

bors commented Mar 24, 2023

⌛ Testing commit 4d55aff with merge d012d2f...

@bors
Copy link
Contributor

bors commented Mar 25, 2023

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 25, 2023
@bors bors merged commit d012d2f into rust-lang:master Mar 25, 2023
@rustbot rustbot added this to the 1.70.0 milestone Mar 25, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (d012d2f): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

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

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.7% [0.7%, 0.7%] 1
Improvements ✅
(primary)
-10.1% [-10.1%, -10.1%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -10.1% [-10.1%, -10.1%] 1

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.6% [0.8%, 2.3%] 2
Regressions ❌
(secondary)
3.1% [3.1%, 3.1%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.0% [-1.9%, -0.5%] 5
All ❌✅ (primary) 1.6% [0.8%, 2.3%] 2

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.7% [1.4%, 2.0%] 4
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-7.8% [-7.8%, -7.8%] 1
Improvements ✅
(secondary)
-0.5% [-0.8%, -0.4%] 5
All ❌✅ (primary) -0.2% [-7.8%, 2.0%] 5

@rustbot rustbot added the perf-regression Performance regression. label Mar 25, 2023
@rylev
Copy link
Member

rylev commented Mar 28, 2023

The one regression is noise.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Mar 28, 2023
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.

10 participants