-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Simplify some code for lowering THIR patterns #136435
base: master
Are you sure you want to change the base?
Conversation
By storing `PatRange` in an Arc, and copying a few fields out of `Pat`, we can greatly simplify the lifetimes involved in match lowering.
These particular patterns make it harder to experiment with alternate representations for THIR patterns and subpatterns.
This does mean that we have to resolve the list of arm IDs twice, but it's unclear whether that even matters, whereas the cleaner signature is a nice improvement.
r? @Nadrieril rustbot has assigned @Nadrieril. Use |
Some changes occurred in match checking cc @Nadrieril Some changes occurred in cc @BoxyUwU |
Let's see if this has any measurable perf impact: @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Simplify some code for lowering THIR patterns I've been playing around with some radically different ways of storing THIR patterns, and while those experiments haven't yet produced a clear win, I have noticed various smaller things in the existing code that can be made a bit nicer. Some of the more significant changes: - With a little bit of extra effort (and thoughtful use of Arc), we can completely remove an entire layer of `'pat` lifetimes from the intermediate data structures used for match lowering. - In several places, lists of THIR patterns were being double-boxed for no apparent reason.
The double-boxing was introduced in #101139, but doesn't seem to have been mentioned at the time. I suspect it was just a consequence of doing some type-based refactoring in multiple stages, and not noticing further opportunities for simplification. (Or perhaps there were larger obstacles at the time that have since been cleared away.) |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (efc27c7): comparison URL. Overall result: ❌ regressions - no action neededBenchmarking 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 Instruction countThis 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.
Max RSS (memory usage)Results (secondary 2.3%)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.
CyclesResults (secondary 6.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.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 777.275s -> 776.971s (-0.04%) |
I've been playing around with some radically different ways of storing THIR patterns, and while those experiments haven't yet produced a clear win, I have noticed various smaller things in the existing code that can be made a bit nicer.
Some of the more significant changes:
'pat
lifetimes from the intermediate data structures used for match lowering.