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

Make jump threading state sparse #127036

Merged
merged 2 commits into from
Jul 3, 2024
Merged

Make jump threading state sparse #127036

merged 2 commits into from
Jul 3, 2024

Conversation

cjgillot
Copy link
Contributor

Continuation of #127024

Both dataflow const-prop and jump threading involve cloning the state vector a lot. This PR replaces the data structure by a sparse vector, considering:

  • that jump threading state is typically very sparse (at most 1 or 2 set entries);
  • that dataflow const-prop is disabled by default;
  • that place/value map is very eager, and prone to creating an overly large state.

The first commit is shared with the previous PR to avoid needless conflicts.

r? @oli-obk

@rustbot
Copy link
Collaborator

rustbot commented Jun 27, 2024

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@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 Jun 27, 2024
@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 Jun 27, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 27, 2024
Make jump threading state sparse

Continuation of rust-lang#127024

Both dataflow const-prop and jump threading involve cloning the state vector a lot. This PR replaces the data structure by a sparse vector, considering:
- that jump threading state is typically very sparse (at most 1 or 2 set entries);
- that dataflow const-prop is disabled by default;
- that place/value map is very eager, and prone to creating an overly large state.

The first commit is shared with the previous PR to avoid needless conflicts.

r? `@oli-obk`
@bors
Copy link
Contributor

bors commented Jun 27, 2024

⌛ Trying commit 73f860a with merge ca4f312...

@bors
Copy link
Contributor

bors commented Jun 27, 2024

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

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ca4f312): 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.7% [-1.1%, -0.5%] 4
Improvements ✅
(secondary)
-1.9% [-1.9%, -1.9%] 1
All ❌✅ (primary) -0.7% [-1.1%, -0.5%] 4

