Skip to content

Don't require allocas for consuming simple enums #138582

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

scottmcm
Copy link
Member

@scottmcm scottmcm commented Mar 16, 2025

Well, 4 months later I'm finally back to this.

For example, if you pass an Option<u32> to a function, don't immediately write it to an alloca then read it again.

@rustbot
Copy link
Collaborator

rustbot commented Mar 16, 2025

r? @saethlin

rustbot has assigned @saethlin.
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. labels Mar 16, 2025
@scottmcm
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 Mar 17, 2025
@bors
Copy link
Collaborator

bors commented Mar 17, 2025

⌛ Trying commit 019c41a with merge a5a9937...

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 17, 2025
Don't require `alloca`s for creating or consuming simple enums

This lets, for example, `Option<u32>` stay a `ScalarPair` the whole time, never needing to get written to stack.
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Mar 17, 2025

☀️ Try build successful - checks-actions
Build commit: a5a9937 (a5a99374d77fd499d01fb91c55bcb4ef8dad712a)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (a5a9937): 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.2%, 1.6%] 187
Regressions ❌
(secondary)
0.6% [0.2%, 6.7%] 129
Improvements ✅
(primary)
-0.5% [-1.0%, -0.3%] 9
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [-1.0%, 1.6%] 196

Max RSS (memory usage)

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

Cycles

Results (primary 1.1%, secondary 2.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)
1.1% [0.8%, 1.5%] 11
Regressions ❌
(secondary)
2.5% [1.1%, 3.5%] 10
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.7% [-2.7%, -2.7%] 1
All ❌✅ (primary) 1.1% [0.8%, 1.5%] 11

Binary size

Results (primary -0.2%, secondary -0.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.0% [0.0%, 0.0%] 20
Improvements ✅
(primary)
-0.2% [-0.6%, -0.0%] 65
Improvements ✅
(secondary)
-0.1% [-0.3%, -0.0%] 22
All ❌✅ (primary) -0.2% [-0.6%, -0.0%] 65

Bootstrap: 775.741s -> 776.411s (0.09%)
Artifact size: 365.10 MiB -> 364.26 MiB (-0.23%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Mar 17, 2025
@scottmcm
Copy link
Member Author

scottmcm commented Mar 17, 2025

Wow, those numbers are horrible :/

(Well, other than the size improvements)

@scottmcm scottmcm changed the title Don't require allocas for creating or consuming simple enums Don't require allocas for consuming simple enums Mar 17, 2025
@rust-log-analyzer

This comment has been minimized.

@scottmcm
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 Mar 17, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 17, 2025
Don't require `alloca`s for consuming simple enums

For example, if you pass an `Option<u32>` to a function, don't immediately write it to an `alloca` then read it again.
@bors
Copy link
Collaborator

bors commented Mar 17, 2025

⌛ Trying commit 3477a13 with merge 132433d...

@bors
Copy link
Collaborator

bors commented Mar 17, 2025

☀️ Try build successful - checks-actions
Build commit: 132433d (132433d7556f612643abac6a48c4b80911f5e9f4)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (132433d): 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.2% [0.1%, 0.5%] 9
Regressions ❌
(secondary)
0.5% [0.2%, 1.4%] 45
Improvements ✅
(primary)
-0.4% [-0.8%, -0.2%] 14
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.3%] 3
All ❌✅ (primary) -0.1% [-0.8%, 0.5%] 23

Max RSS (memory usage)

Results (primary -2.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)
-2.9% [-2.9%, -2.9%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.9% [-2.9%, -2.9%] 1

Cycles

Results (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)
3.5% [2.4%, 5.4%] 9
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

Results (primary -0.1%, secondary 0.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.0% [0.0%, 0.0%] 4
Regressions ❌
(secondary)
0.0% [0.0%, 0.0%] 38
Improvements ✅
(primary)
-0.1% [-0.4%, -0.0%] 54
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.1% [-0.4%, 0.0%] 58

Bootstrap: 774.895s -> 775.425s (0.07%)
Artifact size: 365.10 MiB -> 365.16 MiB (0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 17, 2025
@scottmcm
Copy link
Member Author

Wow, that one's almost entirely green in primary and almost entirely red in secondary O_o

@scottmcm
Copy link
Member Author

scottmcm commented Jul 6, 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 Jul 6, 2025
bors added a commit that referenced this pull request Jul 6, 2025
Don't require `alloca`s for consuming simple enums

Well, 4 months later I'm finally back to this.

Will stay as Draft until #143502 lands, since this builds on that.

For example, if you pass an `Option<u32>` to a function, don't immediately write it to an `alloca` then read it again.
@bors
Copy link
Collaborator

bors commented Jul 6, 2025

⌛ Trying commit ae2daed with merge 81bafbf...

@rust-log-analyzer

This comment has been minimized.

@bors

This comment was marked as resolved.

@scottmcm
Copy link
Member Author

scottmcm commented Jul 6, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

bors added a commit that referenced this pull request Jul 6, 2025
Don't require `alloca`s for consuming simple enums

Well, 4 months later I'm finally back to this.

For example, if you pass an `Option<u32>` to a function, don't immediately write it to an `alloca` then read it again.
@bors
Copy link
Collaborator

bors commented Jul 6, 2025

⌛ Trying commit f452f6d with merge 7ec415a...

@bors
Copy link
Collaborator

bors commented Jul 6, 2025

☀️ Try build successful - checks-actions
Build commit: 7ec415a (7ec415a2dd00f671ff064d2ad88c2a73f6f6a4a5)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (7ec415a): comparison URL.

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

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.4% [0.1%, 0.9%] 172
Regressions ❌
(secondary)
0.5% [0.0%, 6.8%] 177
Improvements ✅
(primary)
-0.5% [-0.8%, -0.4%] 11
Improvements ✅
(secondary)
-0.2% [-0.8%, -0.0%] 9
All ❌✅ (primary) 0.4% [-0.8%, 0.9%] 183

Max RSS (memory usage)

Results (secondary 2.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.3% [1.6%, 5.7%] 9
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.8% [-2.4%, -0.8%] 3
All ❌✅ (primary) - - 0

Cycles

Results (primary 2.8%, secondary 0.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.8% [2.4%, 3.3%] 2
Regressions ❌
(secondary)
4.9% [0.8%, 8.5%] 5
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-6.6% [-11.7%, -1.3%] 3
All ❌✅ (primary) 2.8% [2.4%, 3.3%] 2

Binary size

Results (primary -0.1%, secondary -0.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.3%, -0.0%] 66
Improvements ✅
(secondary)
-0.0% [-0.2%, -0.0%] 28
All ❌✅ (primary) -0.1% [-0.3%, -0.0%] 66

Bootstrap: 461.042s -> 461.941s (0.19%)
Artifact size: 372.12 MiB -> 370.56 MiB (-0.42%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 7, 2025
@scottmcm
Copy link
Member Author

scottmcm commented Jul 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 Jul 7, 2025
@bors
Copy link
Collaborator

bors commented Jul 7, 2025

⌛ Trying commit bc074f1 with merge abd7739...

bors added a commit that referenced this pull request Jul 7, 2025
Don't require `alloca`s for consuming simple enums

Well, 4 months later I'm finally back to this.

For example, if you pass an `Option<u32>` to a function, don't immediately write it to an `alloca` then read it again.
@bors
Copy link
Collaborator

bors commented Jul 7, 2025

☀️ Try build successful - checks-actions
Build commit: abd7739 (abd773984d3b89a23c04f8cf58c43e835b4a970f)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (abd7739): comparison URL.

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

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.4% [0.2%, 0.8%] 170
Regressions ❌
(secondary)
0.5% [0.0%, 6.8%] 180
Improvements ✅
(primary)
-0.4% [-0.6%, -0.2%] 8
Improvements ✅
(secondary)
-0.4% [-1.3%, -0.0%] 14
All ❌✅ (primary) 0.4% [-0.6%, 0.8%] 178

Max RSS (memory usage)

Results (primary 1.7%, secondary 2.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.7% [1.1%, 2.3%] 3
Regressions ❌
(secondary)
3.5% [1.4%, 6.1%] 16
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.7% [-3.8%, -1.7%] 2
All ❌✅ (primary) 1.7% [1.1%, 2.3%] 3

Cycles

Results (secondary 0.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.1% [1.0%, 8.9%] 8
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-6.4% [-11.3%, -1.3%] 4
All ❌✅ (primary) - - 0

Binary size

Results (primary -0.1%, secondary -0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

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

Bootstrap: 463.852s -> 463.523s (-0.07%)
Artifact size: 372.07 MiB -> 370.47 MiB (-0.43%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 7, 2025
@saethlin
Copy link
Member

saethlin commented Jul 7, 2025

Does it make sense that this would regress optimizations? The perfect report looks like we lost some optimizations in rustc.

@scottmcm
Copy link
Member Author

scottmcm commented Jul 7, 2025

No, it doesn't make sense that check builds would regress here. I'll have to dig in more.

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-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

6 participants