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

Stop llvm.expecting assert terminators #124606

Merged
merged 1 commit into from
May 5, 2024
Merged

Conversation

scottmcm
Copy link
Member

@scottmcm scottmcm commented May 2, 2024

We're putting llvm.expect calls before the https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/enum.TerminatorKind.html#variant.Assert terminators.

But we don't need them. One of the arms is always to a panic function that's marked #[cold], which is cold https://llvm.org/docs/LangRef.html#function-attributes in LLVM, which

When computing edge weights, basic blocks post-dominated by a cold function call are also considered to be cold; and, thus, given low weight.

So even without us emitting the extra intrinsic call, LLVM knows what to expect for the br. Thus we can save the (small) effort of emitting it and then LLVM optimizing it out.

r? compiler

@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 May 2, 2024
@scottmcm
Copy link
Member Author

scottmcm commented May 2, 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 May 2, 2024
@bors
Copy link
Contributor

bors commented May 2, 2024

⌛ Trying commit c04b955 with merge b1efbc0...

bors added a commit to rust-lang-ci/rust that referenced this pull request May 2, 2024
Stop `llvm.expect`ing assert terminators

r? ghost
@bors
Copy link
Contributor

bors commented May 2, 2024

☀️ Try build successful - checks-actions
Build commit: b1efbc0 (b1efbc052906efbb73aab7a10cf61b07ec67a80b)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b1efbc0): 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 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
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.1% [-1.1%, -1.1%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

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

Cycles

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

Binary size

Results

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
Improvements ✅
(primary)
-0.0% [-0.1%, -0.0%] 30
Improvements ✅
(secondary)
-0.0% [-0.0%, -0.0%] 3
All ❌✅ (primary) -0.0% [-0.1%, 0.0%] 34

Bootstrap: 671.059s -> 675.174s (0.61%)
Artifact size: 315.99 MiB -> 315.88 MiB (-0.04%)

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

scottmcm commented May 2, 2024

Interesting, dropping the expect gave a "1611442.25x Significance Factor" instruction improvement on the svg-render-1 runtime benchmark. I wish we had a graph to know if that's real...

@scottmcm scottmcm marked this pull request as ready for review May 2, 2024 09:31
@Kobzol
Copy link
Contributor

Kobzol commented May 2, 2024

I wish we had a graph to know if that's real...

Yeah, me too :( Didn't have a lot of time recently to work on the rustc-perf UI, sadly. However, we now have a GSoC 2024 project to improve the rustc-perf frontend, so hopefully this will improve in the future :)

@cjgillot
Copy link
Contributor

cjgillot commented May 3, 2024

@bors r+

@bors
Copy link
Contributor

bors commented May 3, 2024

📌 Commit c04b955 has been approved by cjgillot

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 May 3, 2024
@saethlin
Copy link
Member

saethlin commented May 4, 2024

The binary size improvements here looks interesting, except that the artifact sizes reports a smaller libLLVM.so, which doesn't make much sense to me. Strange...

@Kobzol
Copy link
Contributor

Kobzol commented May 4, 2024

That's just a small fluctuation that happens on pretty much every commit, even no-op ones. Possibly caused by PGO/BOLT.

@scottmcm
Copy link
Member Author

scottmcm commented May 4, 2024

@saethlin Probably PGO in LLVM -- this makes a pretty big difference to how hot the LLVM code is for this, since it used to be called for every arithmetic operation in debug, for example, and now isn't. So it'll definitely churn the LLVM build a bit.

@bors
Copy link
Contributor

bors commented May 5, 2024

⌛ Testing commit c04b955 with merge 02f7806...

@bors
Copy link
Contributor

bors commented May 5, 2024

☀️ Test successful - checks-actions
Approved by: cjgillot
Pushing 02f7806 to master...

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

Finished benchmarking commit (02f7806): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -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
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.2% [-0.2%, -0.2%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

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

Cycles

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

Binary size

Results

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.3%] 4
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.0% [-0.1%, -0.0%] 27
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.0% [-0.1%, 0.3%] 31

Bootstrap: 675.389s -> 676.151s (0.11%)
Artifact size: 315.94 MiB -> 315.84 MiB (-0.03%)

@scottmcm scottmcm deleted the less-expect branch May 6, 2024 07:50
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