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

[perf] rustdoc: Perform less work when cleaning middle::ty parenthesized generic args #132886

Merged
merged 1 commit into from
Nov 13, 2024

Conversation

fmease
Copy link
Member

@fmease fmease commented Nov 11, 2024

CC #132697. I presume the perf regression it caused (if real) boils down to query invocation overhead, namely of def_kind & trait_def as we don't seem to be decoding more often from the crate metadata.

I won't try the obvious and reduce the amount of query calls by threading information via params as that would render the code awkward.

So instead I'm simply trying to attack some low-hanging fruits in the vicinity.


Previously, we would clean_middle_generic_args unconditionally inside clean_middle_generic_args_with_constraints even though we didn't actually use its result for parenthesized generic args (Trait(...) -> ...).

Now, we only call clean_middle_generic_args when necessary. Lastly, I've simplified clean_middle_generic_args_with_constraints.


r? ghost

@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 Nov 11, 2024
@fmease
Copy link
Member Author

fmease commented Nov 11, 2024

@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 Nov 11, 2024
@bors
Copy link
Contributor

bors commented Nov 11, 2024

⌛ Trying commit e51bfa6 with merge 66ae3a1...

bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 11, 2024
…s, r=<try>

[perf] rustdoc: Perform less work when cleaning parenthesized generic args

CC rust-lang#132697. I presume the perf regression it caused (if real) boils down to query invocation overhead (namely, of `def_kind` & `trait_def`). I won't address that because it would worsen the clean middle API. So I'm simply trying to attack some low-hanging fruits in the vicinity.

r? ghost
@fmease fmease changed the title [perf] rustdoc: Perform less work when cleaning parenthesized generic args [perf] rustdoc: Perform less work when cleaning cross-crate parenthesized generic args Nov 11, 2024
@fmease fmease changed the title [perf] rustdoc: Perform less work when cleaning cross-crate parenthesized generic args [perf] rustdoc: Perform less work when cleaning middle::ty parenthesized generic args Nov 11, 2024
src/librustdoc/clean/utils.rs Outdated Show resolved Hide resolved
@bors
Copy link
Contributor

bors commented Nov 11, 2024

☀️ Try build successful - checks-actions
Build commit: 66ae3a1 (66ae3a104b1b7795cf32e60edc012d2bccd27e26)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (66ae3a1): 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 the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.3% [-0.4%, -0.1%] 5
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -0.1%, secondary 0.7%)

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)
2.8% [2.8%, 2.8%] 1
Regressions ❌
(secondary)
0.7% [0.7%, 0.7%] 1
Improvements ✅
(primary)
-1.6% [-2.2%, -0.9%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.1% [-2.2%, 2.8%] 3

Cycles

Results (secondary -2.4%)

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)
- - 0
Improvements ✅
(secondary)
-2.4% [-3.2%, -2.0%] 9
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 786.53s -> 785.607s (-0.12%)
Artifact size: 335.31 MiB -> 335.28 MiB (-0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 11, 2024
@fmease fmease force-pushed the rustdoc-perf-clean-middle-args branch from e51bfa6 to 0cebb35 Compare November 11, 2024 14:26
@@ -112,7 +112,6 @@ pub(crate) fn clean_middle_generic_args<'tcx>(
return None;
}

// Elide internal host effect args.
Copy link
Member Author

Choose a reason for hiding this comment

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

Outdated since #131985

@fmease
Copy link
Member Author

fmease commented Nov 11, 2024

2/5 benchmarks spurious (not a doc profile). corrected perf summary:

Range Mean Count
[ -0.23%, -0.14%] -0.19% 3 (3)

r? rustdoc

@fmease fmease marked this pull request as ready for review November 11, 2024 14:33
@fmease fmease force-pushed the rustdoc-perf-clean-middle-args branch from 0cebb35 to 4660316 Compare November 11, 2024 14:35
@GuillaumeGomez
Copy link
Member

When the PR is ready for you, please run the perf check:

@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 Nov 11, 2024
@fmease
Copy link
Member Author

fmease commented Nov 11, 2024

Oh, nothing really changed with my two force-pushes, I only renamed a variable 😅

@GuillaumeGomez
Copy link
Member

Oh I don't judge, you can do as many renamings as you want. 🤣

@fmease fmease removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 11, 2024
@fmease
Copy link
Member Author

fmease commented Nov 11, 2024

When the PR is ready for you

Right, it's ready, that's what I meant to say above. I might come back to #132697's regression but for now, I won't due to time constraints.

@fmease
Copy link
Member Author

fmease commented Nov 11, 2024

@bors r=GuillaumeGomez

@bors
Copy link
Contributor

bors commented Nov 11, 2024

📌 Commit 4660316 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 Nov 11, 2024
@bors
Copy link
Contributor

bors commented Nov 13, 2024

⌛ Testing commit 4660316 with merge ec239b8...

@bors
Copy link
Contributor

bors commented Nov 13, 2024

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 13, 2024
@bors bors merged commit ec239b8 into rust-lang:master Nov 13, 2024
7 checks passed
@rustbot rustbot added this to the 1.84.0 milestone Nov 13, 2024
@fmease fmease deleted the rustdoc-perf-clean-middle-args branch November 13, 2024 08:55
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ec239b8): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
1.0% [1.0%, 1.0%] 2
Regressions ❌
(secondary)
0.2% [0.2%, 0.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.2% [-0.3%, -0.1%] 5
All ❌✅ (primary) 1.0% [1.0%, 1.0%] 2

Max RSS (memory usage)

Results (primary -0.8%, secondary 3.0%)

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)
3.0% [3.0%, 3.0%] 1
Improvements ✅
(primary)
-0.8% [-1.1%, -0.5%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.8% [-1.1%, -0.5%] 2

Cycles

Results (secondary -2.2%)

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)
- - 0
Improvements ✅
(secondary)
-2.2% [-2.8%, -1.8%] 4
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 784.378s -> 786.527s (0.27%)
Artifact size: 335.40 MiB -> 335.37 MiB (-0.01%)

@rustbot rustbot added the perf-regression Performance regression. label Nov 13, 2024
@lqd
Copy link
Member

lqd commented Nov 13, 2024

Compile time regressions on a rustdoc change? I don't think so, perf bot.

@rustbot label: +perf-regression-triaged

(these should stabilize in the next merge, hopefully, so let's re-check later)

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Nov 13, 2024
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.

6 participants