Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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

Add SliceLike to rustc_type_ir, use it in the generic solver code (+ some other changes) #126813

Merged
merged 3 commits into from
Jun 25, 2024

Conversation

compiler-errors
Copy link
Member

First, we split out TraitRef::new_from_args which takes just ty::GenericArgsRef from TraitRef::new which takes impl IntoIterator<Item: Into<GenericArg>>. I will explain in a minute why.

Second, we introduce SliceLike, which allows us to be generic over List<T> and [T]. This trait has an as_slice() and into_iter() method, and some other convenience functions. However, importantly, since types like I::GenericArgs now implement SliceLike rather than IntoIter<Item = I::GenericArg>, we can't use TraitRef::new on this directly. That's where new_from_args comes in.

Finally, we adjust all the code to use these slice operators. Some things get simpler, some things get a bit more annoying since we need to use as_slice() in a few places. 🤷

r? lcnr

@rustbot rustbot added PG-exploit-mitigations Project group: Exploit mitigations 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 labels Jun 21, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jun 21, 2024

Some changes occurred in match checking

cc @Nadrieril

Some changes occurred in compiler/rustc_sanitizers

cc @rust-lang/project-exploit-mitigations, @rcvalle

HIR ty lowering was modified

cc @fmease

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@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 Jun 21, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 21, 2024
Add `SliceLike` to `rustc_type_ir`, use it in the generic solver code (+ some other changes)

First, we split out `TraitRef::new_from_args` which takes *just* `ty::GenericArgsRef` from `TraitRef::new` which takes `impl IntoIterator<Item: Into<GenericArg>>`. I will explain in a minute why.

Second, we introduce `SliceLike`, which allows us to be generic over `List<T>` and `[T]`. This trait has an `as_slice()` and `into_iter()` method, and some other convenience functions. However, importantly, since types like `I::GenericArgs` now implement `SliceLike` rather than `IntoIter<Item = I::GenericArg>`, we can't use `TraitRef::new` on this directly. That's where `new_from_args` comes in.

Finally, we adjust all the code to use these slice operators. Some things get simpler, some things get a bit more annoying since we need to use `as_slice()` in a few places. 🤷

r? lcnr
@bors
Copy link
Contributor

bors commented Jun 21, 2024

⌛ Trying commit 0770597 with merge d906ddd...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jun 22, 2024

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

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (d906ddd): comparison URL.

Overall result: ❌✅ regressions and improvements - 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
Regressions ❌
(secondary)
0.5% [0.4%, 0.9%] 7
Improvements ✅
(primary)
-0.3% [-0.6%, -0.2%] 18
Improvements ✅
(secondary)
-0.5% [-0.5%, -0.4%] 7
All ❌✅ (primary) -0.3% [-0.6%, -0.2%] 18

Max RSS (memory usage)

Results (primary -3.5%, secondary 3.1%)

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

Cycles

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

Binary size

Results (secondary 0.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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.3% [0.3%, 0.3%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Bootstrap: 697.477s -> 694.569s (-0.42%)
Artifact size: 326.87 MiB -> 326.70 MiB (-0.05%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 22, 2024
@compiler-errors
Copy link
Member Author

Looks like there's a slight perf improvement -- either noise, or because of the addition of new_from_args constructors which mean we don't try to re-intern GenericArgsRef once it's interned.

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.

iter::zip(a.into_iter(), b.into_iter()) seems quite confusing. What are your thoughts about adding zip to slice_like to handle this. Alternatively zip_slice_like as a free function

#[derivative(Debug = "ignore")]
pub(crate) _use_alias_ty_new_instead: (),
}

impl<I: Interner> AliasTy<I> {
pub fn new_from_args(interner: I, def_id: I::DefId, args: I::GenericArgs) -> AliasTy<I> {
Copy link
Contributor

@lcnr lcnr Jun 23, 2024

Choose a reason for hiding this comment

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

can now just delegate to new_from_args?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, that's simpler

@compiler-errors
Copy link
Member Author

iter::zip(a.into_iter(), b.into_iter()) seems quite confusing. What are your thoughts about adding zip to slice_like to handle this. Alternatively zip_slice_like as a free function.

It seems excessive to basically pull down one iterator combination. I don't actually understand what you find confusing about that, either. I guess I could make it slightly less noisy by renaming SliceLike::into_iter into SliceLike::iter so it's consistent with List::iter which returns impl Iterator<Item = T>?

zip_slice_like also seems weird because we still need to call std::iter::zip in case we're zipping a SliceLike and non-slice like thing (i.e. a range) -- we have a couple of those calls. I'd rather keep it "as close" to stdlib as possible so users don't need to choose whether to use the real zip or one that just copies it with name punning.

@lcnr
Copy link
Contributor

lcnr commented Jun 24, 2024

yeah, I'd prefer fn iter over fn into_iter so that it's clear we're not using the method from IntoIterator.

@lcnr
Copy link
Contributor

lcnr commented Jun 24, 2024

@bors r+ rollup=never

@bors
Copy link
Contributor

bors commented Jun 24, 2024

📌 Commit d521e21 has been approved by lcnr

It is now in the queue for this repository.

@bors bors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 24, 2024
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jun 24, 2024
@bors
Copy link
Contributor

bors commented Jun 25, 2024

⌛ Testing commit d521e21 with merge 5b270e1...

@bors
Copy link
Contributor

bors commented Jun 25, 2024

☀️ Test successful - checks-actions
Approved by: lcnr
Pushing 5b270e1 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 25, 2024
@bors bors merged commit 5b270e1 into rust-lang:master Jun 25, 2024
7 checks passed
@rustbot rustbot added this to the 1.81.0 milestone Jun 25, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (5b270e1): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

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
Regressions ❌
(secondary)
0.5% [0.4%, 0.8%] 7
Improvements ✅
(primary)
-0.4% [-0.6%, -0.3%] 12
Improvements ✅
(secondary)
-0.7% [-2.2%, -0.2%] 9
All ❌✅ (primary) -0.4% [-0.6%, -0.3%] 12

Max RSS (memory usage)

Results (primary -2.1%, secondary -3.5%)

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

Cycles

Results (primary -2.0%)

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)
-2.0% [-3.1%, -0.9%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.0% [-3.1%, -0.9%] 2

Binary size

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

Bootstrap: 692.774s -> 693.576s (0.12%)
Artifact size: 326.72 MiB -> 326.73 MiB (0.00%)

@pnkfelix
Copy link
Member

pnkfelix commented Jul 2, 2024

  • regressions are all to secondary benchmark: match-stress
  • marking as triaged

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. PG-exploit-mitigations Project group: Exploit mitigations 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants