Skip to content

Apply size optimizations to panic machinery and some cold functions #129063

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 2 commits into from
Sep 2, 2024

Conversation

the8472
Copy link
Member

@the8472 the8472 commented Aug 13, 2024

  • std dependencies gimli and addr2line are now built with opt-level=s
  • various panic-related methods and #[cold] methods are now marked #[optimize(size)]

Panics should be cold enough that it doesn't make sense to optimize them for speed. The only tradeoff here is if someone does a lot of backtrace captures (without panics) and printing then the opt-level change might impact their perf.

Seems to be the first use of the optimize attribute. Tracking issue #54882

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 13, 2024
@the8472
Copy link
Member Author

the8472 commented Aug 13, 2024

@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 Aug 13, 2024
@bors
Copy link
Collaborator

bors commented Aug 13, 2024

⌛ Trying commit dc2df85 with merge 84b0d6c...

bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 13, 2024
also apply #[optimize(size)] to functions that are marked #[cold]

Let's see if this this has any binary size impact

r? ghost
@bors
Copy link
Collaborator

bors commented Aug 13, 2024

☀️ Try build successful - checks-actions
Build commit: 84b0d6c (84b0d6c40af40b6d73387def8a01fce9ce203d8d)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (84b0d6c): comparison URL.

Overall result: ❌ regressions - 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 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)
1.4% [1.4%, 1.4%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

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

Cycles

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

Binary size

Results (primary -0.0%, 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
Improvements ✅
(primary)
-0.0% [-0.0%, -0.0%] 5
Improvements ✅
(secondary)
-0.0% [-0.0%, -0.0%] 35
All ❌✅ (primary) -0.0% [-0.0%, -0.0%] 5

Bootstrap: 752.976s -> 752.835s (-0.02%)
Artifact size: 341.40 MiB -> 341.44 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 14, 2024
@the8472
Copy link
Member Author

the8472 commented Aug 14, 2024

@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 Aug 14, 2024
@bors
Copy link
Collaborator

bors commented Aug 14, 2024

⌛ Trying commit 79b5cfd with merge 067a1f8...

bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 14, 2024
also apply #[optimize(size)] to functions that are marked #[cold]

Let's see if this this has any binary size impact

r? ghost
@bors
Copy link
Collaborator

bors commented Aug 14, 2024

☀️ Try build successful - checks-actions
Build commit: 067a1f8 (067a1f8343ccb01c00f6f401aea9b47279165e7e)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (067a1f8): 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.7% [0.3%, 0.9%] 5
Regressions ❌
(secondary)
0.7% [0.3%, 1.8%] 9
Improvements ✅
(primary)
-1.2% [-3.2%, -0.3%] 16
Improvements ✅
(secondary)
-1.0% [-1.4%, -0.7%] 2
All ❌✅ (primary) -0.8% [-3.2%, 0.9%] 21

Max RSS (memory usage)

Results (primary 2.4%, secondary 1.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)
5.2% [2.0%, 10.3%] 4
Regressions ❌
(secondary)
2.5% [2.1%, 4.1%] 6
Improvements ✅
(primary)
-3.2% [-5.4%, -1.0%] 2
Improvements ✅
(secondary)
-5.2% [-5.2%, -5.2%] 1
All ❌✅ (primary) 2.4% [-5.4%, 10.3%] 6

Cycles

Results (primary -4.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)
-4.0% [-4.5%, -3.4%] 4
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -4.0% [-4.5%, -3.4%] 4

Binary size

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)
0.1% [0.0%, 0.9%] 25
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.8% [-9.1%, -0.0%] 44
Improvements ✅
(secondary)
-0.4% [-2.0%, -0.1%] 79
All ❌✅ (primary) -1.1% [-9.1%, 0.9%] 69

Bootstrap: 753.65s -> 753.561s (-0.01%)
Artifact size: 341.43 MiB -> 341.47 MiB (0.01%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Aug 14, 2024
@the8472 the8472 changed the title also apply #[optimize(size)] to functions that are marked #[cold] Apply size optimizations to panic machinery and some cold functions Aug 14, 2024
@the8472
Copy link
Member Author

the8472 commented Aug 14, 2024

Odd, I expected opt builds to get smaller (by not bloating stuff in panic code paths).
But debug builds getting faster and smaller is unexpected.

@the8472 the8472 marked this pull request as ready for review August 14, 2024 22:25
@the8472
Copy link
Member Author

the8472 commented Aug 14, 2024

r? libs

@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 Aug 28, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 29, 2024
Apply size optimizations to panic machinery and some cold functions

* std dependencies gimli and addr2line are now built with opt-level=s
* various panic-related methods and `#[cold]` methods are now marked `#[optimize(size)]`

Panics should be cold enough that it doesn't make sense to optimize them for speed. The only tradeoff here is if someone does a lot of backtrace captures (without panics) and printing then the opt-level change might impact their perf.

Seems to be the first use of the optimize attribute. Tracking issue rust-lang#54882
@bors
Copy link
Collaborator

bors commented Aug 29, 2024

⌛ Testing commit 79b5cfd with merge c751b40...

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-msvc-ext failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[RUSTC-TIMING] miri test:false 4.428
error: failed to remove file `C:\a\rust\rust\build\x86_64-pc-windows-msvc\stage1-tools\x86_64-pc-windows-msvc\release\miri.exe`

Caused by:
  Access is denied. (os error 5)
Command has failed. Rerun with -v to see more details.
  local time: Thu, Aug 29, 2024  9:52:18 AM
  network time: Thu, 29 Aug 2024 09:52:18 GMT
##[error]Process completed with exit code 1.
Post job cleanup.

@bors
Copy link
Collaborator

bors commented Aug 29, 2024

💔 Test failed - checks-actions

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

lqd commented Aug 29, 2024

@bors retry

@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 Aug 29, 2024
@cuviper
Copy link
Member

cuviper commented Aug 29, 2024

I think it could be nice to add #[optimize(size)] mod backtrace_rs; too, but that didn't seem to have any effect when I tried it locally just now. In the tracking issue, it sounds like it's still missing propagation for that kind of use.

@bors
Copy link
Collaborator

bors commented Sep 1, 2024

⌛ Testing commit 79b5cfd with merge 6a06eeb...

bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 1, 2024
Apply size optimizations to panic machinery and some cold functions

* std dependencies gimli and addr2line are now built with opt-level=s
* various panic-related methods and `#[cold]` methods are now marked `#[optimize(size)]`

Panics should be cold enough that it doesn't make sense to optimize them for speed. The only tradeoff here is if someone does a lot of backtrace captures (without panics) and printing then the opt-level change might impact their perf.

Seems to be the first use of the optimize attribute. Tracking issue rust-lang#54882
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-msvc-ext failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[RUSTC-TIMING] miri test:false 4.506
error: failed to remove file `C:\a\rust\rust\build\x86_64-pc-windows-msvc\stage1-tools\x86_64-pc-windows-msvc\release\miri.exe`

Caused by:
  Access is denied. (os error 5)
Command has failed. Rerun with -v to see more details.
  local time: Sun, Sep  1, 2024  1:52:11 PM
  network time: Sun, 01 Sep 2024 13:52:11 GMT
##[error]Process completed with exit code 1.
Post job cleanup.

@bors
Copy link
Collaborator

bors commented Sep 1, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 1, 2024
@the8472
Copy link
Member Author

the8472 commented Sep 1, 2024

@bors retry

@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 Sep 1, 2024
@bors
Copy link
Collaborator

bors commented Sep 2, 2024

⌛ Testing commit 79b5cfd with merge e71f952...

@bors
Copy link
Collaborator

bors commented Sep 2, 2024

☀️ Test successful - checks-actions
Approved by: Amanieu
Pushing e71f952 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 2, 2024
@bors bors merged commit e71f952 into rust-lang:master Sep 2, 2024
7 checks passed
@rustbot rustbot added this to the 1.83.0 milestone Sep 2, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e71f952): 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.3% [0.3%, 0.4%] 8
Regressions ❌
(secondary)
0.4% [0.3%, 0.7%] 18
Improvements ✅
(primary)
-1.0% [-3.0%, -0.3%] 19
Improvements ✅
(secondary)
-0.8% [-1.5%, -0.3%] 6
All ❌✅ (primary) -0.6% [-3.0%, 0.4%] 27

Max RSS (memory usage)

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)
1.3% [0.4%, 9.3%] 26
Regressions ❌
(secondary)
0.9% [0.4%, 2.3%] 54
Improvements ✅
(primary)
-1.4% [-13.2%, -0.4%] 26
Improvements ✅
(secondary)
-0.8% [-1.7%, -0.4%] 28
All ❌✅ (primary) -0.0% [-13.2%, 9.3%] 52

Cycles

Results (primary 0.2%, secondary 0.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.9% [0.4%, 4.3%] 45
Regressions ❌
(secondary)
0.9% [0.4%, 2.8%] 70
Improvements ✅
(primary)
-1.8% [-3.9%, -0.5%] 16
Improvements ✅
(secondary)
-0.9% [-2.3%, -0.4%] 46
All ❌✅ (primary) 0.2% [-3.9%, 4.3%] 61

Binary size

Results (primary -2.2%, secondary -0.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.0% [0.0%, 0.2%] 7
Regressions ❌
(secondary)
0.5% [0.5%, 0.5%] 1
Improvements ✅
(primary)
-2.8% [-8.5%, -0.0%] 25
Improvements ✅
(secondary)
-0.5% [-2.0%, -0.1%] 47
All ❌✅ (primary) -2.2% [-8.5%, 0.2%] 32

Bootstrap: missing data
Artifact size: 338.33 MiB -> 338.27 MiB (-0.02%)

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. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

9 participants