-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Suppress errors in const eval during trait selection v2 #92674
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
Conversation
Co-authored-by: bjorn3 <[email protected]>
Some changes occured to the CTFE / Miri engine cc @rust-lang/miri Some changes occured to rustc_codegen_cranelift cc @bjorn3 Some changes occured to the CTFE / Miri engine cc @rust-lang/miri |
This comment has been minimized.
This comment has been minimized.
Don't understand why CI outputs that fmt failure. I did run tidy with --bless locally. |
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 53c0bab with merge fcb93cd944d39604d20b8ea2ec20a15d08c2f84b... |
☀️ Try build successful - checks-actions |
Queued fcb93cd944d39604d20b8ea2ec20a15d08c2f84b with parent 488acf8, future comparison URL. |
Finished benchmarking commit (fcb93cd944d39604d20b8ea2ec20a15d08c2f84b): comparison url. Summary: This change led to very large relevant mixed results 🤷 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 |
The notable thing in the perf regression is that |
let dedup_result = alloc_map.get(&id); | ||
debug!(?dedup_result); | ||
|
||
match param_env.reveal() { |
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.
these matches are not obvious to me. Can you explain them? I'm unsure what the rules are here.
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.
The rationale for those was as follows:
If we have stored a successful allocation with Reveal::Selection
then we can deduplicate that result on calls of dedup_eval_alloc_raw
with both Reveal::Selection
and Reveal::UserFacing
(since Selection
and UserFacing
only differ in that we keep certain errors silent with Selection
, but successful allocations are always equivalent). This is also the reason why we can deduplicate from saved calls with UserFacing
on calls with both Selection
and UserFacing
.
If we try to deduplicate with Reveal::All
we should be able to deduplicate from saved query results with both Selection
and UserFacing
, since All
will always succeed if either UserFacing
or Selection
have succeeded. On the other hand if we have a saved result with Reveal::All
, it's not guaranteed that query calls with Reveal::Selection
or Reveal::UserFacing
succeed, so we can't deduplicate from those.
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.
👍 please copy this comment into the source, it explains this perfectly
} | ||
_ => {} | ||
} | ||
tcx.sess.struct_span_err(span, "failed to evaluate the given constant") |
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.
all cases of this in the test suite are redundant.
EDIT: ah no, I just grepped badly...
This error message is still often redundant and then just noise. Not sure how to improve it though...
Yeah that's weird. |
The calls of @oli-obk Can you request another perf-run please? |
I'll address the review comments after a successful perf-run. |
@bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 78e4b6f with merge 74db553a3539cb722fc57e34b88a6871c7a89933... |
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
Queued 74db553a3539cb722fc57e34b88a6871c7a89933 with parent 0bcacb3, future comparison URL. |
Finished benchmarking commit (74db553a3539cb722fc57e34b88a6871c7a89933): comparison url. Summary: This change led to small relevant improvements 🎉 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. @bors rollup=never |
This comment has been minimized.
This comment has been minimized.
864a3e8
to
6ead573
Compare
This comment has been minimized.
This comment has been minimized.
6ead573
to
66a689c
Compare
The job Click to see the possible cause of the failure (guessed by this bot)
|
Your approach sadly doesn't work, adding interior mutability to the For an example how your current approach could break, consider the following scenario:
I believe that the only way to soundly avoid recomputations with different Sorry for only looking at this PR now and thanks for working on this 🙇❤️ |
@lcnr Thanks for the review. I think the problem you describe should be solved by the changes introduced in the commit |
yes, my example was incorrect after this commit, but the issue that queries should remain pure functions still remains. We now get the following scenario:
This might seem fine as It still has issues, most noticeably this introduces nondeterminism in the compiler (especially once we run queries in parallel, which we do want). If we first compute I wouldn't be surprised if this causes other subtle issues for our query system, at this point you have to ask people more involved than me |
Ok, thanks for clarifying this. I can close this PR, but I would definitely still be interested in working on the issue and getting the idea implemented. There is one thing I don't understand about your example though:
It can't be because the result is already cached, because in a scenario in which we didn't have the deduplication logic and in which some other |
that was me not being careful enough while writing it, should have fixed it in the above comment.
definitely. I would be interested in you reviving #92653. I should be able to take the time for a first look at it this week, either after you're reopened it or even before then if it is already somewhat ready (ignoring perf for now) |
Thanks, that makes sense to me now. I'll ping you about further work on this issue on zulip. |
This is the second attempt of #92653
Significantly reduces the complexity of the previous PR. Hopefully also result in better perf results.
Needs a perf-run.
r? @oli-obk
cc @lcnr @RalfJung