-
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
Remove the size of locals heuristic in MIR inlining #110705
Conversation
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 173845c with merge cbbf8037a859939483a183c7ce46714fda36d37d... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (cbbf8037a859939483a183c7ce46714fda36d37d): comparison URL. Overall result: ❌✅ regressions and improvements - 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. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis 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.
CyclesResultsThis 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.
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
Wow, those results look great to me. (I don't know why doc builds regressed on instructions -- maybe just that rlibs are bigger with more inlining? -- but overall they look ½-and-½ above and below for cycles, including the non-relevant ones, so my guess is that's fine since you didn't change anything about rustdoc directly.) Spitballing in case someone objects: another possibility would be to count only the size of |
Thanks @saethlin! Besides instruction count, we have a regression on metadata and binary size for optimized builds. I think those are tolerable (+0.4% on binary size, +2% on crate metadata on average). The regression in bootstrap timings is a unfortunate, but not a reason not to land this PR. @scottmcm I'm not even convinced that the size of aggregates matters. Those aggregates would end up on the stack either way, through an inlined call or a regular call. Inlining gives the possibility to emit a copy, so that's good to take. @bors r+ |
☀️ Test successful - checks-actions |
One of the biggest inlining changes due to this PR in the standard library is that So MIR opts aside, I'm going to see what I can do about that. I don't know how to validate my guess without implementing a fix for it, so this may not be very quick. |
Finished benchmarking commit (915aa06): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis 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.
CyclesResultsThis 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.
|
keccak + cranelift-codegen 🙃 |
Improvements outweigh regressions. @rustbot label: +perf-regression-triaged |
General regression blocking cmov generation in if blocks seems to bisect to this change, causing branchier code to be emitted. #125338. |
This heuristic doesn't necessarily correlate to complexity of the MIR Body. In particular, a lot of straight-line code in MIR tends to never reuse a local, even though any optimizer would effectively reuse the storage or just put everything in registers. So it doesn't even necessarily make sense that this would be a stack size heuristic.
So... what happens if we just delete the heuristic? The benchmark suite improves significantly. Less heuristics better?
r? @cjgillot