-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Add an intermediate representation to exhaustiveness checking #88950
Conversation
3fc15cc
to
1b0cd5f
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Interesting, |
It's weird though, because patterns used to be lowered already via a |
1b0cd5f
to
288be0c
Compare
Ok, some progress. My local measurements differ quite a bit from perf here, so I want to see what it says now. @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
288be0c
to
180204f
Compare
Huh ok I found the main issue; commit @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Ohh I can trivialize the terrible mess that was @bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit b7e358e with merge 86bbc6573b2248ce60968ba6b29dd56dc4ac80c8... |
@varkor remember the mess I introduced to solve #80632? It's all in this cute function now https://github.com/Nadrieril/rust/blob/b7e358ee17a5794603b2324858de078c4586acfc/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs#L1577-L1586 ! 7 lines of this do the job of about 250 lines of convoluted |
☀️ Try build successful - checks-actions |
Queued 86bbc6573b2248ce60968ba6b29dd56dc4ac80c8 with parent addb4da, future comparison URL. |
Finished benchmarking commit (86bbc6573b2248ce60968ba6b29dd56dc4ac80c8): comparison url. Summary: This change led to large relevant mixed results 🤷 in compiler performance.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. 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 led to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never |
😆 I'm getting to it right now |
r=me unless you want to keep investigating the stress test perf regression |
Yay thanks! Most (1%) of the regression comes from the last commit, presumably the part where we retraverse all the patterns. Since that didn't affect the more realistic benchmarks, and no real match has 8000 arms, I believe that retraversing the patterns takes negligible time in real cases. So I'll ignore that 1%. @bors r=oli-obk |
📌 Commit b7e358e has been approved by |
Just want to second how much more readable the code is without |
This comment has been minimized.
This comment has been minimized.
☀️ Test successful - checks-actions |
Finished benchmarking commit (6df1d82): comparison url. Summary: This change led to very large relevant mixed results 🤷 in compiler performance.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression |
The exhaustiveness checking algorithm keeps deconstructing patterns into a
Constructor
and someFields
, but does so a bit all over the place. This PR introduces a new representation for patterns that already has that information, so we only compute it once at the start.I find this makes code easier to follow. In particular
DeconstructedPat::specialize
is a lot simpler than what happened before, and more closely matches the description of the algorithm. I'm also hoping this could help for the project of librarifying exhaustiveness for rust_analyzer since it decouples the algorithm fromrustc_middle::Pat
.