Skip to content
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

do not eagerly use Reveal::All in const_eval_resolve_for_typeck #132418

Closed
wants to merge 1 commit into from

Conversation

lcnr
Copy link
Contributor

@lcnr lcnr commented Oct 31, 2024

We should not use RevealAll when resolving the instance; only when evaluating its body.

r? @BoxyUwU

we should not use `RevealAll` when resolving the instance
only when evaluating its body.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 31, 2024
@rustbot
Copy link
Collaborator

rustbot commented Oct 31, 2024

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

@lcnr
Copy link
Contributor Author

lcnr commented Oct 31, 2024

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 31, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 31, 2024
do not eagerly use `Reveal::All` in `const_eval_resolve_for_typeck`

We should not use `RevealAll` when resolving the instance; only when evaluating its body.

r? `@BoxyUwU`
@bors
Copy link
Contributor

bors commented Oct 31, 2024

⌛ Trying commit 780bd2f with merge 8b79e04...

//
// In case the query key would contain unconstrained inference variables, we bail instead.
if (unevaluated, param_env).has_non_region_infer() {
return Err(Either::Right(ErrorHandled::TooGeneric(span)));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anything that cares about infer vars should use infcx.try_const_eval_resolve :<

@bors
Copy link
Contributor

bors commented Oct 31, 2024

☀️ Try build successful - checks-actions
Build commit: 8b79e04 (8b79e04e23ef8433b4d1e41d936d3ed8e1173faf)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (8b79e04): comparison URL.

Overall result: ❌ regressions - please read the text below

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 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 @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

This 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.

mean range count
Regressions ❌
(primary)
0.2% [0.2%, 0.3%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [0.2%, 0.3%] 3

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

Results (secondary -6.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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-6.1% [-6.1%, -6.1%] 1
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 784.059s -> 782.369s (-0.22%)
Artifact size: 333.59 MiB -> 333.45 MiB (-0.04%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Nov 1, 2024
@BoxyUwU
Copy link
Member

BoxyUwU commented Nov 1, 2024

I like the general cleanup in this PR though I think it (unfortunately) makes sense to continue using a Reveal::All env for resolving instances when evaluating const arguments. We already use Reveal::All unconditionally when evaluating the body which means that we handle opaques "incorrectly" regardless.

Since getting an instance of an anon const will trivially succeed regardless of if it contains any opaque types, that means that not using Reveal::All introduces the possibility to have a const argument that fails to resolve (and therefore be evaluated) while it succeeding if wrapped in an anon const.

One thing we could do to avoid that would be to not reveal opaque types during ctfe in typeck but that seems like a far wider change (and also one that is perhaps not super desirable).

@BoxyUwU BoxyUwU added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 1, 2024
@lcnr
Copy link
Contributor Author

lcnr commented Nov 19, 2024

this is kinda irrelevant now that #132927 has landed, closing

@lcnr lcnr closed this Nov 19, 2024
@lcnr lcnr deleted the prepare-for-eval branch November 19, 2024 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants