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

Allow more top-down inlining for single-BB callees #138157

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

scottmcm
Copy link
Member

@scottmcm scottmcm commented Mar 7, 2025

This means that things like <usize as Step>::forward_unchecked and <PartialOrd for f32>::le will inline even if
we've already done a bunch of inlining to find the calls to them.

Fixes #138136

Draft as it's built atop #138135, which adds a mir-opt test that's a nice demonstration of this. To see just this change, look at 48f63e3 Rebased to be just the inlining change, as the other existing tests show it great.

@rustbot
Copy link
Collaborator

rustbot commented Mar 7, 2025

r? @Noratrieb

rustbot has assigned @Noratrieb.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Mar 7, 2025
@scottmcm
Copy link
Member Author

scottmcm commented Mar 7, 2025

@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 Mar 7, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 7, 2025
…<try>

Allow more top-down inlining for single-BB callees

This means that things like `<usize as Step>::forward_unchecked` and `<PartialOrd for f32>::le` will inline even if
we've already done a bunch of inlining to find the calls to them.

Fixes rust-lang#138136

Draft as it's built atop rust-lang#138135, which adds a mir-opt test that's a nice demonstration of this.
@bors
Copy link
Contributor

bors commented Mar 7, 2025

⌛ Trying commit 48f63e3 with merge 10923a0...

}

