Add a check for impossible predicates to trivial_const - #156934
Conversation
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
|
|
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Add a check for impossible predicates to trivial_const
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (131aad2): comparison URL. Overall result: ❌ regressions - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (secondary 2.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 2.0%, secondary 2.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 511.354s -> 510.996s (-0.07%) |
|
IMO the perf overhead is fine, all that the "regression" means is that the |
|
false global bounds continue to make me unhappy 😆 in the long term we hopefully can cleanup this special case but for now it seems reasonable enough to me. note that impossible_bounds uses the new solver internally even on stable. this seems reasonable enough to me and probably doesn't warrant wider sign off? cc @rust-lang/initiative-trait-system-refactor can you add something to the PR description which links to #147721 specifically helix's comment about trivial consts bypassing the existing jank around false global bounds on const items |
|
Updated. Feel free to just modify the PR description yourself, I don't really understand type system implementation context here I just identified where to insert the right hack to make a test case pass. |
| return None; | ||
| } | ||
|
|
||
| if crate::impossible_predicates::has_impossible_predicates(tcx, def.into()) { |
There was a problem hiding this comment.
| if crate::impossible_predicates::has_impossible_predicates(tcx, def.into()) { | |
| // If there are impossible predicates then MIR passes will replace the body with | |
| // `unreachable` causing const eval errors when trying to evaluate the body. For | |
| // now we avoid using trivial consts for such bodies so that the behaviour doesn't | |
| // change. | |
| if crate::impossible_predicates::has_impossible_predicates(tcx, def.into()) { |
There was a problem hiding this comment.
though, writing this out, your logic here just straight up looks at the MIR so I'm surprised there'd wind up being a divergence? are you looking at different MIR than what const eval actually executes? if so why :3
There was a problem hiding this comment.
are you looking at different MIR than what const eval actually executes? if so why :3
Yes. The entire idea of trivial_const is to bypass the numerous MIR passes and queries that are done on MIR bodies to lower consts, because in the common case all those passes and queries just add compile time.
It would probably make sense for trivial_const to intercept const lowering before MIR is built.
yeah, we already use this when building vtables, so relying on this more sgtm |
|
@bors squash |
This comment has been minimized.
This comment has been minimized.
* Add a check for impossible predicates to trivial_const * Improve comment on impossible predicates check Co-authored-by: Boxy <rust@boxyuwu.dev>
|
🔨 2 commits were squashed into 8dc9f9a. |
1fa0962 to
8dc9f9a
Compare
|
@bors r+ rollup=never (perf sensitive) |
This comment has been minimized.
This comment has been minimized.
Add a check for impossible predicates to trivial_const The problem here is that trivial consts bypass the MIR pass which replaces bodies with `unreachable` when there are false global bounds. see #147721 (comment). This fixes the problem, but it is a bit hacky. But maybe all the handling of false global bounds is hacky?
|
@bors yield |
|
Auto build was cancelled. Cancelled workflows: The next pull request likely to be tested is #157739. |
This comment has been minimized.
This comment has been minimized.
Add a check for impossible predicates to trivial_const The problem here is that trivial consts bypass the MIR pass which replaces bodies with `unreachable` when there are false global bounds. see #147721 (comment). This fixes the problem, but it is a bit hacky. But maybe all the handling of false global bounds is hacky?
|
💔 Test for 5f9f26e failed: CI. Failed job:
|
|
@bors retry |
|
A job failed! Check out the build log: (web) (plain enhanced) (plain) Click to see the possible cause of the failure (guessed by this bot) |
|
@bors p=6 |
This comment has been minimized.
This comment has been minimized.
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing a1e52fc (parent) -> 3bdd7f8 (this PR) Test differencesShow 4 test diffsStage 1
Stage 2
Additionally, 2 doctest diffs were found. These are ignored, as they are noisy. Job group index
Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 3bdd7f86fcecc0ea65d79e62e39a70c8a2aabf15 --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (3bdd7f8): comparison URL. Overall result: ❌ regressions - please read:Our benchmarks found a performance regression caused by this PR. Next Steps:
@rustbot label: +perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (secondary -3.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 4.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 519.113s -> 519.494s (0.07%) |
|
perf triage: This regression was justified per-merge in #156934 (comment) @rustbot label: +perf-regression-triaged |
…BoxyUwU Add a check for impossible predicates to trivial_const The problem here is that trivial consts bypass the MIR pass which replaces bodies with `unreachable` when there are false global bounds. see rust-lang#147721 (comment). This fixes the problem, but it is a bit hacky. But maybe all the handling of false global bounds is hacky?
View all comments
The problem here is that trivial consts bypass the MIR pass which replaces bodies with
unreachablewhen there are false global bounds. see #147721 (comment).This fixes the problem, but it is a bit hacky. But maybe all the handling of false global bounds is hacky?