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

Only use dense bitsets in dataflow analyses #116152

Merged
merged 2 commits into from Jan 23, 2024
Merged

Conversation

cjgillot
Copy link
Contributor

@cjgillot cjgillot commented Sep 25, 2023

When a dataflow state has the size close to the number of locals, we should prefer a dense bitset, like we already store locals in a dense vector.
Other occurrences of ChunkedBitSet need to be justified by the size of the dataflow state.

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

bors commented Sep 25, 2023

⌛ Trying commit f528b4c with merge b5f969f...

bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 25, 2023
Experiment: only use dense bitsets

r? `@ghost`
@bors
Copy link
Contributor

bors commented Sep 25, 2023

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

1 similar comment
@bors
Copy link
Contributor

bors commented Sep 25, 2023

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

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b5f969f): 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.3% [0.3%, 0.3%] 2
Regressions ❌
(secondary)
0.8% [0.7%, 0.9%] 4
Improvements ✅
(primary)
-0.9% [-1.8%, -0.2%] 55
Improvements ✅
(secondary)
-1.1% [-3.5%, -0.3%] 31
All ❌✅ (primary) -0.9% [-1.8%, 0.3%] 57

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.6% [5.6%, 5.6%] 1
Regressions ❌
(secondary)
5.5% [1.1%, 11.4%] 11
Improvements ✅
(primary)
-3.0% [-3.0%, -3.0%] 1
Improvements ✅
(secondary)
-1.3% [-2.2%, -0.8%] 4
All ❌✅ (primary) 1.3% [-3.0%, 5.6%] 2

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)
-1.3% [-1.9%, -0.6%] 17
Improvements ✅
(secondary)
-2.6% [-3.2%, -2.0%] 7
All ❌✅ (primary) -1.3% [-1.9%, -0.6%] 17

Binary size

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

Bootstrap: 632.116s -> 629.721s (-0.38%)
Artifact size: 317.31 MiB -> 316.90 MiB (-0.13%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Sep 25, 2023
@cjgillot cjgillot changed the title Experiment: only use dense bitsets Only use dense bitsets in dataflow analyses Sep 25, 2023
@cjgillot cjgillot marked this pull request as ready for review September 25, 2023 19:48
@rustbot
Copy link
Collaborator

rustbot commented Sep 25, 2023

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@lqd
Copy link
Member

lqd commented Sep 25, 2023

cc @nnethercote who introduced the chunked bitsets in #93984

@nnethercote
Copy link
Contributor

#93984 (comment) is the best comment about why I introduced these. In short, it was mostly about reducing peak memory usage, and so all metrics should be considered.

Having said that, interestingly the results here don't look like the inverse of #93984. keccak is no longer in the benchmark suite, and it was the most-affected benchmark, but ones like unicode-normalization and match-stress were also affected strongly.

In #93984 I measured a few crates outside of rustc-perf: http-0.2.6, rust-language-tags-0.3.2, tinyvec-1.5.1, vte-0.10.1. It would be worth measuring them too (or updated versions) along with keccak. If the perf results are good, it would be a nice win for simplicity if ChunkedBitSet can be removed.

@cjgillot
Copy link
Contributor Author

Looking closer to the massif and dhat profiles, the analyses using a MovePathIndex are responsible for the memory consumption. This is to be expected, as there are many more move paths than locals.

New version, only changing the liveness analyses, not initializedness.
@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 Sep 27, 2023
@bors
Copy link
Contributor

bors commented Sep 27, 2023

⌛ Trying commit a3e432c with merge dba968f...

bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 27, 2023
Only use dense bitsets in dataflow analyses

r? `@ghost`
@bors
Copy link
Contributor

bors commented Sep 27, 2023

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

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (dba968f): 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
Improvements ✅
(secondary)
-0.4% [-0.4%, -0.4%] 1
All ❌✅ (primary) - - 0

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

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

Binary size

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

Bootstrap: 630.239s -> 631.272s (0.16%)
Artifact size: 317.29 MiB -> 317.41 MiB (0.04%)

@rustbot rustbot removed S-waiting-on-perf Status: Waiting on a perf run to be completed. perf-regression Performance regression. labels Sep 28, 2023
@cjgillot
Copy link
Contributor Author

r? @nnethercote

For the cases that use MovePathIndex, a better solution would be to shrink the state space. For borrowck, I don't know if this is possible, but I suspect that dropping Copy or !Drop types for drop elaboration should be possible. In another PR.

@bors
Copy link
Contributor

bors commented Jan 22, 2024

⌛ Testing commit d67d907 with merge 941b825...

bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 22, 2024
Only use dense bitsets in dataflow analyses

When a dataflow state has the size close to the number of locals, we should prefer a dense bitset, like we already store locals in a dense vector.
Other occurrences of `ChunkedBitSet` need to be justified by the size of the dataflow state.
@bors
Copy link
Contributor

bors commented Jan 22, 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 Jan 22, 2024
@rust-log-analyzer

This comment has been minimized.

@cjgillot
Copy link
Contributor Author

@bors r=nnethercote

@bors
Copy link
Contributor

bors commented Jan 23, 2024

📌 Commit e07ffe9 has been approved by nnethercote

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 23, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 23, 2024
Only use dense bitsets in dataflow analyses

When a dataflow state has the size close to the number of locals, we should prefer a dense bitset, like we already store locals in a dense vector.
Other occurrences of `ChunkedBitSet` need to be justified by the size of the dataflow state.
@bors
Copy link
Contributor

bors commented Jan 23, 2024

⌛ Testing commit e07ffe9 with merge 05d9c16...

@bors
Copy link
Contributor

bors commented Jan 23, 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 23, 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)

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

bors commented Jan 23, 2024

⌛ Testing commit e07ffe9 with merge 0e42435...

@bors
Copy link
Contributor

bors commented Jan 23, 2024

☀️ Test successful - checks-actions
Approved by: nnethercote
Pushing 0e42435 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 23, 2024
@bors bors merged commit 0e42435 into rust-lang:master Jan 23, 2024
12 checks passed
@rustbot rustbot added this to the 1.77.0 milestone Jan 23, 2024
@cjgillot cjgillot deleted the unchunck branch January 23, 2024 14:16
@rust-timer
Copy link
Collaborator

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

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)
4.8% [4.8%, 4.8%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.6% [-2.6%, -2.6%] 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: 663.309s -> 661.891s (-0.21%)
Artifact size: 308.35 MiB -> 308.33 MiB (-0.01%)

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.

None yet

7 participants