Skip to content

Optimize dataflow-const-prop place-tracking infra#110820

Merged
bors merged 8 commits into
rust-lang:masterfrom
cjgillot:faster-dcp
May 11, 2023
Merged

Optimize dataflow-const-prop place-tracking infra#110820
bors merged 8 commits into
rust-lang:masterfrom
cjgillot:faster-dcp

Conversation

@cjgillot

Copy link
Copy Markdown
Contributor

Optimization opportunities found while investigating #110719

Computing places breadth-first ensures that we create short projections before deep projections, since the former are more likely to be propagated.

The most relevant is the pre-computation of flooded places. Callgrind showed flood_* methods and especially preorder_preinvoke were especially hot. This PR attempts to pre-compute the set of ValueIndex that preorder_invoke would visit.

Using this information, we make some PlaceIndex inaccessible when they contain no ValueIndex, allowing to skip computations for those places.

cc @jachris as original author

@rustbot

rustbot commented Apr 25, 2023

Copy link
Copy Markdown
Collaborator

r? @TaKO8Ki

(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 Apr 25, 2023
@rustbot

rustbot commented Apr 25, 2023

Copy link
Copy Markdown
Collaborator

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@oli-obk

oli-obk commented May 3, 2023

Copy link
Copy Markdown
Contributor

@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 3, 2023
@bors

bors commented May 3, 2023

Copy link
Copy Markdown
Collaborator

⌛ Trying commit 3cfa1b1fa6c493ebbf8b4282eb92a161eb8563c7 with merge 8fffd5b5f897bb58af07618610dd7b1cef63d4e2...

@bors

bors commented May 3, 2023

Copy link
Copy Markdown
Collaborator

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

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (8fffd5b5f897bb58af07618610dd7b1cef63d4e2): comparison URL.

Overall result: no relevant changes - 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 benchmark run did not return any relevant results for this metric.

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

Cycles

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

Binary size

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

Bootstrap: 654.411s -> 654.14s (-0.04%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 3, 2023
@cjgillot

cjgillot commented May 5, 2023

Copy link
Copy Markdown
Contributor Author

The perf results are expected: those code paths are not enabled by default.

@oli-obk oli-obk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me with question answered as a comment or addressed otherwise

Comment thread compiler/rustc_mir_dataflow/src/value_analysis.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how deep can this recursion get? We can have some very long projections from user code. A recursion limit could either cause a miscompilation or a hard error where there shouldn't be one, so maybe use ensure_sufficient_stack?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This recursion is required for correctness, so I added the ensure_sufficient_stack.
I don't think this is much of an issue in practice: we have a limit on the number of created values in register_with_filter.

@oli-obk

oli-obk commented May 8, 2023

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented May 8, 2023

Copy link
Copy Markdown
Collaborator

📌 Commit e858997ad21c730972d6f3f254ad6821f64f50f6 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 May 8, 2023
@bors

bors commented May 8, 2023

Copy link
Copy Markdown
Collaborator

⌛ Testing commit e858997ad21c730972d6f3f254ad6821f64f50f6 with merge 390e41af383ca43944ee332c68e3f3cb1e84b122...

@rust-log-analyzer

This comment has been minimized.

@bors

bors commented May 8, 2023

Copy link
Copy Markdown
Collaborator

💔 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 May 8, 2023
@cjgillot

cjgillot commented May 9, 2023

Copy link
Copy Markdown
Contributor Author

@bors r=oli-obk

@bors

bors commented May 9, 2023

Copy link
Copy Markdown
Collaborator

📌 Commit ccc1da2 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 May 9, 2023
@bors

bors commented May 10, 2023

Copy link
Copy Markdown
Collaborator

⌛ Testing commit ccc1da2 with merge b73d98147a1d4b1f392b6e38c052d8151e1a2dfa...

@bors

bors commented May 10, 2023

Copy link
Copy Markdown
Collaborator

💔 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 May 10, 2023
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

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

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

@cjgillot

Copy link
Copy Markdown
Contributor Author

@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 May 10, 2023
@Noratrieb

Copy link
Copy Markdown
Member

@bors p=50
PR CI seems to be normal recently, let's see whether it passes here

@bors

bors commented May 10, 2023

Copy link
Copy Markdown
Collaborator

⌛ Testing commit ccc1da2 with merge 9a767b6...

@bors

bors commented May 11, 2023

Copy link
Copy Markdown
Collaborator

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 11, 2023
@bors bors merged commit 9a767b6 into rust-lang:master May 11, 2023
@rustbot rustbot added this to the 1.71.0 milestone May 11, 2023
@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (9a767b6): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

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

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

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)
-2.7% [-3.2%, -2.3%] 3
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 658.519s -> 659.961s (0.22%)

@cjgillot cjgillot deleted the faster-dcp branch May 11, 2023 06:03
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.

8 participants