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

Sandwich MIR optimizations between DSE. #119672

Merged
merged 3 commits into from Jan 16, 2024
Merged

Conversation

cjgillot
Copy link
Contributor

@cjgillot cjgillot commented Jan 6, 2024

This PR reorders MIR optimization passes in an attempt to increase their efficiency.

  • Stop running CopyProp before GVN, it's useless as GVN will do the same thing anyway. Instead, we perform CopyProp at the end of the pipeline, to ensure we do not emit copy/move chains.
  • Run DSE before GVN, as it increases the probability to have single-assignment locals.
  • Run DSE after the final CopyProp to turn copies into moves.

r? @ghost

@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 Jan 6, 2024
@cjgillot
Copy link
Contributor Author

cjgillot commented Jan 6, 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 Jan 6, 2024
@bors
Copy link
Contributor

bors commented Jan 6, 2024

⌛ Trying commit bee69ed with merge da2b34d...

bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 6, 2024
Sandwich MIR optimizations between DSE.

This PR reorders MIR optimization passes in an attempt to increase their efficiency.

- Stop running CopyProp before GVN, it's useless as GVN will do the same thing anyway. Instead, we perform CopyProp at the end of the pipeline, to ensure we do not emit copy/move chains.
- Run DSE before GVN, as it increases the probability to have single-assignment locals.
- Run DSE after the final CopyProp to turn copies into moves.

r? `@ghost`
@cjgillot cjgillot added the A-mir-opt Area: MIR optimizations label Jan 6, 2024
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jan 6, 2024

☀️ Try build successful - checks-actions
Build commit: da2b34d (da2b34d645102a105976e2818671f2be9fc7cf06)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (da2b34d): 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.8% [0.2%, 4.7%] 19
Regressions ❌
(secondary)
0.4% [0.2%, 0.8%] 12
Improvements ✅
(primary)
-1.0% [-2.2%, -0.2%] 28
Improvements ✅
(secondary)
-0.8% [-1.9%, -0.2%] 13
All ❌✅ (primary) -0.2% [-2.2%, 4.7%] 47

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)
4.8% [1.9%, 14.4%] 5
Regressions ❌
(secondary)
3.8% [1.7%, 9.5%] 4
Improvements ✅
(primary)
-1.6% [-2.4%, -0.1%] 4
Improvements ✅
(secondary)
-5.1% [-7.8%, -3.7%] 3
All ❌✅ (primary) 2.0% [-2.4%, 14.4%] 9

Cycles

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)
2.8% [1.1%, 4.5%] 2
Regressions ❌
(secondary)
3.0% [2.2%, 3.9%] 2
Improvements ✅
(primary)
-1.9% [-2.4%, -1.4%] 8
Improvements ✅
(secondary)
-2.2% [-2.3%, -2.0%] 3
All ❌✅ (primary) -1.0% [-2.4%, 4.5%] 10

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.7% [0.0%, 2.2%] 14
Regressions ❌
(secondary)
0.0% [0.0%, 0.0%] 1
Improvements ✅
(primary)
-0.3% [-1.0%, -0.0%] 69
Improvements ✅
(secondary)
-0.5% [-1.1%, -0.2%] 21
All ❌✅ (primary) -0.1% [-1.0%, 2.2%] 83

Bootstrap: 668.367s -> 667.451s (-0.14%)
Artifact size: 308.49 MiB -> 308.66 MiB (0.05%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jan 6, 2024
@bors
Copy link
Contributor

bors commented Jan 9, 2024

☔ The latest upstream changes (presumably #119767) made this pull request unmergeable. Please resolve the merge conflicts.

@bors
Copy link
Contributor

bors commented Jan 11, 2024

☔ The latest upstream changes (presumably #119677) made this pull request unmergeable. Please resolve the merge conflicts.

@cjgillot
Copy link
Contributor Author

Now that #119677 is merged.
@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 Jan 12, 2024
@bors
Copy link
Contributor

bors commented Jan 12, 2024

⌛ Trying commit bc35ee4 with merge cc8825e...

bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 12, 2024
Sandwich MIR optimizations between DSE.

This PR reorders MIR optimization passes in an attempt to increase their efficiency.

- Stop running CopyProp before GVN, it's useless as GVN will do the same thing anyway. Instead, we perform CopyProp at the end of the pipeline, to ensure we do not emit copy/move chains.
- Run DSE before GVN, as it increases the probability to have single-assignment locals.
- Run DSE after the final CopyProp to turn copies into moves.

r? `@ghost`
@bors
Copy link
Contributor

bors commented Jan 12, 2024

☀️ Try build successful - checks-actions
Build commit: cc8825e (cc8825e3c98ad94907c9ea8483edd15220baa7e3)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (cc8825e): 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.1%, 1.2%] 12
Regressions ❌
(secondary)
0.5% [0.2%, 1.8%] 10
Improvements ✅
(primary)
-1.1% [-2.1%, -0.2%] 27
Improvements ✅
(secondary)
-1.0% [-2.2%, -0.2%] 9
All ❌✅ (primary) -0.5% [-2.1%, 1.2%] 39

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)
2.4% [0.9%, 3.6%] 6
Regressions ❌
(secondary)
2.6% [2.1%, 3.1%] 2
Improvements ✅
(primary)
-4.0% [-18.0%, -0.4%] 9
Improvements ✅
(secondary)
-8.4% [-8.4%, -8.4%] 1
All ❌✅ (primary) -1.4% [-18.0%, 3.6%] 15

Cycles

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)
1.9% [1.9%, 1.9%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.6% [-2.6%, -0.5%] 9
Improvements ✅
(secondary)
-1.9% [-3.3%, -0.9%] 5
All ❌✅ (primary) -1.2% [-2.6%, 1.9%] 10

Binary size

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

Bootstrap: 666.309s -> 663.818s (-0.37%)
Artifact size: 308.10 MiB -> 308.22 MiB (0.04%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 13, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jan 13, 2024

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@cjgillot
Copy link
Contributor Author

Perf results: we get some nice speedups, near 2% for cargo, clap & ripgrep, which confirm the earlier perf run. On average, small improvements and small regressions balance out.
I propose to go ahead and merge this.
r? wg-mir-opt

@oli-obk
Copy link
Contributor

oli-obk commented Jan 15, 2024

@bors r+

@bors
Copy link
Contributor

bors commented Jan 15, 2024

📌 Commit bc35ee4 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 Jan 15, 2024
@bors
Copy link
Contributor

bors commented Jan 16, 2024

⌛ Testing commit bc35ee4 with merge 00b705e...

bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 16, 2024
Sandwich MIR optimizations between DSE.

This PR reorders MIR optimization passes in an attempt to increase their efficiency.

- Stop running CopyProp before GVN, it's useless as GVN will do the same thing anyway. Instead, we perform CopyProp at the end of the pipeline, to ensure we do not emit copy/move chains.
- Run DSE before GVN, as it increases the probability to have single-assignment locals.
- Run DSE after the final CopyProp to turn copies into moves.

r? `@ghost`
@bors
Copy link
Contributor

bors commented Jan 16, 2024

💥 Test timed out

@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 Jan 16, 2024
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@oli-obk
Copy link
Contributor

oli-obk commented Jan 16, 2024

@bors retry apple builder timeout

@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 Jan 16, 2024
@bors
Copy link
Contributor

bors commented Jan 16, 2024

⌛ Testing commit bc35ee4 with merge fa0dc20...

@bors
Copy link
Contributor

bors commented Jan 16, 2024

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 16, 2024
@bors bors merged commit fa0dc20 into rust-lang:master Jan 16, 2024
12 checks passed
@rustbot rustbot added this to the 1.77.0 milestone Jan 16, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (fa0dc20): 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.7% [0.2%, 1.4%] 14
Regressions ❌
(secondary)
0.5% [0.2%, 2.7%] 14
Improvements ✅
(primary)
-1.0% [-2.2%, -0.2%] 31
Improvements ✅
(secondary)
-0.9% [-2.2%, -0.2%] 10
All ❌✅ (primary) -0.4% [-2.2%, 1.4%] 45

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)
2.4% [2.4%, 2.4%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-4.0% [-7.9%, -0.7%] 6
Improvements ✅
(secondary)
-5.2% [-8.2%, -3.1%] 3
All ❌✅ (primary) -3.1% [-7.9%, 2.4%] 7

Cycles

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)
1.4% [1.4%, 1.4%] 2
Regressions ❌
(secondary)
2.0% [1.8%, 2.3%] 4
Improvements ✅
(primary)
-1.8% [-2.7%, -1.1%] 11
Improvements ✅
(secondary)
-2.5% [-3.1%, -2.0%] 3
All ❌✅ (primary) -1.3% [-2.7%, 1.4%] 13

Binary size

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

Bootstrap: 666.062s -> 664.881s (-0.18%)
Artifact size: 308.24 MiB -> 308.33 MiB (0.03%)

@lqd
Copy link
Member

lqd commented Jan 16, 2024

As seen in the previous runs: some nice wins on bigger benchmarks, and overall gains outweigh the few losses.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Jan 16, 2024
@cjgillot cjgillot deleted the dse-sandwich branch January 16, 2024 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir-opt Area: MIR optimizations merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. 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.

None yet

8 participants