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

[Experiment] Rewrite exhaustiveness in one pass #111720

Closed
wants to merge 40 commits into from

Conversation

Nadrieril
Copy link
Member

I've had this in mind for a looong time now. Arm reachability checking does a quadratic amount of work: for each arm it checks if it is reachable given the arms above it. This feels wasteful since we often end up re-exploring the same cases when we check for exhaustiveness.

This PR is an attempt to check reachability at the same time as exhaustiveness. This opens the door to a bunch of code simplifications I'm very excited.

Last time I tried I utterly destroyed performance. Until I get the right permissions to run perf in my dev environment, I'll run perf from here if that's ok.

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 18, 2023
@Nadrieril Nadrieril force-pushed the linear-pass-take-2 branch from bc17e34 to 6e5c460 Compare May 18, 2023 12:09
@Nadrieril
Copy link
Member 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 May 18, 2023
@bors
Copy link
Contributor

bors commented May 18, 2023

⌛ Trying commit 6e5c460dabf632f3cfc2b042be3a9ad6a43d7bc6 with merge f07aa9a3c6ed57d9d30e29332b5836d416ed417d...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented May 18, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 18, 2023
@Nadrieril
Copy link
Member Author

I didn't know doc errors would stop bors 🙈

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented May 18, 2023

⌛ Trying commit 5735021ca97a51358b5d44d3df7d3ea936fa806c with merge 7b35e41a47c1bd7d4278379f89c90bd54038b471...

@bors
Copy link
Contributor

bors commented May 23, 2023

☀️ Try build successful - checks-actions
Build commit: 7a6baddc69eb6fadc114345e5ca1eb81f2a07807 (7a6baddc69eb6fadc114345e5ca1eb81f2a07807)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (7a6baddc69eb6fadc114345e5ca1eb81f2a07807): comparison URL.

Overall result: ❌✅ regressions and improvements - 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.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@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.6% [0.4%, 0.9%] 3
Regressions ❌
(secondary)
3.4% [0.3%, 4.7%] 8
Improvements ✅
(primary)
-0.8% [-2.1%, -0.1%] 15
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.3%] 2
All ❌✅ (primary) -0.6% [-2.1%, 0.9%] 18

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
Regressions ❌
(secondary)
1.3% [1.0%, 1.6%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.5% [-3.5%, -3.5%] 1
All ❌✅ (primary) - - 0

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)
- - 0
Improvements ✅
(secondary)
-7.5% [-9.2%, -6.1%] 6
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 646.644s -> 647.317s (0.10%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 23, 2023
@Nadrieril
Copy link
Member Author

This makes no sense I'm measuring a 14% improvement on match-stress locally :'(

@Kobzol
Copy link
Contributor

Kobzol commented May 23, 2023

@nnethercote
Copy link
Contributor

Walltime results are also nice, up to 8% wins on match-stress. Instruction counts are a decent metric in general, but the larger the change, the less reliable they become, and this seems like a fairly large change.

@Nadrieril
Copy link
Member Author

Ohh nice I never checked the other metrics, ty both

@Nadrieril
Copy link
Member Author

I lost momentum because of the perf issue, should come back to this this week or the next

@Nadrieril Nadrieril closed this Jun 6, 2023
@Kobzol
Copy link
Contributor

Kobzol commented Jun 7, 2023

@Nadrieril I'm curious, why did you close this? The perf. results on the match stress enum were really nice.

@Nadrieril
Copy link
Member Author

Nadrieril commented Jun 7, 2023

I'm still excited about it and hope to finish it! But I lost momentum and life happened and I don't expect to be able to come back to it for weeks if not months :/. I'm closing it in the meantime for triage purposes
Thx for checking in btw, appreciate to know I'm not working unnoticed

@Kobzol
Copy link
Contributor

Kobzol commented Jun 7, 2023

I see. Take care!

bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 21, 2023
[Experiment] Rewrite exhaustiveness in one pass

Arm reachability checking does a quadratic amount of work: for each arm we check if it is reachable given the arms above it. This feels wasteful since we often end up re-exploring the same cases when we check for exhaustiveness.

This PR is an attempt to check reachability at the same time as exhaustiveness. This opens the door to a bunch of code simplifications I'm very excited about. The main question is whether I can get actual performance gains out of this.

I had started the experiment in rust-lang#111720 but I can't reopen it.

r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 29, 2023
[Experiment] Rewrite exhaustiveness in one pass

Arm reachability checking does a quadratic amount of work: for each arm we check if it is reachable given the arms above it. This feels wasteful since we often end up re-exploring the same cases when we check for exhaustiveness.

This PR is an attempt to check reachability at the same time as exhaustiveness. This opens the door to a bunch of code simplifications I'm very excited about. The main question is whether I can get actual performance gains out of this.

I had started the experiment in rust-lang#111720 but I can't reopen it.

r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 2, 2023
[Experiment] Rewrite exhaustiveness in one pass

Arm reachability checking does a quadratic amount of work: for each arm we check if it is reachable given the arms above it. This feels wasteful since we often end up re-exploring the same cases when we check for exhaustiveness.

This PR is an attempt to check reachability at the same time as exhaustiveness. This opens the door to a bunch of code simplifications I'm very excited about. The main question is whether I can get actual performance gains out of this.

I had started the experiment in rust-lang#111720 but I can't reopen it.

r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 12, 2023
[Experiment] Rewrite exhaustiveness in one pass

Arm reachability checking does a quadratic amount of work: for each arm we check if it is reachable given the arms above it. This feels wasteful since we often end up re-exploring the same cases when we check for exhaustiveness.

This PR is an attempt to check reachability at the same time as exhaustiveness. This opens the door to a bunch of code simplifications I'm very excited about. The main question is whether I can get actual performance gains out of this.

I had started the experiment in rust-lang#111720 but I can't reopen it.

r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 12, 2023
[Experiment] Rewrite exhaustiveness in one pass

Arm reachability checking does a quadratic amount of work: for each arm we check if it is reachable given the arms above it. This feels wasteful since we often end up re-exploring the same cases when we check for exhaustiveness.

This PR is an attempt to check reachability at the same time as exhaustiveness. This opens the door to a bunch of code simplifications I'm very excited about. The main question is whether I can get actual performance gains out of this.

I had started the experiment in rust-lang#111720 but I can't reopen it.

r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 13, 2023
[Experiment] Rewrite exhaustiveness in one pass

Arm reachability checking does a quadratic amount of work: for each arm we check if it is reachable given the arms above it. This feels wasteful since we often end up re-exploring the same cases when we check for exhaustiveness.

This PR is an attempt to check reachability at the same time as exhaustiveness. This opens the door to a bunch of code simplifications I'm very excited about. The main question is whether I can get actual performance gains out of this.

I had started the experiment in rust-lang#111720 but I can't reopen it.

r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 13, 2023
[Experiment] Rewrite exhaustiveness in one pass

Arm reachability checking does a quadratic amount of work: for each arm we check if it is reachable given the arms above it. This feels wasteful since we often end up re-exploring the same cases when we check for exhaustiveness.

This PR is an attempt to check reachability at the same time as exhaustiveness. This opens the door to a bunch of code simplifications I'm very excited about. The main question is whether I can get actual performance gains out of this.

I had started the experiment in rust-lang#111720 but I can't reopen it.

r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 15, 2023
[Experiment] Rewrite exhaustiveness in one pass

Arm reachability checking does a quadratic amount of work: for each arm we check if it is reachable given the arms above it. This feels wasteful since we often end up re-exploring the same cases when we check for exhaustiveness.

This PR is an attempt to check reachability at the same time as exhaustiveness. This opens the door to a bunch of code simplifications I'm very excited about. The main question is whether I can get actual performance gains out of this.

I had started the experiment in rust-lang#111720 but I can't reopen it.

r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 15, 2023
[Experiment] Rewrite exhaustiveness in one pass

Arm reachability checking does a quadratic amount of work: for each arm we check if it is reachable given the arms above it. This feels wasteful since we often end up re-exploring the same cases when we check for exhaustiveness.

This PR is an attempt to check reachability at the same time as exhaustiveness. This opens the door to a bunch of code simplifications I'm very excited about. The main question is whether I can get actual performance gains out of this.

I had started the experiment in rust-lang#111720 but I can't reopen it.

r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 16, 2023
[Experiment] Rewrite exhaustiveness in one pass

Arm reachability checking does a quadratic amount of work: for each arm we check if it is reachable given the arms above it. This feels wasteful since we often end up re-exploring the same cases when we check for exhaustiveness.

This PR is an attempt to check reachability at the same time as exhaustiveness. This opens the door to a bunch of code simplifications I'm very excited about. The main question is whether I can get actual performance gains out of this.

I had started the experiment in rust-lang#111720 but I can't reopen it.

r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 20, 2023
[Experiment] Rewrite exhaustiveness in one pass

Arm reachability checking does a quadratic amount of work: for each arm we check if it is reachable given the arms above it. This feels wasteful since we often end up re-exploring the same cases when we check for exhaustiveness.

This PR is an attempt to check reachability at the same time as exhaustiveness. This opens the door to a bunch of code simplifications I'm very excited about. The main question is whether I can get actual performance gains out of this.

I had started the experiment in rust-lang#111720 but I can't reopen it.

r? `@ghost`
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 4, 2023
[Experiment] Rewrite exhaustiveness in one pass

Arm reachability checking does a quadratic amount of work: for each arm we check if it is reachable given the arms above it. This feels wasteful since we often end up re-exploring the same cases when we check for exhaustiveness.

This PR is an attempt to check reachability at the same time as exhaustiveness. This opens the door to a bunch of code simplifications I'm very excited about. The main question is whether I can get actual performance gains out of this.

I had started the experiment in rust-lang#111720 but I can't reopen it.

r? `@ghost`
@Nadrieril Nadrieril added the A-exhaustiveness-checking Relating to exhaustiveness / usefulness checking of patterns label Dec 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-exhaustiveness-checking Relating to exhaustiveness / usefulness checking of patterns perf-regression Performance regression. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

7 participants