-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
mir-opt: Replace clone on primitives with copy #94276
Conversation
b7293c8
to
05db2c2
Compare
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 05db2c29b137029c3db4d1dc0653fa3bd4d261bb with merge e3ab4694509bf757e2b190ca236e525005c34285... |
☀️ Try build successful - checks-actions |
Queued e3ab4694509bf757e2b190ca236e525005c34285 with parent bafe8d0, future comparison URL. |
Finished benchmarking commit (e3ab4694509bf757e2b190ca236e525005c34285): comparison url. Summary: This benchmark run shows 1 relevant improvement 🎉 to instruction counts.
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. @bors rollup=never |
Since this is green in perf (not even just neutral, to my surprise) and it avoids function calls for clones in debug (unlike today, where you can see things like r? rust-lang/mir-opt |
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.
We're missing probably the largest chunk of things, and that is calling generic functions that clone their generic parameters. MIR opts will not work there, as they only see the generic function, and the Clone
bounds don't allow switching to Copy
in that case. This is a recurring problem with other MIR opts, too.
That said, the effects on a real world benchmark are neat though I do wonder how much of that is these benchmarks being old and not having had clippy applied to them (which will tell you to do this transformation in user space, and even on generic things).
} | ||
} | ||
|
||
fn is_trivially_pure_copy<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { |
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.
This should probably live next to is_trivially_sized
and should probably be used to speed up is_copy_modulo_regions
by avoiding a query call.
That's why the test I used here is It's definitely true that this is something that LLVM will reliably inline, so only hitting the obvious things in the generic MIR is ok by me. I'll go do the move you mentioned in the other comment |
08905f9
to
8e242d7
Compare
Well, I tried short-circuiting in
So I left that out of the change. I definitely don't know enough about queries and such to have any idea why that's happening. It fails in @rustbot ready |
This comment has been minimized.
This comment has been minimized.
7037a5f
to
c2919c1
Compare
This comment has been minimized.
This comment has been minimized.
📌 Commit 705b880 has been approved by |
⌛ Testing commit 705b880 with merge a7c0d7302bbc247a044776a9fd08c0cd20a82bab... |
💔 Test failed - checks-actions |
@bors retry auto (dist-apple-various didn't start |
⌛ Testing commit 705b880 with merge f8311752f15ee207d04dd52ad61c693c0d2944df... |
💔 Test failed - checks-actions |
@bors retry -- this time it's dist-x86_64-apple that didn't start |
☀️ Test successful - checks-actions |
Finished benchmarking commit (c5a43b8): comparison url. Summary: This benchmark run did not return any relevant results. 38 results were found to be statistically significant but too small to be relevant. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
We can't do it for everything, but it would be nice to at least stop making calls to clone methods in debug from things like derived-clones.
r? @ghost