Skip to content

[experiment, do not merge!] rewrite the DenseBitSet structure to only use 1 word on the stack #141325

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

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

tage64
Copy link

@tage64 tage64 commented May 21, 2025

Modify DenseBitSet in the rustc_index crate so that it only uses one word on the stack instead of 4 words as before, allowing for faster clones. The downside is that it may at most store 63 elements on the stack as aposed to 128 for the previous implementation.

r? lqd

This is experimental so far and I mostly want a perf run to measure
the performance.

This commit modifies DenseBitSet so that it only uses one word on the
stack instead of 4 words as before, allowing for faster clones. The
downside is that it may at most store 63 elements on the stack as aposed
to 128 for the previous implementation.
@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 21, 2025
@rustbot
Copy link
Collaborator

rustbot commented May 21, 2025

Some changes occurred in coverage instrumentation.

cc @Zalathar

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@lqd lqd marked this pull request as draft May 21, 2025 08:26
@lqd
Copy link
Member

lqd commented May 21, 2025

(sorry for the unintended pings, everyone)

cc @nnethercote this is the bitset work I was telling you about. It did look interesting in my tests, ~= 0.5% wins on a lot of primary benchmarks.

let's see if a try build works:

@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 21, 2025
@rust-log-analyzer

This comment has been minimized.

bors added a commit to rust-lang-ci/rust that referenced this pull request May 21, 2025
[experiment, do not merge!] rewrite the DenseBitSet structure to only use 1 word on the stack

Modify DenseBitSet in the rustc_index crate so that it only uses one word on the stack instead of 4 words as before, allowing for faster clones. The downside is that it may at most store 63 elements on the stack as aposed to 128 for the previous implementation.

r? lqd

This is experimental so far and I mostly want a perf run to measure
the performance.
@bors
Copy link
Collaborator

bors commented May 21, 2025

⌛ Trying commit 3ff2c88 with merge 693ccca...

@rust-timer

This comment has been minimized.

@nnethercote
Copy link
Contributor

Looks interesting. Unfortunately being a single commit makes it incredibly hard to review, especially with so much code being moved into dense_bit_set.rs. If it gets beyond the draft stage I think the commits need to be structured differently to make review easier. E.g. the code doesn't need to move into dense_bit_set.rs, or if that's really desired, it should be moved in a first commit and then modified in a second commit. And any other changes are made that are independent (e.g. changing MixedBitSet::Small to Self::Small) can be done in separate commits as well.

@lqd
Copy link
Member

lqd commented May 21, 2025

Yeah this is just for the perf run I think. The branch I was looking at (now unfortunately gone) had many smaller commits that were easier to review, eg the last 20 of master...tage64:rust:replace_predecessors

@tage64
Copy link
Author

tage64 commented May 21, 2025

I squashed all commits into one to make rebasing on upstream easier. Maybe that was not necessary but as you said, this is just for experiments. The original commit history is still there in tage64/rust@thin_bit_set_old.

@bors
Copy link
Collaborator

bors commented May 21, 2025

☀️ Try build successful - checks-actions
Build commit: 693ccca (693cccaceb81d959dbf823da027464c8655b8b57)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (693ccca): 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 the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.2% [0.2%, 0.2%] 1
Improvements ✅
(primary)
-0.5% [-1.1%, -0.1%] 83
Improvements ✅
(secondary)
-1.0% [-3.3%, -0.1%] 50
All ❌✅ (primary) -0.5% [-1.1%, -0.1%] 83

Max RSS (memory usage)

Results (primary -1.1%, secondary -1.3%)

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.8% [0.8%, 0.9%] 2
Improvements ✅
(primary)
-1.1% [-1.1%, -1.1%] 1
Improvements ✅
(secondary)
-2.4% [-5.2%, -0.4%] 4
All ❌✅ (primary) -1.1% [-1.1%, -1.1%] 1

Cycles

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)
1.8% [1.5%, 2.1%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.2% [-2.0%, -0.7%] 6
All ❌✅ (primary) - - 0

Binary size

Results (primary 0.0%, secondary 0.1%)

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.0% [0.0%, 0.1%] 48
Regressions ❌
(secondary)
0.1% [0.0%, 0.1%] 25
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [0.0%, 0.1%] 48

Bootstrap: 775.275s -> 774.785s (-0.06%)
Artifact size: 365.51 MiB -> 365.51 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 21, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

sizes are different

The new implementation of DenseBitSet doesn't store the exact domain
size, so of course the hash values for identical sets with different
domain sizes may be equal.
@rust-log-analyzer

This comment has been minimized.

… dependency to be required instead of optional
@rust-log-analyzer

This comment has been minimized.

…erialize dependency to be required instead of optional", and introduce conditional compilation instead.
bors added a commit that referenced this pull request May 26, 2025
[experimental, do not merge!] a faster implementation of Polonius and a more compact DenseBitSet implementation

This is the union of #141326 and #141325, a Polonius experiment combined with a more compact version of `DenseBitSet`. I would like to get a perf-run of this `@lqd.`

r? lqd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants