introduce canonical queries, use for normalization and dropck-outlives#48411
introduce canonical queries, use for normalization and dropck-outlives#48411bors merged 27 commits intorust-lang:masterfrom
Conversation
| let cause = ObligationCause::dummy(); | ||
| match infcx.at(&cause, param_env).normalize(&value) { | ||
| Ok(Normalized { value: normalized_value, obligations: _ }) => { | ||
| // ^^^^^^^^^^^ |
There was a problem hiding this comment.
How certain is this? Can you assert that this holds, or would that be too expensive?
There was a problem hiding this comment.
Hmm. It's probably worth asserting, or maybe refactoring the types to prove it.
src/librustc_trans/mir/mod.rs
Outdated
| where T: TransNormalize<'tcx> | ||
| where T: TypeFoldable<'tcx> | ||
| { | ||
| self.cx.tcx.trans_apply_param_substs(self.param_substs, value) |
There was a problem hiding this comment.
Can we get rid of trans_apply_param_substs now?
|
r=me with nits and build failure addressed |
|
@bors try I'd like to do a perf run. |
…try>
introduce canonical queries, use for normalization and dropck-outlives
This branch adds in the concept of a **canonicalized trait query** and uses it for three specific operations:
- `infcx.at(cause, param_env).normalize(type_foldable)`
- normalizes all associated types in `type_foldable`
- `tcx.normalize_erasing_regions(param_env, type_foldable)`
- like normalize, but erases regions first and in the result; this leads to better caching
- `infcx.at(cause, param_env).dropck_outlives(ty)`
- produces the set of types that must be live when a value of type `ty` is dropped
- used from dropck but also NLL outlives
This is a kind of "first step" towards a more Chalk-ified approach. It leads to a **big** speedup for NLL, which is basically dominated by the dropck-outlives computation. Here are some timing measurements for the `syn` crate (pre-branch measurements coming soon):
| Commit | NLL disabled | NLL enabled |
| ------- | --- | --- |
| Before my branch | 5.43s | 8.99s |
| After my branch | 5.36s | 7.25s |
(Note that NLL enabled still does *all the work* that NLL disabled does, so this is not really a way to compare the performance of NLL versus the AST-based borrow checker directly.) Since this affects all codepaths, I'd like to do a full perf run before we land anything.
Also, this is not the "final point" for canonicalization etc. I think canonicalization can be made substantially faster, for one thing. But it seems like a reasonable starting point for a branch that's gotten a bit larger than I would have liked.
**Commit convention:** First of all, this entire branch ought to be a "pure refactoring", I believe, not changing anything about external behavior. Second, I've tagged the most important commits with `[VIC]` (very important commit), so you can scan for those. =)
r? @eddyb
|
☀️ Test successful - status-travis |
|
cc @rust-lang/release -- I'd like to request a perf run. try build completed, not sure what other steps I need to do. |
|
I'll run it soon, for now just always ping me |
|
Perf started |
|
Here are the results: Also archived here, since I've noticed that perf links tend to go stale: http://smallcultfollowing.com/pr-48411/rustc%20performance%20data.htm (instructions) |
Major changes (>10%)Got worse:
Got better
Medium changes (3-10%)
Got better:
Small changes (<3%)
|
|
I'll try to take a look at |
|
@bors try |
|
🔒 Merge conflict |
0e84c2d to
41d762f
Compare
|
@bors try |
…try>
introduce canonical queries, use for normalization and dropck-outlives
This branch adds in the concept of a **canonicalized trait query** and uses it for three specific operations:
- `infcx.at(cause, param_env).normalize(type_foldable)`
- normalizes all associated types in `type_foldable`
- `tcx.normalize_erasing_regions(param_env, type_foldable)`
- like normalize, but erases regions first and in the result; this leads to better caching
- `infcx.at(cause, param_env).dropck_outlives(ty)`
- produces the set of types that must be live when a value of type `ty` is dropped
- used from dropck but also NLL outlives
This is a kind of "first step" towards a more Chalk-ified approach. It leads to a **big** speedup for NLL, which is basically dominated by the dropck-outlives computation. Here are some timing measurements for the `syn` crate (pre-branch measurements coming soon):
| Commit | NLL disabled | NLL enabled |
| ------- | --- | --- |
| Before my branch | 5.43s | 8.99s |
| After my branch | 5.36s | 7.25s |
(Note that NLL enabled still does *all the work* that NLL disabled does, so this is not really a way to compare the performance of NLL versus the AST-based borrow checker directly.) Since this affects all codepaths, I'd like to do a full perf run before we land anything.
Also, this is not the "final point" for canonicalization etc. I think canonicalization can be made substantially faster, for one thing. But it seems like a reasonable starting point for a branch that's gotten a bit larger than I would have liked.
**Commit convention:** First of all, this entire branch ought to be a "pure refactoring", I believe, not changing anything about external behavior. Second, I've tagged the most important commits with `[VIC]` (very important commit), so you can scan for those. =)
r? @eddyb
|
☀️ Test successful - status-travis |
|
Perf started for 251f865. |
|
@Mark-Simulacrum when I try to compare,I get errors about not having results for 063deba ... am I doing something wrong ? =) |
Consolidate `trans_apply_param_substs` and `trans_apply_param_substs_env`. Also remove `trans_impl_self_ty`
fbaf9cb to
17c4103
Compare
|
@bors r=eddyb |
|
📌 Commit 17c4103 has been approved by |
…ddyb
introduce canonical queries, use for normalization and dropck-outlives
This branch adds in the concept of a **canonicalized trait query** and uses it for three specific operations:
- `infcx.at(cause, param_env).normalize(type_foldable)`
- normalizes all associated types in `type_foldable`
- `tcx.normalize_erasing_regions(param_env, type_foldable)`
- like normalize, but erases regions first and in the result; this leads to better caching
- `infcx.at(cause, param_env).dropck_outlives(ty)`
- produces the set of types that must be live when a value of type `ty` is dropped
- used from dropck but also NLL outlives
This is a kind of "first step" towards a more Chalk-ified approach. It leads to a **big** speedup for NLL, which is basically dominated by the dropck-outlives computation. Here are some timing measurements for the `syn` crate (pre-branch measurements coming soon):
| Commit | NLL disabled | NLL enabled |
| ------- | --- | --- |
| Before my branch | 5.43s | 8.99s |
| After my branch | 5.36s | 7.25s |
(Note that NLL enabled still does *all the work* that NLL disabled does, so this is not really a way to compare the performance of NLL versus the AST-based borrow checker directly.) Since this affects all codepaths, I'd like to do a full perf run before we land anything.
Also, this is not the "final point" for canonicalization etc. I think canonicalization can be made substantially faster, for one thing. But it seems like a reasonable starting point for a branch that's gotten a bit larger than I would have liked.
**Commit convention:** First of all, this entire branch ought to be a "pure refactoring", I believe, not changing anything about external behavior. Second, I've tagged the most important commits with `[VIC]` (very important commit), so you can scan for those. =)
r? @eddyb
|
☀️ Test successful - status-appveyor, status-travis |
[WIP] Create a canonical trait query for `evaluate_obligation` This builds on the canonical query machinery introduced in #48411 to introduce a new canonical trait query for `evaluate_obligation` in the trait selector. Also ports most callers of the original `evaluate_obligation` to the new system (except in coherence, which requires support for intercrate mode). Closes #48537. r? @nikomatsakis
[WIP] Create a canonical trait query for `evaluate_obligation` This builds on the canonical query machinery introduced in #48411 to introduce a new canonical trait query for `evaluate_obligation` in the trait selector. Also ports most callers of the original `evaluate_obligation` to the new system (except in coherence, which requires support for intercrate mode). Closes #48537. r? @nikomatsakis
Create a canonical trait query for `evaluate_obligation` This builds on the canonical query machinery introduced in #48411 to introduce a new canonical trait query for `evaluate_obligation` in the trait selector. Also ports most callers of the original `evaluate_obligation` to the new system (except in coherence, which requires support for intercrate mode). Closes #48537. r? @nikomatsakis
|
FWIW, this (specifically, short-circuit |
This branch adds in the concept of a canonicalized trait query and uses it for three specific operations:
infcx.at(cause, param_env).normalize(type_foldable)type_foldabletcx.normalize_erasing_regions(param_env, type_foldable)infcx.at(cause, param_env).dropck_outlives(ty)tyis droppedThis is a kind of "first step" towards a more Chalk-ified approach. It leads to a big speedup for NLL, which is basically dominated by the dropck-outlives computation. Here are some timing measurements for the
syncrate (pre-branch measurements coming soon):(Note that NLL enabled still does all the work that NLL disabled does, so this is not really a way to compare the performance of NLL versus the AST-based borrow checker directly.) Since this affects all codepaths, I'd like to do a full perf run before we land anything.
Also, this is not the "final point" for canonicalization etc. I think canonicalization can be made substantially faster, for one thing. But it seems like a reasonable starting point for a branch that's gotten a bit larger than I would have liked.
Commit convention: First of all, this entire branch ought to be a "pure refactoring", I believe, not changing anything about external behavior. Second, I've tagged the most important commits with
[VIC](very important commit), so you can scan for those. =)r? @eddyb