-
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
Use a fresh InferCtxt
when we 'speculatively' evaluate predicates
#91183
Conversation
r? @nagisa (rust-highfive has picked a reviewer for you, use r? to override) |
I'm hoping to remove this 'speculative' evaluation entirely in #89831. However, that PR is blocked on several other PRs. In the meantime, this PR will make the existing logic more correct, and allow affected users to update to the latest nightly. |
78d1306
to
be7a68b
Compare
LGTM. r=me with CI green and a comment added on why we use a fresh Maybe we should also do a perf run just in case. |
r? @jackh726 |
This comment has been minimized.
This comment has been minimized.
@bors rollup=never (for perf reasons) |
Blocked on #91205 |
The existing `InferCtxt` may already have in-progress projections for some of the predicates we may (recursively evaluate). This can cause us to incorrect produce (and cache!) `EvaluatedToRecur`, leading us to incorrectly mark a predicate as unimplemented. We now create a fresh `InferCtxt` for each sub-obligation that we 'speculatively' evaluate. This causes us to miss out on some legitimate caching opportunities, but ensures that our speculative evaluation cannot pollute any of the caches from the 'real' `InferCtxt`. The evaluation can still update *global* caches, but our global caches don't have any notion of 'in progress', so this is fine. Fixes rust-lang#90662
be7a68b
to
04964d7
Compare
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 04964d7 with merge 267787aa5ef8c1a8030445f1baded8c450b61d2a... |
☀️ Try build successful - checks-actions |
Queued 267787aa5ef8c1a8030445f1baded8c450b61d2a with parent 1e79d79, future comparison URL. |
Finished benchmarking commit (267787aa5ef8c1a8030445f1baded8c450b61d2a): comparison url. Summary: This change led to very large relevant regressions 😿 in compiler performance.
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 |
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 931a3a6 with merge 48ed0538da3299e6f9820d237251c584e3cf3546... |
💥 Test timed out |
@bors try |
⌛ Trying commit 931a3a6 with merge ce10115f5e07e18e55f328a29a2c47fab24e1338... |
☀️ Try build successful - checks-actions |
Queued ce10115f5e07e18e55f328a29a2c47fab24e1338 with parent 58f9efd, future comparison URL. |
Finished benchmarking commit (ce10115f5e07e18e55f328a29a2c47fab24e1338): comparison url. Summary: This change led to very large relevant regressions 😿 in compiler performance.
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 |
After some further thought, I think this strategy is insufficient to complete fix the issue. We could still end up hitting a spurious I think we need to avoid speculative evaluation entirely. PR #89831 remove speculative evaluation (among other things), but it causes a significant performance hit. Since this bug is currently preventing code from compiling, we might want to accept the performance hit for the time being. |
Closing since this is getting removed anyways |
The existing
InferCtxt
may already have in-progress projectionsfor some of the predicates we may (recursively evaluate). This can
cause us to incorrect produce (and cache!)
EvaluatedToRecur
, leadingus to incorrectly mark a predicate as unimplemented.
We now create a fresh
InferCtxt
for each sub-obligation that we'speculatively' evaluate. This causes us to miss out on some
legitimate caching opportunities, but ensures that our speculative
evaluation cannot pollute any of the caches from the 'real'
InferCtxt
.The evaluation can still update global caches, but our global caches
don't have any notion of 'in progress', so this is fine.
Fixes #90662