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

Avoid checking the edition as much as possible #125828

Merged

Conversation

vincenzopalazzo
Copy link
Member

@vincenzopalazzo vincenzopalazzo commented May 31, 2024

Inside #123865, we are adding support for the new semantics for expr2024, but we have noted a performance issue.

While talking with @eholk, we realized there is a redundant check for each token regarding an edition. This commit moves the edition check to the end, avoiding some extra checks that can slow down compilation time.

However, we should keep this issue under observation because we may want to improve the edition check if we are unable to significantly improve compiler performance.

r? ghost

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 31, 2024
@vincenzopalazzo
Copy link
Member Author

@bors try @rust-timer queue

You can follow the discussion on zulip

@rust-timer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented May 31, 2024

@vincenzopalazzo: 🔑 Insufficient privileges: not in try users

vincenzopalazzo added a commit to vincenzopalazzo/team that referenced this pull request May 31, 2024
While working on macros ofter is good to ask "we are introducing a
regression in terms of performance?"

So this commit is allowing the macros wg to use the perf bot.

Link: rust-lang/rust#125828
Signed-off-by: Vincenzo Palazzo <[email protected]>
@vincenzopalazzo vincenzopalazzo changed the title rustc_parser: avoid checking the edition as much as possible [perf-only] rustc_parser: avoid checking the edition as much as possible May 31, 2024
vincenzopalazzo added a commit to vincenzopalazzo/team that referenced this pull request May 31, 2024
While working on macros ofter is good to ask "we are introducing a
regression in terms of performance?"

So this commit is allowing the macros wg to use the perf bot.

Link: rust-lang/rust#125828
Co-authored-by: Michael Goulet <[email protected]>
Signed-off-by: Vincenzo Palazzo <[email protected]>
@eholk
Copy link
Contributor

eholk commented May 31, 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 May 31, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request May 31, 2024
…egression, r=<try>

[perf-only] rustc_parser: avoid checking the edition as much as possible

CC rust-lang#123865
r? ghost
@bors
Copy link
Contributor

bors commented May 31, 2024

⌛ Trying commit 252f83a with merge d693eba...

@matthiaskrgr
Copy link
Member

🤔 I would assume that PGO already does such kind of optimization on its own.

@bors
Copy link
Contributor

bors commented May 31, 2024

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

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (d693eba): 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)
-0.3% [-0.4%, -0.2%] 8
Improvements ✅
(secondary)
-0.3% [-0.4%, -0.3%] 4
All ❌✅ (primary) -0.3% [-0.4%, -0.2%] 8

Max RSS (memory usage)

Results (primary 3.9%)

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)
3.9% [3.9%, 3.9%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.9% [3.9%, 3.9%] 1

Cycles

Results (primary -1.1%, secondary 2.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)
2.7% [2.0%, 4.0%] 9
Improvements ✅
(primary)
-1.1% [-1.4%, -0.9%] 11
Improvements ✅
(secondary)
-1.2% [-1.5%, -0.9%] 2
All ❌✅ (primary) -1.1% [-1.4%, -0.9%] 11

Binary size

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

Bootstrap: 672.771s -> 666.635s (-0.91%)
Artifact size: 318.83 MiB -> 318.84 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 31, 2024
@eholk
Copy link
Contributor

eholk commented May 31, 2024

Comparing these results with the results from the last PR, it looks like this more than makes up for the regressions in html5ever, but only gets back some of the performance for ttmuncher.

@workingjubilee
Copy link
Contributor

🤔 I would assume that PGO already does such kind of optimization on its own.

It is incorrect to reorder a || b into b || a, or the same with &&, in the general case, whereas a | b can be ordered in any direction.

@workingjubilee
Copy link
Contributor

And yes, the optimization may be permissible in this case, but LLVM got slightly more skittish about reordering those after it got burned by doing the optimization unsoundly.

@fmease
Copy link
Member

fmease commented May 31, 2024

@vincenzopalazzo
Copy link
Member Author

vincenzopalazzo commented Jun 2, 2024

Sorry for the delay!

Well, we've already made some improvements with @eholk's suggestion, right? Why don't we try to merge this PR and track the performance issue with a tracking issue?

I think we already have several PRs for expr2024, so maybe it's worth looking at this later to see if we need some other kind of optimization that allows us cheap access to the edition?

r? fmease

@vincenzopalazzo vincenzopalazzo changed the title [perf-only] rustc_parser: avoid checking the edition as much as possible Avoid checking the edition as much as possible Jun 2, 2024
@vincenzopalazzo vincenzopalazzo marked this pull request as ready for review June 2, 2024 07:42
Inside rust-lang#123865, we are adding support for the new semantics
for expr2024, but we have noted a performance issue.

We realized there is a redundant check for each
token regarding an edition. This commit moves the edition
check to the end, avoiding some extra checks that
can slow down compilation time.

Link: rust-lang#123865
Co-Developed-by: @eholk
Signed-off-by: Vincenzo Palazzo <[email protected]>
@fmease
Copy link
Member

fmease commented Jun 2, 2024

@bors r

@bors
Copy link
Contributor

bors commented Jun 2, 2024

📌 Commit 36d5fc9 has been approved by fmease

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 Jun 2, 2024
@bors
Copy link
Contributor

bors commented Jun 2, 2024

⌛ Testing commit 36d5fc9 with merge a6416d8...

@bors
Copy link
Contributor

bors commented Jun 2, 2024

☀️ Test successful - checks-actions
Approved by: fmease
Pushing a6416d8 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 2, 2024
@bors bors merged commit a6416d8 into rust-lang:master Jun 2, 2024
7 checks passed
@rustbot rustbot added this to the 1.80.0 milestone Jun 2, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (a6416d8): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -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)
-0.4% [-0.4%, -0.3%] 6
Improvements ✅
(secondary)
-0.4% [-0.5%, -0.3%] 4
All ❌✅ (primary) -0.4% [-0.4%, -0.3%] 6

Max RSS (memory usage)

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

Cycles

Results (primary 2.2%, secondary 2.5%)

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.2% [1.8%, 2.4%] 3
Regressions ❌
(secondary)
3.1% [2.0%, 4.5%] 10
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.6% [-2.6%, -2.6%] 1
All ❌✅ (primary) 2.2% [1.8%, 2.4%] 3

Binary size

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

Bootstrap: 669.121s -> 667.68s (-0.22%)
Artifact size: 318.92 MiB -> 318.93 MiB (0.00%)

@vincenzopalazzo vincenzopalazzo deleted the macros/performance-regression branch June 3, 2024 08:15
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. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler 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

8 participants