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

Perform opportunistic simplifications during value numbering #111344

Closed
wants to merge 2 commits into from

Conversation

cjgillot
Copy link
Contributor

@cjgillot cjgillot commented May 8, 2023

Based on #109597
Based on #119439

Opening mostly for discussion.

@rustbot
Copy link
Collaborator

rustbot commented May 8, 2023

r? @petrochenkov

(rustbot has picked a reviewer for you, use r? to override)

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

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

bors commented May 8, 2023

⌛ Trying commit 7e731ee19e9a11414f711e82aa3f220342a97532 with merge d0c89341fa5520a74ff1a0c782163343027a602d...

@bors
Copy link
Contributor

bors commented May 8, 2023

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

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (d0c89341fa5520a74ff1a0c782163343027a602d): 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.4%, 1.8%] 6
Regressions ❌
(secondary)
3.0% [0.2%, 24.1%] 9
Improvements ✅
(primary)
-0.5% [-1.1%, -0.2%] 75
Improvements ✅
(secondary)
-0.6% [-3.1%, -0.1%] 42
All ❌✅ (primary) -0.4% [-1.1%, 1.8%] 81

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)
5.3% [2.4%, 8.5%] 6
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.2% [-3.9%, -1.1%] 12
Improvements ✅
(secondary)
-2.7% [-4.3%, -1.4%] 5
All ❌✅ (primary) 0.3% [-3.9%, 8.5%] 18

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% [0.7%, 2.0%] 4
Regressions ❌
(secondary)
16.3% [15.5%, 17.1%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.1% [-3.1%, -3.1%] 1
All ❌✅ (primary) 1.4% [0.7%, 2.0%] 4

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.4% [0.0%, 1.5%] 11
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.6% [-5.2%, -0.0%] 99
Improvements ✅
(secondary)
-0.8% [-4.0%, -0.1%] 32
All ❌✅ (primary) -0.5% [-5.2%, 1.5%] 110

Bootstrap: 654.499s -> 657.369s (0.44%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels May 8, 2023
@bugadani
Copy link
Contributor

bugadani commented May 8, 2023

Optimization contributors just have to have a special place in their hearts for keccak.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented May 17, 2023

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

bors added a commit to rust-lang-ci/rust that referenced this pull request May 24, 2023
…illot,tmiasko

Preprocess and cache dominator tree

Preprocessing dominators has a very strong effect for rust-lang#111344.
That pass checks that assignments dominate their uses repeatedly. Using the unprocessed dominator tree caused a quadratic runtime (number of bbs x depth of the dominator tree).

This PR also caches the dominator tree and the pre-processed dominators in the MIR cfg cache.

Rebase of rust-lang#107157
cc `@tmiasko`
saethlin pushed a commit to saethlin/miri that referenced this pull request May 26, 2023
…asko

Preprocess and cache dominator tree

Preprocessing dominators has a very strong effect for rust-lang/rust#111344.
That pass checks that assignments dominate their uses repeatedly. Using the unprocessed dominator tree caused a quadratic runtime (number of bbs x depth of the dominator tree).

This PR also caches the dominator tree and the pre-processed dominators in the MIR cfg cache.

Rebase of rust-lang/rust#107157
cc `@tmiasko`
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jun 14, 2023

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

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jun 19, 2023

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

@bors
Copy link
Contributor

bors commented Dec 30, 2023

⌛ Trying commit 935e283 with merge 01915ea...

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 30, 2023
Perform opportunistic simplifications during value numbering

Based on rust-lang#109597

Opening mostly for discussion. In its current form, I think this pass does too much. I want to remove the const-propagation part to make it simpler.
@bors
Copy link
Contributor

bors commented Dec 30, 2023

☀️ Try build successful - checks-actions
Build commit: 01915ea (01915ea9cc2476cc183f598c9e9092878bedc23c)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (01915ea): 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.5% [0.3%, 0.8%] 7
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.6% [-1.0%, -0.2%] 9
Improvements ✅
(secondary)
-0.8% [-1.2%, -0.4%] 11
All ❌✅ (primary) -0.1% [-1.0%, 0.8%] 16

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)
3.0% [0.7%, 6.8%] 5
Regressions ❌
(secondary)
3.8% [0.5%, 7.2%] 10
Improvements ✅
(primary)
-6.1% [-15.8%, -0.5%] 5
Improvements ✅
(secondary)
-3.0% [-4.7%, -1.6%] 5
All ❌✅ (primary) -1.6% [-15.8%, 6.8%] 10

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.0% [1.0%, 1.0%] 3
Regressions ❌
(secondary)
2.1% [2.0%, 2.1%] 2
Improvements ✅
(primary)
-0.5% [-0.6%, -0.4%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [-0.6%, 1.0%] 6

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.4% [0.0%, 3.7%] 55
Regressions ❌
(secondary)
0.6% [0.0%, 1.3%] 6
Improvements ✅
(primary)
-0.3% [-1.4%, -0.0%] 13
Improvements ✅
(secondary)
-0.7% [-3.9%, -0.2%] 21
All ❌✅ (primary) 0.3% [-1.4%, 3.7%] 68

Bootstrap: 668.324s -> 669.679s (0.20%)
Artifact size: 311.76 MiB -> 311.83 MiB (0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Dec 30, 2023
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Dec 31, 2023
Implement constant propagation on top of MIR SSA analysis

This implements the idea I proposed in rust-lang/rust#110719 (comment)

Based on rust-lang/rust#109597

The value numbering "GVN" pass formulates each rvalue that appears in MIR with an abstract form (the `Value` enum), and assigns an integer `VnIndex` to each. This abstract form can be used to deduplicate values, reusing an earlier local that holds the same value instead of recomputing. This part is proposed in #109597.

From this abstract representation, we can perform more involved simplifications, for example in rust-lang/rust#111344.

With the abstract representation `Value`, we can also attempt to evaluate each to a constant using the interpreter. This builds a `VnIndex -> OpTy` map. From this map, we can opportunistically replace an operand or a rvalue with a constant if their value has an associated `OpTy`.

The most relevant commit is [Evaluated computed values to constants.](rust-lang/rust@2767c49)"

r? `@oli-obk`
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 17, 2024
Fold arithmetic identities in GVN

Extracted from rust-lang#111344

This PR implements a few arithmetic folds for unary and binary operations.
This should take care of the missed optimizations introduced by rust-lang#116012.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 17, 2024
Fold arithmetic identities in GVN

Extracted from rust-lang#111344

This PR implements a few arithmetic folds for unary and binary operations.
This should take care of the missed optimizations introduced by rust-lang#116012.
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jan 18, 2024
Fold arithmetic identities in GVN

Extracted from rust-lang/rust#111344

This PR implements a few arithmetic folds for unary and binary operations.
This should take care of the missed optimizations introduced by rust-lang/rust#116012.
@cjgillot
Copy link
Contributor 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 Jan 20, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 20, 2024
Perform opportunistic simplifications during value numbering

~Based on rust-lang#109597
~Based on rust-lang#119439

Opening mostly for discussion.
@bors
Copy link
Contributor

bors commented Jan 20, 2024

⌛ Trying commit 0167761 with merge 2cd7dda...

@bors
Copy link
Contributor

bors commented Jan 20, 2024

☀️ Try build successful - checks-actions
Build commit: 2cd7dda (2cd7ddaa6c29d00461f1185aaaba85330f616648)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (2cd7dda): 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.7%, 0.7%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.6% [-0.9%, -0.4%] 5
Improvements ✅
(secondary)
-1.0% [-1.3%, -0.7%] 6
All ❌✅ (primary) -0.2% [-0.9%, 0.7%] 7

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)
3.7% [0.2%, 6.1%] 6
Regressions ❌
(secondary)
1.6% [0.8%, 2.2%] 4
Improvements ✅
(primary)
-5.0% [-10.3%, -1.6%] 4
Improvements ✅
(secondary)
-3.6% [-3.6%, -3.6%] 1
All ❌✅ (primary) 0.3% [-10.3%, 6.1%] 10

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

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.9% [0.4%, 3.6%] 12
Regressions ❌
(secondary)
0.8% [0.6%, 1.3%] 6
Improvements ✅
(primary)
-1.8% [-1.8%, -1.8%] 1
Improvements ✅
(secondary)
-1.0% [-2.2%, -0.6%] 4
All ❌✅ (primary) 0.7% [-1.8%, 3.6%] 13

Bootstrap: 663.584s -> 667.018s (0.52%)
Artifact size: 308.31 MiB -> 308.34 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 20, 2024
@Dylan-DPC Dylan-DPC added S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 23, 2024
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-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. 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.

8 participants