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

Use new solver in evaluate_obligation query (when new solver is enabled) #107103

Merged

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Jan 20, 2023

(only when -Ztrait-solver=next, of course)

... Does this make sense? It seems to me like it should be reasonable, but maybe there's some reason why this is a bad idea.

r? @lcnr

Needs a perf run because I guess this solver == TraitSolver::Next check is on a hot path.

@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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Jan 20, 2023
@rustbot
Copy link
Collaborator

rustbot commented Jan 20, 2023

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

@compiler-errors
Copy link
Member Author

@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 Jan 20, 2023
@bors
Copy link
Contributor

bors commented Jan 20, 2023

⌛ Trying commit 3e31e7b112ec1faffa1f32f1423185fb70ecc474 with merge 198dee10dce45e624f5a7e09f329deac21a34261...

@compiler-errors compiler-errors changed the title Use new solver in evaluate_obligation query Use new solver in evaluate_obligation query (when new solver is enabled) Jan 20, 2023
@bors
Copy link
Contributor

bors commented Jan 20, 2023

☀️ Try build successful - checks-actions
Build commit: 198dee10dce45e624f5a7e09f329deac21a34261 (198dee10dce45e624f5a7e09f329deac21a34261)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (198dee10dce45e624f5a7e09f329deac21a34261): comparison URL.

Overall result: no relevant changes - no action needed

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.

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

Instruction count

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

Max RSS (memory usage)

Results

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)
1.9% [1.9%, 1.9%] 1
Improvements ✅
(primary)
-1.2% [-1.3%, -1.1%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.2% [-1.3%, -1.1%] 2

Cycles

Results

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)
-2.4% [-2.4%, -2.4%] 1
All ❌✅ (primary) - - 0

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 20, 2023
Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

I would like to also do the same for evaluate_predicates_recursively 🤔 and then ICE if -Ztrait-solver=next is ever enabled in evaluate_predicate_recursively. That would mean that apart from shallow selection, we never use the old solver when testing the old solver. That will need another perf run though as that code is even hotter.

apart from that 👍

compiler/rustc_traits/src/evaluate_obligation.rs Outdated Show resolved Hide resolved
@lcnr
Copy link
Contributor

lcnr commented Jan 20, 2023

@rustbot author

@rustbot rustbot 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 Jan 20, 2023
@compiler-errors
Copy link
Member Author

I know this isn't the final approach, but let's see how hot these if statements are in these calls are.

@bors try @rust-timer

@compiler-errors
Copy link
Member Author

@rust-timer queue

@rust-timer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jan 21, 2023

⌛ Trying commit 3ef7bb2836d152bc0a2a291f18f66b48916ec33b with merge b9518856fe196e67df8bd4040c2562710219eda2...

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 21, 2023
@bors
Copy link
Contributor

bors commented Jan 21, 2023

☀️ Try build successful - checks-actions
Build commit: b9518856fe196e67df8bd4040c2562710219eda2 (b9518856fe196e67df8bd4040c2562710219eda2)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b9518856fe196e67df8bd4040c2562710219eda2): comparison URL.

Overall result: ❌ regressions - ACTION NEEDED

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 a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.4% [0.4%, 0.4%] 2
Regressions ❌
(secondary)
0.8% [0.6%, 0.9%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.4% [0.4%, 0.4%] 2

Max RSS (memory usage)

Results

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)
1.8% [1.8%, 1.8%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.7% [-6.5%, -2.8%] 2
All ❌✅ (primary) - - 0

Cycles

Results

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)
2.6% [2.6%, 2.6%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

@oli-obk
Copy link
Contributor

oli-obk commented Jan 26, 2023

@bors rollup=always

@lcnr
Copy link
Contributor

lcnr commented Jan 26, 2023

@bors r- 😅

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 26, 2023
@lcnr
Copy link
Contributor

lcnr commented Jan 26, 2023

going to remove TyCtxtExt::evaluate_goal in #107321 because I want us to always use infcx.evaluate_root_goal instead. Having a solver API which doesn't canonicalize for you causes us to accidentally use a different canonicalization routine which will cause all kinds of issues (and causes us to cache less).

I think we should instead change infcx.evaluate_obligation to branch of -Ztrait-solver=next and call infcx.evaluate_root_obligation there without canonicalizing ourselves.

@compiler-errors
Copy link
Member Author

Makes sense

@compiler-errors
Copy link
Member Author

@rustbot ready

This could take a quick look, I'm using the same strategy as evaluation_probe to make sure we properly return EvaluatedToOkModulo{Opaques,Regions}.

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

lcnr commented Jan 27, 2023

can you move this to fn InferCtxt::evaluate_obligation? It feels unnecessary to use the query cache considering that we already have a trait solver cache (or well, will have)

r=me on the impl using probe though

@@ -141,11 +147,11 @@ type CanonicalResponse<'tcx> = Canonical<'tcx, Response<'tcx>>;
/// solver, merge the two responses again.
pub type QueryResult<'tcx> = Result<CanonicalResponse<'tcx>, NoSolution>;

pub trait TyCtxtExt<'tcx> {
pub trait TyCtxtSolveExt<'tcx> {
Copy link
Member Author

Choose a reason for hiding this comment

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

oops i guess i should revert this too lol

@lcnr lcnr mentioned this pull request Jan 27, 2023
11 tasks
@@ -92,6 +120,9 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
&self,
obligation: &PredicateObligation<'tcx>,
) -> EvaluationResult {
// Run canonical query. If overflow occurs, rerun from scratch but this time
Copy link
Member Author

Choose a reason for hiding this comment

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

This comment is a leftover from 2fd5516, and should have been moved to this function instead of left in evaluate_obligation, where this behavior notable does not occur.

@compiler-errors
Copy link
Member Author

@bors r=lcnr rollup=maybe

@bors
Copy link
Contributor

bors commented Jan 27, 2023

📌 Commit 5bfd90e has been approved by lcnr

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 27, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 27, 2023
…e_obligation, r=lcnr

Use new solver in `evaluate_obligation` query (when new solver is enabled)

(only when `-Ztrait-solver=next`, of course)

... Does this make sense? It seems to me like it should be reasonable, but maybe there's some reason why this is a bad idea.

r? `@lcnr`

Needs a perf run because I guess this `solver == TraitSolver::Next` check is on a hot path.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 28, 2023
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#107022 (Implement `SpecOptionPartialEq` for `cmp::Ordering`)
 - rust-lang#107100 (Use proper `InferCtxt` when probing for associated types in astconv)
 - rust-lang#107103 (Use new solver in `evaluate_obligation` query (when new solver is enabled))
 - rust-lang#107190 (Recover from more const arguments that are not wrapped in curly braces)
 - rust-lang#107306 (Correct suggestions for closure arguments that need a borrow)
 - rust-lang#107339 (internally change regions to be covariant)
 - rust-lang#107344 (Minor tweaks in the new solver)
 - rust-lang#107373 (Don't merge vtables when full debuginfo is enabled.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 3b6593a into rust-lang:master Jan 28, 2023
@rustbot rustbot added this to the 1.69.0 milestone Jan 28, 2023
@compiler-errors compiler-errors deleted the new-solver-evaluate_obligation branch August 11, 2023 20:08
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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants