Skip to content

re-use Sized fast-path #139577

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

Merged
merged 1 commit into from
Apr 14, 2025
Merged

re-use Sized fast-path #139577

merged 1 commit into from
Apr 14, 2025

Conversation

davidtwco
Copy link
Member

There's an existing fast path for the type_op_prove_predicate predicate, checking for trivially Sized types, which can be re-used when evaluating obligations within queries. This should improve performance and was found to be beneficial in #137944.

r? types

There's an existing fast path for the `type_op_prove_predicate`
predicate, checking for trivially `Sized` types, which can be re-used
when evaluating obligations within queries. This should improve
performance, particularly in anticipation of new sizedness traits being
added which can take advantage of this.
@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. labels Apr 9, 2025
@davidtwco
Copy link
Member Author

davidtwco commented Apr 9, 2025

@bors try

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 9, 2025
re-use `Sized` fast-path

There's an existing fast path for the `type_op_prove_predicate` predicate, checking for trivially `Sized` types, which can be re-used when evaluating obligations within queries. This should improve performance and was found to be beneficial in rust-lang#137944.

r? types
@bors
Copy link
Collaborator

bors commented Apr 9, 2025

⌛ Trying commit 72d17bf with merge de946b5...

@lqd
Copy link
Member

lqd commented Apr 9, 2025

@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 Apr 9, 2025
@bors
Copy link
Collaborator

bors commented Apr 9, 2025

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

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (de946b5): comparison URL.

Overall result: ✅ improvements - 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 is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.5% [-1.2%, -0.2%] 73
Improvements ✅
(secondary)
-1.8% [-12.1%, -0.1%] 55
All ❌✅ (primary) -0.5% [-1.2%, -0.2%] 73

Max RSS (memory usage)

Results (primary -1.9%, secondary 0.4%)

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)
6.6% [6.6%, 6.6%] 1
Regressions ❌
(secondary)
3.1% [1.0%, 4.5%] 5
Improvements ✅
(primary)
-2.5% [-8.2%, -0.5%] 15
Improvements ✅
(secondary)
-6.5% [-7.4%, -5.6%] 2
All ❌✅ (primary) -1.9% [-8.2%, 6.6%] 16

Cycles

Results (primary -1.0%, secondary -3.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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.0% [-1.1%, -0.9%] 2
Improvements ✅
(secondary)
-3.9% [-11.1%, -1.6%] 11
All ❌✅ (primary) -1.0% [-1.1%, -0.9%] 2

Binary size

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

Bootstrap: 779.721s -> 778.291s (-0.18%)
Artifact size: 366.13 MiB -> 366.06 MiB (-0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 9, 2025
davidtwco added a commit to davidtwco/rust that referenced this pull request Apr 10, 2025
davidtwco added a commit to davidtwco/rust that referenced this pull request Apr 14, 2025
@@ -504,3 +505,21 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for PlaceholderReplacer<'_, 'tcx> {
}
}
}

pub fn sizedness_fast_path<'tcx>(tcx: TyCtxt<'tcx>, predicate: ty::Predicate<'tcx>) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe name it is_sized_pred_for_trivially_sized_type?

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't name it that because I add to it later in the Sized work with MetaSized and "we have a MetaSized predicate that we can skip because there's a Sized predicate with the same self_ty in the ParamEnv" - I can rename it in this PR as you suggest, and then rename it back to something more general later if you want?

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm... I guess. It's nonobvious enough that you need to read the function anyway unless you already know what it is, then the name is unique enough.

Comment on lines +28 to +29
LL | fn server() -> impl {
| ^^^^ cannot infer type
Copy link
Contributor

Choose a reason for hiding this comment

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

lmao is this the {error type}: Sized fast path?

Copy link
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

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

r=me with function renamed

@oli-obk oli-obk assigned oli-obk and unassigned BoxyUwU Apr 14, 2025
@oli-obk
Copy link
Contributor

oli-obk commented Apr 14, 2025

@bors r+

@bors
Copy link
Collaborator

bors commented Apr 14, 2025

📌 Commit 72d17bf has been approved by oli-obk

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 Apr 14, 2025
@bors
Copy link
Collaborator

bors commented Apr 14, 2025

⌛ Testing commit 72d17bf with merge 2da29db...

@bors
Copy link
Collaborator

bors commented Apr 14, 2025

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing 2da29db to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 14, 2025
@bors bors merged commit 2da29db into rust-lang:master Apr 14, 2025
7 checks passed
@rustbot rustbot added this to the 1.88.0 milestone Apr 14, 2025
Copy link

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 990039e (parent) -> 2da29db (this PR)

Test differences

Show 6 test diffs

6 doctest diffs were found. These are ignored, as they are noisy.

Job duration changes

  1. x86_64-apple-2: 6457.7s -> 3952.7s (-38.8%)
  2. dist-x86_64-apple: 7629.4s -> 9267.1s (21.5%)
  3. dist-apple-various: 6999.1s -> 8156.3s (16.5%)
  4. dist-aarch64-apple: 5612.8s -> 4932.6s (-12.1%)
  5. x86_64-apple-1: 9100.0s -> 8246.2s (-9.4%)
  6. x86_64-mingw-2: 7383.7s -> 6831.3s (-7.5%)
  7. dist-x86_64-linux-alt: 7051.7s -> 7549.3s (7.1%)
  8. x86_64-msvc-ext1: 7178.1s -> 7632.5s (6.3%)
  9. x86_64-gnu-distcheck: 4809.7s -> 5081.9s (5.7%)
  10. dist-android: 2536.5s -> 2663.2s (5.0%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (2da29db): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.6% [-1.2%, -0.3%] 55
Improvements ✅
(secondary)
-2.1% [-12.2%, -0.4%] 44
All ❌✅ (primary) -0.6% [-1.2%, -0.3%] 55

Max RSS (memory usage)

Results (primary -1.1%, secondary 0.4%)

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)
1.3% [0.4%, 2.3%] 2
Regressions ❌
(secondary)
2.9% [2.8%, 3.0%] 2
Improvements ✅
(primary)
-1.6% [-3.0%, -0.4%] 9
Improvements ✅
(secondary)
-2.2% [-2.3%, -2.0%] 2
All ❌✅ (primary) -1.1% [-3.0%, 2.3%] 11

Cycles

Results (primary -0.6%, secondary -3.6%)

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.1% [2.1%, 2.1%] 1
Improvements ✅
(primary)
-0.6% [-0.6%, -0.6%] 1
Improvements ✅
(secondary)
-4.2% [-10.6%, -2.0%] 10
All ❌✅ (primary) -0.6% [-0.6%, -0.6%] 1

Binary size

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

Bootstrap: 781.448s -> 781.17s (-0.04%)
Artifact size: 365.12 MiB -> 365.07 MiB (-0.01%)

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. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants