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

[perf experiment] Enable DeduplicateBlocks #106551

Closed
wants to merge 2 commits into from

Conversation

saethlin
Copy link
Member

@saethlin saethlin commented Jan 7, 2023

It looks to me like all this really does is delete duplicated empty unreachable blocks, and the occasional StorageDead + drop block. Perhaps something unexpected turns up in perf.

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 7, 2023
@saethlin
Copy link
Member Author

saethlin commented Jan 7, 2023

@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 7, 2023
@bors
Copy link
Contributor

bors commented Jan 7, 2023

⌛ Trying commit 098af8fbffa06926b3d72b2e136cc2e3c224431f with merge 11d6ba903e6762c93f69ccf2ece4c445cfc575ae...

@bors
Copy link
Contributor

bors commented Jan 7, 2023

☀️ Try build successful - checks-actions
Build commit: 11d6ba903e6762c93f69ccf2ece4c445cfc575ae (11d6ba903e6762c93f69ccf2ece4c445cfc575ae)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (11d6ba903e6762c93f69ccf2ece4c445cfc575ae): 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.9% [0.3%, 2.1%] 7
Regressions ❌
(secondary)
1.4% [0.2%, 2.6%] 11
Improvements ✅
(primary)
-0.6% [-1.0%, -0.3%] 15
Improvements ✅
(secondary)
-0.5% [-0.6%, -0.3%] 4
All ❌✅ (primary) -0.2% [-1.0%, 2.1%] 22

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.7% [1.2%, 4.7%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.7% [-3.0%, -0.0%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.5% [-3.0%, 4.7%] 6

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

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jan 7, 2023
@saethlin
Copy link
Member Author

saethlin commented Jan 7, 2023

Cachegrind diffs look like this:

--------------------------------------------------------------------------------
Ir          
--------------------------------------------------------------------------------
173,178,186  PROGRAM TOTALS

--------------------------------------------------------------------------------
Ir           file:function
--------------------------------------------------------------------------------
176,073,369  ???:<rustc_data_structures::obligation_forest::ObligationForest<rustc_trait_selection::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection::traits::fulfill::FulfillProcessor>

pub fn process_obligations<P>(&mut self, processor: &mut P) -> P::OUT

Which is interesting. I have never seen a case like this where the whole regression is accounted for by a codegen change in one function.

@saethlin
Copy link
Member Author

saethlin commented Jan 8, 2023

Compiling rustc, here is the size of the blocks that get deduplicated:

(  1)     9855 (91.4%, 91.4%): 0
(  2)      597 ( 5.5%, 96.9%): 2
(  3)      260 ( 2.4%, 99.3%): 1
(  4)       55 ( 0.5%, 99.8%): 3
(  5)        7 ( 0.1%, 99.9%): 4
(  6)        1 ( 0.0%, 99.9%): 5

And with DestinationPropagation enabled, this distribution slants much more towards 0.

The limit of this pass was previously set at 10. Things must have been very different back in the day to justify setting it that high. I'm setting the limit down to 3.

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

bors commented Jan 8, 2023

⌛ Trying commit ee29825 with merge 303c0a1f5a0e2a8be2e7b8e1eac1978c0a63f3e5...

@bors
Copy link
Contributor

bors commented Jan 8, 2023

☀️ Try build successful - checks-actions
Build commit: 303c0a1f5a0e2a8be2e7b8e1eac1978c0a63f3e5 (303c0a1f5a0e2a8be2e7b8e1eac1978c0a63f3e5)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (303c0a1f5a0e2a8be2e7b8e1eac1978c0a63f3e5): 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%, 1.1%] 6
Regressions ❌
(secondary)
1.4% [0.1%, 2.5%] 10
Improvements ✅
(primary)
-0.6% [-0.8%, -0.4%] 4
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [-0.8%, 1.1%] 10

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)
1.7% [1.7%, 1.7%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.4% [-4.7%, -0.0%] 2
Improvements ✅
(secondary)
-3.4% [-3.7%, -3.1%] 2
All ❌✅ (primary) -1.0% [-4.7%, 1.7%] 3

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

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 8, 2023
@saethlin
Copy link
Member Author

saethlin commented Jan 8, 2023

Adding a tighter limit to this seems to have removed our improvements but hardly altered the regressions. I would not have expected that. So if I remove the limit entirely, I should see huge regression due to making optimized_mir slow, but what else will show up?

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

bors commented Jan 8, 2023

⌛ Trying commit 3b77094 with merge 8992fea7489ae2ab19a68d91257bc3ea778fcf79...

@rust-timer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jan 8, 2023

☀️ Try build successful - checks-actions
Build commit: 8992fea7489ae2ab19a68d91257bc3ea778fcf79 (8992fea7489ae2ab19a68d91257bc3ea778fcf79)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (8992fea7489ae2ab19a68d91257bc3ea778fcf79): 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.6% [0.2%, 0.9%] 5
Regressions ❌
(secondary)
1.3% [0.4%, 2.6%] 17
Improvements ✅
(primary)
-0.5% [-0.9%, -0.2%] 13
Improvements ✅
(secondary)
-0.5% [-0.7%, -0.3%] 3
All ❌✅ (primary) -0.2% [-0.9%, 0.9%] 18

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.3% [1.8%, 3.0%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.3% [-4.5%, -0.0%] 2
Improvements ✅
(secondary)
-2.9% [-2.9%, -2.9%] 1
All ❌✅ (primary) 0.5% [-4.5%, 3.0%] 5

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.6% [1.6%, 1.6%] 1
Regressions ❌
(secondary)
2.6% [2.2%, 3.1%] 4
Improvements ✅
(primary)
-0.6% [-0.6%, -0.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.5% [-0.6%, 1.6%] 2

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 9, 2023
@cjgillot cjgillot added the A-mir-opt Area: MIR optimizations label Jan 21, 2023
@Noratrieb Noratrieb added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 24, 2023
@Noratrieb
Copy link
Member

Marking as waiting on author because it's still a draft.

@saethlin
Copy link
Member Author

saethlin commented Apr 2, 2023

#106428 enabled deduplicating unreachable blocks. The distribution of block sizes now looks like this (it used to be dominated by 0):

(  1)     5006 (63.2%, 63.2%): 1
(  2)     1469 (18.5%, 81.7%): 0
(  3)     1301 (16.4%, 98.1%): 2
(  4)       62 ( 0.8%, 98.9%): 3
(  5)       54 ( 0.7%, 99.6%): 4
(  6)        9 ( 0.1%, 99.7%): 6
(  7)        6 ( 0.1%, 99.8%): 5
(  8)        3 ( 0.0%, 99.8%): 7
(  9)        2 ( 0.0%, 99.9%): 8
( 10)        1 ( 0.0%, 99.9%): 9

It looks like most of the 0-statement blocks are drop terminators. the 1-statement blocks are split between _0 = + goto and StorageDead + goto.

I suspect that this distribution will be significantly reshaped by jump threading or whatever other passes land, and since this pass isn't deleting enough MIR to produce a benefit, I'm closing this.

@saethlin saethlin closed this Apr 2, 2023
@saethlin saethlin deleted the deduplicate-blocks branch April 2, 2023 19:22
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 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