-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Inline FnOnce
/FnMut
/Fn
shims once again
#137907
Conversation
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Inline `FnOnce`/`FnMut`/`Fn` shims once again cc rust-lang#137901 r? `@ghost`
3be05c2
to
2091084
Compare
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Inline `FnOnce`/`FnMut`/`Fn` shims once again cc rust-lang#137901 r? `@ghost`
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Previously, this ended up making things kinda slow in the compiler: #110833 (comment). |
…, r=<try> [do not merge] Inliner experiment 2 cc rust-lang#137907 (comment) r? `@ghost`
Finished benchmarking commit (633435e): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking 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 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 (primary 0.4%, secondary 2.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.
CyclesResults (primary 12.8%, secondary -4.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.
Binary sizeResults (primary -0.1%, secondary -0.1%)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.
Bootstrap: missing data |
…, r=<try> [do not merge] Inliner experiment 2 cc rust-lang#137907 (comment) r? `@ghost`
For the clap regression: I ran cachegrind and confirmed that yes, this is indeed all in LLVM (as the codegen split in rustc-perf already suggested). Give that this is incr-patched, it seems likely that this is because of a lack of CGU partitioning luck due to the extra inlining. But I think @saethlin would have a more informed opinion on this |
2091084
to
8cdcf3f
Compare
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
r? saethlin or reassign |
agh didn't mean to push that last commit |
8cdcf3f
to
0931ef1
Compare
There is also no data for the runtime benchmarks. |
Let me fix CI (there seems to be some platform-dependent inliner instability) then I can queue another perf run. |
f8f376e
to
d33946c
Compare
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Inline `FnOnce`/`FnMut`/`Fn` shims once again This PR fixes the argument checking for `extern "rust-call"` ABI functions with a spread arg, which do no expect their arguments to be exploded from a tuple like closures do. Secondly, it removes the hack that prevented them from being inlined. This results in more work done by the compiler, but it does end up allowing us to inline functions we didn't before. Fixes rust-lang#137901
Slightly more informed. I think opt-incr-patched benchmarks do not deserve the same weight as the rest of the benchmark suite because our compilation pipeline very deeply does not support optimizations and incrementality at the same time. Maybe we could make it do that, but swings like this are an indicator that we haven't made the investment, not that this PR is bad. I know I've pointed at CGU partitioning as the cause of this in the past, and I believe that's technically wrong so I just want to say this before it gets too widespread. The actual partitioning part of the algorithm is very stable to perturbations, what is unstable is the instantiation mode selection, which selects which Instances are partitioned explicitly vs lazily. It would be pretty cool for these incr-patched benchmarks to identify the number of dirtied CGUs. I think that's basically the number of |
InstanceKind::Intrinsic(_) | InstanceKind::Virtual(..) => { | ||
debug!("instance without MIR (intrinsic / virtual)"); | ||
return Err("implementation limitation"); | ||
return Err("implementation limitation -- cannot inline intrinsic"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually we can inline intrinsics, but we don't want to.
rust/compiler/rustc_mir_transform/src/cross_crate_inline.rs
Lines 37 to 43 in e16a049
if tcx.has_attr(def_id, sym::rustc_intrinsic) { | |
// Intrinsic fallback bodies are always cross-crate inlineable. | |
// To ensure that the MIR inliner doesn't cluelessly try to inline fallback | |
// bodies even when the backend would implement something better, we stop | |
// the MIR inliner from ever inlining an intrinsic. | |
return true; | |
} |
Phew, that inliner clause was something. Thank you so much for fixing this. r=me when CI passes |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (76aedcd): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking 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 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 (primary 0.6%, secondary 1.6%)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 (primary 22.2%, secondary -1.4%)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 sizeResults (primary -0.1%, secondary -0.1%)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.
Bootstrap: 773.808s -> 774.314s (0.07%) |
@bors r=saethlin rollup=never |
Bumping this over my other |
☀️ Test successful - checks-actions |
Finished benchmarking commit (30f168e): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowOur benchmarks found a performance regression caused by this PR. Next Steps:
@rustbot label: +perf-regression 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 (primary 2.9%, secondary 2.4%)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 (primary 34.1%, secondary -0.7%)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 sizeResults (primary -0.1%, secondary -0.1%)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.
Bootstrap: 775.73s -> 773.363s (-0.31%) |
Overall there are more wins than regressions, and this change should help optimizations. The single large regression is unlucky CGU scheduling on an optimized incremental build, which is not very common. @rustbot label: +perf-regression-triaged |
This PR fixes the argument checking for
extern "rust-call"
ABI functions with a spread arg, which do no expect their arguments to be exploded from a tuple like closures do.Secondly, it removes the hack that prevented them from being inlined. This results in more work done by the compiler, but it does end up allowing us to inline functions we didn't before.
Fixes #137901