bb5: {
_8 = AddUnchecked(copy _7, const 1_u32);
Copy link
Member Author

Choose a reason for hiding this comment

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

Huzzah, a Range loop is finally optimized down to just the AddUnchecked(i, 1), no Step trait indirection.

cc @FractalFir who will probably appreciate this for other backends.

@bors
Copy link
Contributor

bors commented Mar 7, 2025

☀️ Try build successful - checks-actions
Build commit: 10923a0 (10923a044371351c6571ba4981524da06812575c)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (10923a0): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

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 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.8% [0.3%, 1.3%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.6% [-0.9%, -0.3%] 4
Improvements ✅
(secondary)
-0.3% [-0.4%, -0.1%] 2
All ❌✅ (primary) -0.1% [-0.9%, 1.3%] 6

Max RSS (memory usage)

Results (primary -0.6%, 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)
4.4% [1.7%, 7.2%] 2
Regressions ❌
(secondary)
2.1% [2.1%, 2.1%] 1
Improvements ✅
(primary)
-5.6% [-6.9%, -4.3%] 2
Improvements ✅
(secondary)
-2.7% [-2.7%, -2.7%] 1
All ❌✅ (primary) -0.6% [-6.9%, 7.2%] 4

Cycles

Results (primary -1.2%)

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.2% [-1.4%, -1.0%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.2% [-1.4%, -1.0%] 2

Binary size

Results (primary 0.1%, secondary 0.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.2% [0.0%, 2.3%] 40
Regressions ❌
(secondary)
0.1% [0.0%, 0.2%] 44
Improvements ✅
(primary)
-0.2% [-1.7%, -0.0%] 21
Improvements ✅
(secondary)
-0.2% [-0.2%, -0.2%] 2
All ❌✅ (primary) 0.1% [-1.7%, 2.3%] 61

Bootstrap: 766.551s -> 766.742s (0.02%)
Artifact size: 362.09 MiB -> 362.03 MiB (-0.02%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Mar 7, 2025
@scottmcm scottmcm force-pushed the inline-more-tiny-things branch from 48f63e3 to e6789c8 Compare March 8, 2025 05:03
@scottmcm
Copy link
Member Author

scottmcm commented Mar 8, 2025

@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 Mar 8, 2025
@bors
Copy link
Contributor

bors commented Mar 8, 2025

⌛ Trying commit e6789c8 with merge 3827dac...

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 8, 2025
…<try>

Allow more top-down inlining for single-BB callees

This means that things like `<usize as Step>::forward_unchecked` and `<PartialOrd for f32>::le` will inline even if
we've already done a bunch of inlining to find the calls to them.

Fixes rust-lang#138136

~~Draft as it's built atop rust-lang#138135, which adds a mir-opt test that's a nice demonstration of this.  To see just this change, look at <https://github.com/rust-lang/rust/pull/138157/commits/48f63e3be552605c2933056b77bf23a326757f92>~~ Rebased to be just the inlining change, as the other existing tests show it great.
@bors
Copy link
Contributor

bors commented Mar 8, 2025

☀️ Try build successful - checks-actions
Build commit: 3827dac (3827dac7a7e728ea164b3c64e4dd1fb716c06a58)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (3827dac): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

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 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.8% [0.4%, 1.3%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.6% [-0.9%, -0.3%] 5
Improvements ✅
(secondary)
-0.5% [-0.6%, -0.4%] 3
All ❌✅ (primary) -0.2% [-0.9%, 1.3%] 7

Max RSS (memory usage)

Results (primary -2.5%, secondary -3.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)
6.6% [6.6%, 6.6%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-4.3% [-8.5%, -2.3%] 5
Improvements ✅
(secondary)
-3.0% [-3.0%, -3.0%] 1
All ❌✅ (primary) -2.5% [-8.5%, 6.6%] 6

Cycles

Results (primary -1.2%, 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)
1.9% [1.9%, 1.9%] 1
Improvements ✅
(primary)
-1.2% [-1.2%, -1.2%] 1
Improvements ✅
(secondary)
-2.5% [-2.5%, -2.5%] 1
All ❌✅ (primary) -1.2% [-1.2%, -1.2%] 1

Binary size

Results (primary 0.1%, secondary 0.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.2% [0.0%, 2.3%] 48
Regressions ❌
(secondary)
0.1% [0.0%, 0.2%] 44
Improvements ✅
(primary)
-0.2% [-0.9%, -0.0%] 14
Improvements ✅
(secondary)
-0.2% [-0.2%, -0.2%] 2
All ❌✅ (primary) 0.1% [-0.9%, 2.3%] 62

Bootstrap: 766.525s -> 765.262s (-0.16%)
Artifact size: 362.15 MiB -> 362.08 MiB (-0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 8, 2025
@scottmcm scottmcm force-pushed the inline-more-tiny-things branch from e6789c8 to 154f715 Compare March 9, 2025 01:24
@rust-log-analyzer

This comment has been minimized.

This means that things like `<usize as Step>::forward_unchecked` and `<PartialOrd for f32>::le` will inline even if we've already done a bunch of inlining to find the calls to them.
@scottmcm scottmcm force-pushed the inline-more-tiny-things branch from 154f715 to d30af47 Compare March 9, 2025 03:00
@scottmcm
Copy link
Member Author

scottmcm commented Mar 9, 2025

@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 Mar 9, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 9, 2025
…<try>

Allow more top-down inlining for single-BB callees

This means that things like `<usize as Step>::forward_unchecked` and `<PartialOrd for f32>::le` will inline even if
we've already done a bunch of inlining to find the calls to them.

Fixes rust-lang#138136

~~Draft as it's built atop rust-lang#138135, which adds a mir-opt test that's a nice demonstration of this.  To see just this change, look at <https://github.com/rust-lang/rust/pull/138157/commits/48f63e3be552605c2933056b77bf23a326757f92>~~ Rebased to be just the inlining change, as the other existing tests show it great.
@bors
Copy link
Contributor

bors commented Mar 9, 2025

⌛ Trying commit d30af47 with merge b2a2f87b43bf4e9696e100ff16d21845b3904b79...

@bors
Copy link
Contributor

bors commented Mar 9, 2025

☀️ Try build successful - checks-actions
Build commit: b2a2f87 (b2a2f87b43bf4e9696e100ff16d21845b3904b79)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b2a2f87): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

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 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.4% [0.4%, 0.4%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.6% [-0.9%, -0.3%] 6
Improvements ✅
(secondary)
-0.4% [-0.4%, -0.4%] 1
All ❌✅ (primary) -0.4% [-0.9%, 0.4%] 7

Max RSS (memory usage)

Results (primary -0.0%, secondary 2.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)
3.9% [2.5%, 6.1%] 3
Regressions ❌
(secondary)
2.6% [2.6%, 2.6%] 1
Improvements ✅
(primary)
-3.0% [-4.8%, -2.2%] 4
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.0% [-4.8%, 6.1%] 7

Cycles

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

Binary size

Results (primary -0.0%, 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.2% [0.0%, 2.6%] 34
Regressions ❌
(secondary)
0.1% [0.0%, 0.1%] 40
Improvements ✅
(primary)
-0.2% [-0.9%, -0.0%] 45
Improvements ✅
(secondary)
-1.0% [-2.7%, -0.1%] 17
All ❌✅ (primary) -0.0% [-0.9%, 2.6%] 79

Bootstrap: 765.603s -> 766.315s (0.09%)
Artifact size: 361.95 MiB -> 361.97 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 9, 2025
@scottmcm scottmcm marked this pull request as ready for review March 9, 2025 08:20
@rustbot
Copy link
Collaborator

rustbot commented Mar 9, 2025

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

The Miri subtree was changed

cc @rust-lang/miri

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. 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. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MIR inliner, despite running, doesn't always inline trivial things like i32::le
6 participants