Max RSS (memory usage)

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

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: 695.971s -> 696.966s (0.14%)
Artifact size: 326.67 MiB -> 326.70 MiB (0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 27, 2024
@oli-obk
Copy link
Contributor

oli-obk commented Jun 28, 2024

@bors r+

@bors
Copy link
Contributor

bors commented Jun 28, 2024

📌 Commit 73f860a 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 Jun 28, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 28, 2024
Only track mentionned places for jump threading

This PR aims to reduce the state space size in jump threading and dataflow const-prop opts.

The current implementation walks the types of all locals, and creates a place for each possible projection. This can easily lead to a large number of places and tracked values, most being useless to the actual pass.

With this PR, we instead collect places that appear syntactically in the MIR (first commit). However, this is not sufficient (second commit), and we miss places that we could track in aggregate assignments. The third commit tracks such assignments to mirror place projections, see the inline comment.

This is complementary to rust-lang#127036

r? `@oli-obk`
@cjgillot cjgillot added the A-mir-opt Area: MIR optimizations label Jun 28, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 1, 2024
Make jump threading state sparse

Continuation of rust-lang#127024

Both dataflow const-prop and jump threading involve cloning the state vector a lot. This PR replaces the data structure by a sparse vector, considering:
- that jump threading state is typically very sparse (at most 1 or 2 set entries);
- that dataflow const-prop is disabled by default;
- that place/value map is very eager, and prone to creating an overly large state.

The first commit is shared with the previous PR to avoid needless conflicts.

r? `@oli-obk`
@bors
Copy link
Contributor

bors commented Jul 1, 2024

⌛ Testing commit 73f860a with merge 6e68440...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jul 1, 2024

💔 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 Jul 1, 2024
@cjgillot
Copy link
Contributor Author

cjgillot commented Jul 1, 2024

Removed a duplicated commit.
@bors r=oli-obk

@bors
Copy link
Contributor

bors commented Jul 1, 2024

📌 Commit 76244d4 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 Jul 1, 2024
@bors
Copy link
Contributor

bors commented Jul 2, 2024

⌛ Testing commit 76244d4 with merge b5f0652...

bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 2, 2024
Make jump threading state sparse

Continuation of rust-lang#127024

Both dataflow const-prop and jump threading involve cloning the state vector a lot. This PR replaces the data structure by a sparse vector, considering:
- that jump threading state is typically very sparse (at most 1 or 2 set entries);
- that dataflow const-prop is disabled by default;
- that place/value map is very eager, and prone to creating an overly large state.

The first commit is shared with the previous PR to avoid needless conflicts.

r? `@oli-obk`
@rust-log-analyzer
Copy link
Collaborator

The job dist-x86_64-msvc-alt failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
 finished in 5.105 seconds
[TIMING] core::build_steps::dist::JsonDocs { host: x86_64-pc-windows-msvc } -- 5.115
[TIMING] core::build_steps::dist::Mingw { host: x86_64-pc-windows-msvc } -- 0.000
thread 'main' panicked at src/lib.rs:1668:17:
failed to copy `C:\a\rust\rust\build\x86_64-pc-windows-msvc\stage2\bin\rustdoc.exe` to `C:\a\rust\rust\build\tmp\tarball\rustc\x86_64-pc-windows-msvc\image\bin\rustdoc.exe`: The process cannot access the file because it is being used by another process. (os error 32)
Build completed unsuccessfully in 0:33:30
  local time: Tue, Jul  2, 2024  1:01:09 AM
  network time: Tue, 02 Jul 2024 01:01:09 GMT
##[error]Process completed with exit code 1.

@bors
Copy link
Contributor

bors commented Jul 2, 2024

💔 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 Jul 2, 2024
@cjgillot
Copy link
Contributor Author

cjgillot commented Jul 2, 2024

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

bors commented Jul 3, 2024

⌛ Testing commit 76244d4 with merge 2b90614...

@bors
Copy link
Contributor

bors commented Jul 3, 2024

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 3, 2024
@bors bors merged commit 2b90614 into rust-lang:master Jul 3, 2024
7 checks passed
@rustbot rustbot added this to the 1.81.0 milestone Jul 3, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (2b90614): 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.8% [-1.1%, -0.5%] 5
Improvements ✅
(secondary)
-0.4% [-0.4%, -0.4%] 1
All ❌✅ (primary) -0.8% [-1.1%, -0.5%] 5

Max RSS (memory usage)

Results (secondary -0.2%)

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

Cycles

Results (secondary -9.0%)

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.5% [0.5%, 0.5%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-10.5% [-10.7%, -10.4%] 6
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 742.585s -> 742.115s (-0.06%)
Artifact size: 327.63 MiB -> 327.64 MiB (0.00%)

@cjgillot cjgillot deleted the sparse-state branch July 4, 2024 05:33
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 4, 2024
Only track mentioned places for jump threading

This PR aims to reduce the state space size in jump threading and dataflow const-prop opts.

The current implementation walks the types of all locals, and creates a place for each possible projection. This can easily lead to a large number of places and tracked values, most being useless to the actual pass.

With this PR, we instead collect places that appear syntactically in the MIR (first commit). However, this is not sufficient (second commit), and we miss places that we could track in aggregate assignments. The third commit tracks such assignments to mirror place projections, see the inline comment.

This is complementary to rust-lang#127036

r? `@oli-obk`
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 14, 2024
Only track mentioned places for jump threading

This PR aims to reduce the state space size in jump threading and dataflow const-prop opts.

The current implementation walks the types of all locals, and creates a place for each possible projection. This can easily lead to a large number of places and tracked values, most being useless to the actual pass.

With this PR, we instead collect places that appear syntactically in the MIR (first commit). However, this is not sufficient (second commit), and we miss places that we could track in aggregate assignments. The third commit tracks such assignments to mirror place projections, see the inline comment.

This is complementary to rust-lang#127036

r? `@oli-obk`
lnicola pushed a commit to lnicola/rust-analyzer that referenced this pull request Jul 16, 2024
Only track mentioned places for jump threading

This PR aims to reduce the state space size in jump threading and dataflow const-prop opts.

The current implementation walks the types of all locals, and creates a place for each possible projection. This can easily lead to a large number of places and tracked values, most being useless to the actual pass.

With this PR, we instead collect places that appear syntactically in the MIR (first commit). However, this is not sufficient (second commit), and we miss places that we could track in aggregate assignments. The third commit tracks such assignments to mirror place projections, see the inline comment.

This is complementary to rust-lang/rust#127036

r? `@oli-obk`
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. 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.

6 participants