Skip to content

Remove chunk size from each chunk in ChunkedBitSet. #145480

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cjgillot
Copy link
Contributor

Almost all chunks in a ChunkedBitSet have the same constant CHUNK_SIZE, except the last in a bitset which takes the remainder domain_size % CHUNK_SIZE.

r? @ghost for perf

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 16, 2025
@cjgillot
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Aug 16, 2025
Remove chunk size from each chunk in `ChunkedBitSet`.
@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 16, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Aug 16, 2025

☀️ Try build successful (CI)
Build commit: acb05a6 (acb05a6e3a3ea9007fbe164aa0c5e056e7463ba6, parent: cd7cbe818e4a66d46fe2df993d1b8518eba8a5cd)

@rust-timer

This comment has been minimized.

@lqd
Copy link
Member

lqd commented Aug 16, 2025

We have an open PR on dense bitsets that removes the domain size as well (and one passes it in in the few cases where it’s needed; it’s usually easy to know where the bitsets are constructed and used) with good effects IIRC, it’s also something we could try on chunked bitsets.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (acb05a6): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
1.8% [0.3%, 3.3%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.4% [-0.4%, -0.4%] 1
Improvements ✅
(secondary)
-0.5% [-1.1%, -0.2%] 4
All ❌✅ (primary) 1.1% [-0.4%, 3.3%] 3

Max RSS (memory usage)

Results (primary -0.8%, secondary -3.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.8% [-0.8%, -0.8%] 1
Improvements ✅
(secondary)
-3.5% [-3.5%, -3.5%] 1
All ❌✅ (primary) -0.8% [-0.8%, -0.8%] 1

Cycles

Results (primary 2.8%, secondary 4.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.8% [2.8%, 2.8%] 1
Regressions ❌
(secondary)
4.2% [4.2%, 4.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.8% [2.8%, 2.8%] 1

Binary size

Results (primary 0.7%, secondary -1.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.7% [0.7%, 0.7%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.7% [-1.7%, -1.7%] 1
All ❌✅ (primary) 0.7% [0.7%, 0.7%] 1

Bootstrap: 469.562s -> 468.956s (-0.13%)
Artifact size: 377.55 MiB -> 377.45 MiB (-0.02%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Aug 16, 2025
@cjgillot cjgillot marked this pull request as ready for review August 16, 2025 14:08
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 16, 2025
@cjgillot
Copy link
Contributor Author

@lqd do you have a link to the PR for dense bitsets?

@rust-log-analyzer

This comment has been minimized.

@lqd
Copy link
Member

lqd commented Aug 16, 2025

Yes, it’s #141325 — it reduces the bitset size in general, but AFAICT is not yet in an easily reviewable state per se. The author @tage64 has told me they want to wrap that work up though.

@cjgillot
Copy link
Contributor Author

r? compiler

Copy link
Member

@Mark-Simulacrum Mark-Simulacrum left a comment

Choose a reason for hiding this comment

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

r=me with nits fixed (mostly the documentation, open either way on the last_chunk_size comment)

r? @Mark-Simulacrum

View changes since this review

for (chunk_index, (mut self_chunk, other_chunk)) in
self.chunks.iter_mut().zip(other.chunks.iter()).enumerate()
{
let chunk_domain_size = if chunk_index + 1 == num_chunks {
Copy link
Member

Choose a reason for hiding this comment

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

Should this use self.chunk_domain_size(chunk_index)? I guess that maybe doesn't cache the more complex computation (modulus, etc.) but that should only happen once per iteration, so maybe that's better (less register pressure etc)?

Copy link
Contributor Author

@cjgillot cjgillot Aug 24, 2025

Choose a reason for hiding this comment

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

We are mutably borrowing self.chunks, so borrowck won't let us. And re-implementing is simple enough.

@rustbot rustbot assigned Mark-Simulacrum and unassigned jieyouxu Aug 24, 2025
@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 24, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 24, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@cjgillot
Copy link
Contributor Author

@bors r=Mark-Simulacrum

@bors
Copy link
Collaborator

bors commented Aug 25, 2025

📌 Commit 9c9a89a has been approved by Mark-Simulacrum

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. 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