Repository navigation
Auto trait finder: Avoid recomputing ParamEnv if nothing changed - #165774
Conversation
|
@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.
This comment has been minimized.
This comment has been minimized.
1ace453 to
1f10ed1
Compare
1f10ed1 to
82cac95
Compare
|
@bors try cancel |
|
Try build cancelled. Cancelled workflows: Hint: if you want to run another try build, you do not need to manually cancel the previous one. Just run |
|
@bors try |
This comment has been minimized.
This comment has been minimized.
82cac95 to
11705bd
Compare
|
@bors try cancel |
|
Try build cancelled. Cancelled workflows: Hint: if you want to run another try build, you do not need to manually cancel the previous one. Just run |
|
@bors try |
This comment has been minimized.
This comment has been minimized.
|
(You don't need to cancel try builds manually, if you do |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (20a62ed): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking 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. @bors rollup=never rustc-perf Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary 1.1%, secondary 1.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -5.2%, secondary -2.0%)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: 482.793s -> 484.101s (0.27%) |
|
well, that's pretty worth it! |
11705bd to
2a137d3
Compare
|
@bors r=fmease |
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
This pull request was unapproved. |
|
⌛ Testing commit 2a137d3 with merge 3933833... Workflow: https://github.com/rust-lang/rust/actions/runs/44259539524 |
Auto trait finder: Avoid recomputing `ParamEnv` if nothing changed r? @fmease > [!NOTE] > <table> > <tr><td> > >  > > </td><td> > > [I've not used an LLM for any part of this PR, or any other PR I make. This includes any related work like research.](https://0rwx.com/.) > > </td></tr> > </table>
|
|
|
Auto build was cancelled. Cancelled workflows: The next pull request likely to be tested is #166141. |
|
fair enough, sad :/ |
…uwer Rollup of 4 perf-sensitive pull requests Successful merges: - #165396 (Perf - Separate flag computation & intern functions per `TyKind`) - #165774 (Auto trait finder: Avoid recomputing `ParamEnv` if nothing changed) - #165863 (Avoid instantiating `FnSig` when not necessary) - #166084 (Avoid unnecessary LLVM passes when thin LTO buffer is null)
Rollup merge of #165774 - jdonszelmann:better-auto-traits, r=fmease Auto trait finder: Avoid recomputing `ParamEnv` if nothing changed r? @fmease > [!NOTE] > <table> > <tr><td> > >  > > </td><td> > > [I've not used an LLM for any part of this PR, or any other PR I make. This includes any related work like research.](https://0rwx.com/.) > > </td></tr> > </table>
|
Note This PR was benchmarked as part of triage of its containing rollup: triage URL. Finished benchmarking commit (89b1c43): comparison URL. Overall result: ✅ improvements - no action needed@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 -1.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -4.7%, secondary -1.1%)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. Artifact size: 405.23 MiB -> 405.27 MiB (0.01%) |
…illa
Compressed `ParamEnv`s for common marker traits
r? project-trait-system-refactor
This implements "compressed" `ParamEnv`s. It uses the fact that a lot of paramenvs contain many similar bounds on each generic. For example:
```rust
fn foo<A: Clone, B: Clone>(a: A, b: B) {}
```
Contains the bounds `A: Clone, A: Sized, A: MetaSized, B: Clone, B: Sized, B: MetaSized`.
The fact that metasized is in there is already enough of a problem that it is in fact not in there, and we have many hacks to avoid it in many cases which I hope to remove soon.
The new representation of this would be two bitsets:
```
A: <bitset containing Clone | Sized | MetaSized>, B: <bitset containing Clone | Sized | MetaSized>
```
The bitsets can contain the following traits:
- Sized
- MetaSized
- PointeeSized (which may be unused right now? May remove this one again in the future since it kinda represents the absence of any bounds)
- Clone
- Copy
- Debug
- Drop
- Unpin
- Eq
- Send
- Sync
Note that in the future this optimization becomes more important given that we're in the process of experimenting with more implicit trait bounds. In the future, `A: Clone` may expand to `A: Clone, A: Sized, A: MetaSized, A: Forget, A: Move, A: Destruct, A: Leak`, and with this PR those will all become just `A: <bitset containing Sized | MetaSized | Forget | Move | Destruct | Leak>`
On its own this optimization isn't necessarily worth a lot, because by storing these common predicates in a bitset, we actually stop interning them upfront. On access (and they're commonly accessed) we have to re-intern them which is terrible. The real speedup comes from knowing better *in advance* what bounds we're looking for. Using the new paramenv iterators, caller bounds iterators can say that they're looking for a predicate referencing a specific trait and for a specific self type. If we know that, we and the trait isn't any of the compressed traits, or the self type isn't the one of a specific compressed bitset, we can skip the entire set in one step. This optimization needs to offset the cost of re-interning for this optimization to be worth anything.
Note: this PR may be slightly perf-negative on rustdoc. It looks positive in the latest perf runs but that's because it's based on #165774 which improves rustdoc perf a lot. It improves some benchmark by up to 16% and this PR regresses it back by about 1%. See also #165460 (comment), #165774
> [!NOTE]
> <table>
> <tr><td>
>
> 
>
> </td><td>
>
> [I've not used an LLM for any part of this PR, or any other PR I make. This includes any related work like research.](https://0rwx.com/)
>
> </td></tr>
> </table>
…illa
Compressed `ParamEnv`s for common marker traits
r? project-trait-system-refactor
This implements "compressed" `ParamEnv`s. It uses the fact that a lot of paramenvs contain many similar bounds on each generic. For example:
```rust
fn foo<A: Clone, B: Clone>(a: A, b: B) {}
```
Contains the bounds `A: Clone, A: Sized, A: MetaSized, B: Clone, B: Sized, B: MetaSized`.
The fact that metasized is in there is already enough of a problem that it is in fact not in there, and we have many hacks to avoid it in many cases which I hope to remove soon.
The new representation of this would be two bitsets:
```
A: <bitset containing Clone | Sized | MetaSized>, B: <bitset containing Clone | Sized | MetaSized>
```
The bitsets can contain the following traits:
- Sized
- MetaSized
- PointeeSized (which may be unused right now? May remove this one again in the future since it kinda represents the absence of any bounds)
- Clone
- Copy
- Debug
- Drop
- Unpin
- Eq
- Send
- Sync
Note that in the future this optimization becomes more important given that we're in the process of experimenting with more implicit trait bounds. In the future, `A: Clone` may expand to `A: Clone, A: Sized, A: MetaSized, A: Forget, A: Move, A: Destruct, A: Leak`, and with this PR those will all become just `A: <bitset containing Sized | MetaSized | Forget | Move | Destruct | Leak>`
On its own this optimization isn't necessarily worth a lot, because by storing these common predicates in a bitset, we actually stop interning them upfront. On access (and they're commonly accessed) we have to re-intern them which is terrible. The real speedup comes from knowing better *in advance* what bounds we're looking for. Using the new paramenv iterators, caller bounds iterators can say that they're looking for a predicate referencing a specific trait and for a specific self type. If we know that, we and the trait isn't any of the compressed traits, or the self type isn't the one of a specific compressed bitset, we can skip the entire set in one step. This optimization needs to offset the cost of re-interning for this optimization to be worth anything.
Note: this PR may be slightly perf-negative on rustdoc. It looks positive in the latest perf runs but that's because it's based on #165774 which improves rustdoc perf a lot. It improves some benchmark by up to 16% and this PR regresses it back by about 1%. See also #165460 (comment), #165774
> [!NOTE]
> <table>
> <tr><td>
>
> 
>
> </td><td>
>
> [I've not used an LLM for any part of this PR, or any other PR I make. This includes any related work like research.](https://0rwx.com/)
>
> </td></tr>
> </table>
…illa
Compressed `ParamEnv`s for common marker traits
r? project-trait-system-refactor
This implements "compressed" `ParamEnv`s. It uses the fact that a lot of paramenvs contain many similar bounds on each generic. For example:
```rust
fn foo<A: Clone, B: Clone>(a: A, b: B) {}
```
Contains the bounds `A: Clone, A: Sized, A: MetaSized, B: Clone, B: Sized, B: MetaSized`.
The fact that metasized is in there is already enough of a problem that it is in fact not in there, and we have many hacks to avoid it in many cases which I hope to remove soon.
The new representation of this would be two bitsets:
```
A: <bitset containing Clone | Sized | MetaSized>, B: <bitset containing Clone | Sized | MetaSized>
```
The bitsets can contain the following traits:
- Sized
- MetaSized
- PointeeSized (which may be unused right now? May remove this one again in the future since it kinda represents the absence of any bounds)
- Clone
- Copy
- Debug
- Drop
- Unpin
- Eq
- Send
- Sync
Note that in the future this optimization becomes more important given that we're in the process of experimenting with more implicit trait bounds. In the future, `A: Clone` may expand to `A: Clone, A: Sized, A: MetaSized, A: Forget, A: Move, A: Destruct, A: Leak`, and with this PR those will all become just `A: <bitset containing Sized | MetaSized | Forget | Move | Destruct | Leak>`
On its own this optimization isn't necessarily worth a lot, because by storing these common predicates in a bitset, we actually stop interning them upfront. On access (and they're commonly accessed) we have to re-intern them which is terrible. The real speedup comes from knowing better *in advance* what bounds we're looking for. Using the new paramenv iterators, caller bounds iterators can say that they're looking for a predicate referencing a specific trait and for a specific self type. If we know that, we and the trait isn't any of the compressed traits, or the self type isn't the one of a specific compressed bitset, we can skip the entire set in one step. This optimization needs to offset the cost of re-interning for this optimization to be worth anything.
Note: this PR may be slightly perf-negative on rustdoc. It looks positive in the latest perf runs but that's because it's based on #165774 which improves rustdoc perf a lot. It improves some benchmark by up to 16% and this PR regresses it back by about 1%. See also #165460 (comment), #165774
> [!NOTE]
> <table>
> <tr><td>
>
> 
>
> </td><td>
>
> [I've not used an LLM for any part of this PR, or any other PR I make. This includes any related work like research.](https://0rwx.com/)
>
> </td></tr>
> </table>
…illa
Compressed `ParamEnv`s for common marker traits
r? project-trait-system-refactor
This implements "compressed" `ParamEnv`s. It uses the fact that a lot of paramenvs contain many similar bounds on each generic. For example:
```rust
fn foo<A: Clone, B: Clone>(a: A, b: B) {}
```
Contains the bounds `A: Clone, A: Sized, A: MetaSized, B: Clone, B: Sized, B: MetaSized`.
The fact that metasized is in there is already enough of a problem that it is in fact not in there, and we have many hacks to avoid it in many cases which I hope to remove soon.
The new representation of this would be two bitsets:
```
A: <bitset containing Clone | Sized | MetaSized>, B: <bitset containing Clone | Sized | MetaSized>
```
The bitsets can contain the following traits:
- Sized
- MetaSized
- PointeeSized (which may be unused right now? May remove this one again in the future since it kinda represents the absence of any bounds)
- Clone
- Copy
- Debug
- Drop
- Unpin
- Eq
- Send
- Sync
Note that in the future this optimization becomes more important given that we're in the process of experimenting with more implicit trait bounds. In the future, `A: Clone` may expand to `A: Clone, A: Sized, A: MetaSized, A: Forget, A: Move, A: Destruct, A: Leak`, and with this PR those will all become just `A: <bitset containing Sized | MetaSized | Forget | Move | Destruct | Leak>`
On its own this optimization isn't necessarily worth a lot, because by storing these common predicates in a bitset, we actually stop interning them upfront. On access (and they're commonly accessed) we have to re-intern them which is terrible. The real speedup comes from knowing better *in advance* what bounds we're looking for. Using the new paramenv iterators, caller bounds iterators can say that they're looking for a predicate referencing a specific trait and for a specific self type. If we know that, we and the trait isn't any of the compressed traits, or the self type isn't the one of a specific compressed bitset, we can skip the entire set in one step. This optimization needs to offset the cost of re-interning for this optimization to be worth anything.
Note: this PR may be slightly perf-negative on rustdoc. It looks positive in the latest perf runs but that's because it's based on #165774 which improves rustdoc perf a lot. It improves some benchmark by up to 16% and this PR regresses it back by about 1%. See also #165460 (comment), #165774
> [!NOTE]
> <table>
> <tr><td>
>
> 
>
> </td><td>
>
> [I've not used an LLM for any part of this PR, or any other PR I make. This includes any related work like research.](https://0rwx.com/)
>
> </td></tr>
> </table>
…illa
Compressed `ParamEnv`s for common marker traits
r? project-trait-system-refactor
This implements "compressed" `ParamEnv`s. It uses the fact that a lot of paramenvs contain many similar bounds on each generic. For example:
```rust
fn foo<A: Clone, B: Clone>(a: A, b: B) {}
```
Contains the bounds `A: Clone, A: Sized, A: MetaSized, B: Clone, B: Sized, B: MetaSized`.
The fact that metasized is in there is already enough of a problem that it is in fact not in there, and we have many hacks to avoid it in many cases which I hope to remove soon.
The new representation of this would be two bitsets:
```
A: <bitset containing Clone | Sized | MetaSized>, B: <bitset containing Clone | Sized | MetaSized>
```
The bitsets can contain the following traits:
- Sized
- MetaSized
- PointeeSized (which may be unused right now? May remove this one again in the future since it kinda represents the absence of any bounds)
- Clone
- Copy
- Debug
- Drop
- Unpin
- Eq
- Send
- Sync
Note that in the future this optimization becomes more important given that we're in the process of experimenting with more implicit trait bounds. In the future, `A: Clone` may expand to `A: Clone, A: Sized, A: MetaSized, A: Forget, A: Move, A: Destruct, A: Leak`, and with this PR those will all become just `A: <bitset containing Sized | MetaSized | Forget | Move | Destruct | Leak>`
On its own this optimization isn't necessarily worth a lot, because by storing these common predicates in a bitset, we actually stop interning them upfront. On access (and they're commonly accessed) we have to re-intern them which is terrible. The real speedup comes from knowing better *in advance* what bounds we're looking for. Using the new paramenv iterators, caller bounds iterators can say that they're looking for a predicate referencing a specific trait and for a specific self type. If we know that, we and the trait isn't any of the compressed traits, or the self type isn't the one of a specific compressed bitset, we can skip the entire set in one step. This optimization needs to offset the cost of re-interning for this optimization to be worth anything.
Note: this PR may be slightly perf-negative on rustdoc. It looks positive in the latest perf runs but that's because it's based on rust-lang/rust#165774 which improves rustdoc perf a lot. It improves some benchmark by up to 16% and this PR regresses it back by about 1%. See also rust-lang/rust#165460 (comment), rust-lang/rust#165774
> [!NOTE]
> <table>
> <tr><td>
>
> 
>
> </td><td>
>
> [I've not used an LLM for any part of this PR, or any other PR I make. This includes any related work like research.](https://0rwx.com/)
>
> </td></tr>
> </table>
…illa
Compressed `ParamEnv`s for common marker traits
r? project-trait-system-refactor
This implements "compressed" `ParamEnv`s. It uses the fact that a lot of paramenvs contain many similar bounds on each generic. For example:
```rust
fn foo<A: Clone, B: Clone>(a: A, b: B) {}
```
Contains the bounds `A: Clone, A: Sized, A: MetaSized, B: Clone, B: Sized, B: MetaSized`.
The fact that metasized is in there is already enough of a problem that it is in fact not in there, and we have many hacks to avoid it in many cases which I hope to remove soon.
The new representation of this would be two bitsets:
```
A: <bitset containing Clone | Sized | MetaSized>, B: <bitset containing Clone | Sized | MetaSized>
```
The bitsets can contain the following traits:
- Sized
- MetaSized
- PointeeSized (which may be unused right now? May remove this one again in the future since it kinda represents the absence of any bounds)
- Clone
- Copy
- Debug
- Drop
- Unpin
- Eq
- Send
- Sync
Note that in the future this optimization becomes more important given that we're in the process of experimenting with more implicit trait bounds. In the future, `A: Clone` may expand to `A: Clone, A: Sized, A: MetaSized, A: Forget, A: Move, A: Destruct, A: Leak`, and with this PR those will all become just `A: <bitset containing Sized | MetaSized | Forget | Move | Destruct | Leak>`
On its own this optimization isn't necessarily worth a lot, because by storing these common predicates in a bitset, we actually stop interning them upfront. On access (and they're commonly accessed) we have to re-intern them which is terrible. The real speedup comes from knowing better *in advance* what bounds we're looking for. Using the new paramenv iterators, caller bounds iterators can say that they're looking for a predicate referencing a specific trait and for a specific self type. If we know that, we and the trait isn't any of the compressed traits, or the self type isn't the one of a specific compressed bitset, we can skip the entire set in one step. This optimization needs to offset the cost of re-interning for this optimization to be worth anything.
Note: this PR may be slightly perf-negative on rustdoc. It looks positive in the latest perf runs but that's because it's based on rust-lang/rust#165774 which improves rustdoc perf a lot. It improves some benchmark by up to 16% and this PR regresses it back by about 1%. See also rust-lang/rust#165460 (comment), rust-lang/rust#165774
> [!NOTE]
> <table>
> <tr><td>
>
> 
>
> </td><td>
>
> [I've not used an LLM for any part of this PR, or any other PR I make. This includes any related work like research.](https://0rwx.com/)
>
> </td></tr>
> </table>
…illa
Compressed `ParamEnv`s for common marker traits
r? project-trait-system-refactor
This implements "compressed" `ParamEnv`s. It uses the fact that a lot of paramenvs contain many similar bounds on each generic. For example:
```rust
fn foo<A: Clone, B: Clone>(a: A, b: B) {}
```
Contains the bounds `A: Clone, A: Sized, A: MetaSized, B: Clone, B: Sized, B: MetaSized`.
The fact that metasized is in there is already enough of a problem that it is in fact not in there, and we have many hacks to avoid it in many cases which I hope to remove soon.
The new representation of this would be two bitsets:
```
A: <bitset containing Clone | Sized | MetaSized>, B: <bitset containing Clone | Sized | MetaSized>
```
The bitsets can contain the following traits:
- Sized
- MetaSized
- PointeeSized (which may be unused right now? May remove this one again in the future since it kinda represents the absence of any bounds)
- Clone
- Copy
- Debug
- Drop
- Unpin
- Eq
- Send
- Sync
Note that in the future this optimization becomes more important given that we're in the process of experimenting with more implicit trait bounds. In the future, `A: Clone` may expand to `A: Clone, A: Sized, A: MetaSized, A: Forget, A: Move, A: Destruct, A: Leak`, and with this PR those will all become just `A: <bitset containing Sized | MetaSized | Forget | Move | Destruct | Leak>`
On its own this optimization isn't necessarily worth a lot, because by storing these common predicates in a bitset, we actually stop interning them upfront. On access (and they're commonly accessed) we have to re-intern them which is terrible. The real speedup comes from knowing better *in advance* what bounds we're looking for. Using the new paramenv iterators, caller bounds iterators can say that they're looking for a predicate referencing a specific trait and for a specific self type. If we know that, we and the trait isn't any of the compressed traits, or the self type isn't the one of a specific compressed bitset, we can skip the entire set in one step. This optimization needs to offset the cost of re-interning for this optimization to be worth anything.
Note: this PR may be slightly perf-negative on rustdoc. It looks positive in the latest perf runs but that's because it's based on rust-lang/rust#165774 which improves rustdoc perf a lot. It improves some benchmark by up to 16% and this PR regresses it back by about 1%. See also rust-lang/rust#165460 (comment), rust-lang/rust#165774
> [!NOTE]
> <table>
> <tr><td>
>
> 
>
> </td><td>
>
> [I've not used an LLM for any part of this PR, or any other PR I make. This includes any related work like research.](https://0rwx.com/)
>
> </td></tr>
> </table>
View all comments
r? @fmease
Note
I've not used an LLM for any part of this PR, or any other PR I make. This includes any related work like research.