-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 DeepRejectCtxt
to quickly reject ParamEnv
candidates
#128776
Conversation
{ | ||
return Err(NoSolution); | ||
} | ||
|
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 also add this for NormalizesTo
goals
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.
done
pub fn types_may_unify(self, lhs: I::Ty, rhs: I::Ty) -> bool { | ||
// Non rigid types may unify with each other. | ||
if !lhs.is_known_rigid() && !rhs.is_known_rigid() { | ||
return true; | ||
} |
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.
this means we never reject Param(T) == Param(U)
when treating params as rigid, compare their index
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.
fixed
5520ecc
to
a36b90f
Compare
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.
and also in project::assemble_candidates_from_predicates
to also use a fast-path when normalizing in the old solver
match ty.kind() { | ||
ty::Param(p) => match (self.treat_lhs_params, self.treat_rhs_params) { | ||
(TreatParams::AsRigid, TreatParams::AsRigid) => param == p, | ||
_ => true, |
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 exhaustively match here
(ty::Placeholder(lhs), ty::Placeholder(rhs)) => lhs == rhs, | ||
(ty::Placeholder(_), _) | (_, ty::Placeholder(_)) => false, | ||
|
||
_ => false, |
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.
this function has to be an overapproximation, so incorrectly returning false
would result in subtle bugs. Please exhaustively match here: (ty::Whatever | ty::Whatever | ...., _) | (_, ty::whatever | .....)
a36b90f
to
77fc853
Compare
(TreatParams::InstantiateWithInfer, TreatParams::AsRigid) | ||
| (TreatParams::AsRigid, TreatParams::InstantiateWithInfer) | ||
| (TreatParams::InstantiateWithInfer, TreatParams::InstantiateWithInfer) => { |
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.
(TreatParams::InstantiateWithInfer, TreatParams::AsRigid) | |
| (TreatParams::AsRigid, TreatParams::InstantiateWithInfer) | |
| (TreatParams::InstantiateWithInfer, TreatParams::InstantiateWithInfer) => { | |
(TreatParams::InstantiateWithInfer, _) | |
| (_, TreatParams::InstantiateWithInfer) => { |
small style preference
}, | ||
ty::Pat(obl_ty, _) => { | ||
} | ||
(ty::Param(_), ty::Placeholder(_)) | (ty::Placeholder(_), ty::Param(_)) => true, |
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.
not really relevant as it doesnt ever happen on stable, but ty::Param
and placeholder can't unify when treating params as rigid, so you can remove this branch and just use the self.treat_lhs_params == TreatParams::InstantiateWithInfer
branch
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Use `DeepRejectCtxt` to quickly reject `ParamEnv` candidates The description is on the [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/144729-t-types/topic/.5Basking.20for.20help.5D.20.60DeepRejectCtxt.60.20for.20param.20env.20candidates) r? `@lcnr`
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (7a0b60e): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDBenchmarking 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 @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)Results (primary -3.7%, secondary 2.9%)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.
CyclesResults (primary 2.3%)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.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 759.636s -> 760.059s (0.06%) |
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.
2 ideas for perf
- move all
(Rigid, _) | (_, Rigid) => false
into a single branch at the end
and if that doesn't fix the regressions make the deep reject ctxt instead be generic over TreatParams
🤔
A small statistical observation:
std:
We waste time more often in |
the impact on diesel seems quite desirable however. I think we can improve the performance of fast reject significantly so that even the ~20% hit rate from typenum is a perf improvement. |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Use `DeepRejectCtxt` to quickly reject `ParamEnv` candidates The description is on the [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/144729-t-types/topic/.5Basking.20for.20help.5D.20.60DeepRejectCtxt.60.20for.20param.20env.20candidates) r? `@lcnr`
The job Click to see the possible cause of the failure (guessed by this bot)
|
💔 Test failed - checks-actions |
@bors retry |
Use `DeepRejectCtxt` to quickly reject `ParamEnv` candidates The description is on the [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/144729-t-types/topic/.5Basking.20for.20help.5D.20.60DeepRejectCtxt.60.20for.20param.20env.20candidates) r? `@lcnr`
The job Click to see the possible cause of the failure (guessed by this bot)
|
💔 Test failed - checks-actions |
I think that's also a spurious error? cc @rust-lang/infra |
Sadly, yes. @bors retry |
☀️ Test successful - checks-actions |
Finished benchmarking commit (26b5599): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesResults (primary -1.8%)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.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 754.723s -> 756.217s (0.20%) |
Relevant upstream PR: rust-lang/rust#128776: The `TreatParams` enum variants were renamed. Resolves #3503 By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.
The description is on the zulip thread
r? @lcnr