Skip to content

Avoid the would-change check for bitset chunks that are unique#153680

Closed
Zalathar wants to merge 1 commit intorust-lang:mainfrom
Zalathar:chunk-mut
Closed

Avoid the would-change check for bitset chunks that are unique#153680
Zalathar wants to merge 1 commit intorust-lang:mainfrom
Zalathar:chunk-mut

Conversation

@Zalathar
Copy link
Copy Markdown
Member

@Zalathar Zalathar commented Mar 10, 2026

ChunkedBitSet goes out of its way to check whether a union/subtract/intersect operation would actually modify any bits, to avoid calling Rc::make_mut if possible.

But in the case where the Rc is already unique (i.e. Rc::get_mut succeeds), it's cheaper to skip the would-change check entirely.


@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 Mar 10, 2026
@Zalathar
Copy link
Copy Markdown
Member Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Mar 10, 2026
[EXPERIMENT] Avoid the would-change check for bitset chunks that are unique
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 10, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Mar 11, 2026

☀️ Try build successful (CI)
Build commit: d38d65d (d38d65d55029fcaeb492c32d33ea24894520d7de, parent: 0c68443b0a0469e4211acca7e7b06e14f256ada8)

@rust-timer

This comment has been minimized.

@rust-timer

This comment was marked as outdated.

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 11, 2026
@Zalathar Zalathar force-pushed the chunk-mut branch 3 times, most recently from 9897ed8 to 8b13e1a Compare March 11, 2026 04:17
@Zalathar Zalathar changed the title [EXPERIMENT] Avoid the would-change check for bitset chunks that are unique Avoid the would-change check for bitset chunks that are unique Mar 11, 2026
@Zalathar
Copy link
Copy Markdown
Member Author

Zalathar commented Mar 11, 2026

Whoops, it turns out that my previous benchmark run had a bug that would cause it to simply not perform certain ChunkedBitSet bulk updates at all, which is blatantly incorrect. 😅

This implies that I should probably also add some relevant unit tests.

@Zalathar
Copy link
Copy Markdown
Member Author

Let's try again with a version that actually performs real work.

@bors try @rust-timer queue

@rust-timer
Copy link
Copy Markdown
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Mar 11, 2026

⌛ Trying commit 20b8c98 with merge cffefe3

To cancel the try build, run the command @bors try cancel.

Workflow: https://github.com/rust-lang/rust/actions/runs/22937404624

rust-bors Bot pushed a commit that referenced this pull request Mar 11, 2026
Avoid the would-change check for bitset chunks that are unique
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 11, 2026
@Zalathar
Copy link
Copy Markdown
Member Author

Now there’s some kind of bug that causes the modified compiler to hang while building proc_macro.

@bors try cancel

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Mar 11, 2026

@Zalathar
Copy link
Copy Markdown
Member Author

Closing this for now, as it needs better testing/debugging.

@Zalathar Zalathar closed this Mar 11, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Mar 11, 2026
@Zalathar Zalathar deleted the chunk-mut branch March 11, 2026 09:34
@Zalathar
Copy link
Copy Markdown
Member Author

Zalathar commented Mar 11, 2026

Ah, I think the bug might have been in unconditionally returning changed = true from the new fast path, when in fact it can sometimes result in no modification.

This would then break code that relies on the return value when iterating to fixpoint, because it would incorrectly believe that fixpoint is never reached, and loop forever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-perf Status: Waiting on a perf run to be completed. 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.

3 participants