-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Normalize late-bound projections with inference variables in fulfillment #94070
Normalize late-bound projections with inference variables in fulfillment #94070
Conversation
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit df8d9f530e6a6c825f92b21145861dbbabeb083e with merge f20c37cb312b7df326fa1d05e51af9149c90e9fd... |
Things to think about:
|
☀️ Try build successful - checks-actions |
Queued f20c37cb312b7df326fa1d05e51af9149c90e9fd with parent 930fc4f, future comparison URL. |
Yeah, regard the first part, I actually discovered that all that extra normalizing of those Fn trait refs wasn't needed when I stopped first shallow resolving and then normalizing during fulfillment... hence this PR is a lot shorter. The second question is a good point, I can put up a quick PR tomorrow so we can run an experiment unless you want to modify #90887 yourself. |
Finished benchmarking commit (f20c37cb312b7df326fa1d05e51af9149c90e9fd): comparison url. Summary: This benchmark run shows 13 relevant regressions 😿 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. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never |
Haha! That's lovely. Let me rebase that normalization commit when I get up in a few hours. |
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit a2ce369ecd32bb4b319c1495a0991f1260ddd5c8 with merge 0ab1cb526af76f0c1d83259e21fd9cb9497c1e80... |
☀️ Try build successful - checks-actions |
Queued 0ab1cb526af76f0c1d83259e21fd9cb9497c1e80 with parent 30b3f35, future comparison URL. |
Finished benchmarking commit (0ab1cb526af76f0c1d83259e21fd9cb9497c1e80): comparison url. Summary: This benchmark run did not return any relevant results. 14 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. 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 |
fdffc17
to
48fba7e
Compare
Interesting to see that the perf improvement is a combination of the normalization in selection and (probably?) the type flag addition. Per discussion with @jackh726, let's test this hypothesis further. I reverted the type flag diff (and added a small change so we don't resolve variables and normalize in fulfillment, since that's kinda doing duplicated work). |
@bors try @rust-timer queue |
Queued b133e1a0ceb78dbf55643a6deab904d3911208b6 with parent 30b3f35, future comparison URL. |
Finished benchmarking commit (b133e1a0ceb78dbf55643a6deab904d3911208b6): comparison url. Summary: This benchmark run did not return any relevant results. 29 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. 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 |
…malization, r=jackh726 Normalize obligation and expected trait_refs in confirm_poly_trait_refs Consolidate normalization the obligation and expected trait refs in `confirm_poly_trait_refs`. Also, _always_ normalize these trait refs -- we were already normalizing the obligation trait ref when confirming closure and generator candidates, but this does it for fn pointer confirmation as well. This presumably does more work in the case that the obligation's trait ref is already normalized, but we can see from the perf runs in rust-lang#94070, it actually (paradoxically, perhaps) improves performance when paired with logic that normalizes projections in fulfillment loop.
9550ae8
to
fd193d2
Compare
Let's land #90887 first, and see if this stands on its on? |
☔ The latest upstream changes (presumably #90887) made this pull request unmergeable. Please resolve the merge conflicts. |
fd193d2
to
0a096a0
Compare
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 0a096a0 with merge dd0319c25a100e481bc99429d2a54fe68330aa26... |
☀️ Try build successful - checks-actions |
Queued dd0319c25a100e481bc99429d2a54fe68330aa26 with parent 67b3e81, future comparison URL. |
Finished benchmarking commit (dd0319c25a100e481bc99429d2a54fe68330aa26): comparison url. Summary: This benchmark run shows 15 relevant improvements 🎉 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 |
@compiler-errors do you plan to rebase atop #90887 ? |
@nikomatsakis I did! 😄 |
Not sure the slight perf improvement here is worth the added complexity. |
Yeah, in that case, I'll close this out. |
I modified the PR #90887 "Try to normalize associated types before processing obligations" to only attempt normalization when these two conditions are both true:
The only projections that we expect to see inside of a predicate during fulfillment (and which we have any hope of normalizing further) are those that have remaining inference variables that need to be resolved, and which have late-bound vars which opted them out of being replaced with a fresh inference variable in the first place. We rely on existing normalization that is speckled through typeck and confirmation (e.g. here) to uphold this invariant, which means we can skip a large portion of the normalization calls that we saw in #90887.
As seen in the (really messy) initial PR I put up for a perf run, it seems to have improved performance.
Reasoning about why these two conditions together are sufficient:
This probably needs more discussion, but I'm putting this up for initial review, and we can perhaps discuss it in the GATs meeting.
r? @nikomatsakis
cc @jackh726
Fixes #90729
Fixes #93341
Fixes #93342
Fixes #94160