Skip to content

[EXPERIMENT] RawBitSet experiments - #153589

Draft
Zalathar wants to merge 2 commits into
rust-lang:mainfrom
Zalathar:bit-set
Draft

[EXPERIMENT] RawBitSet experiments#153589
Zalathar wants to merge 2 commits into
rust-lang:mainfrom
Zalathar:bit-set

Conversation

@Zalathar

@Zalathar Zalathar commented Mar 9, 2026

Copy link
Copy Markdown
Member

View all comments

(Doing some perf runs to see if I'm on the right track with this RawBitSet stuff.)

@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 9, 2026
@Zalathar

Zalathar commented Mar 9, 2026

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 9, 2026
[EXPERIMENT] RawBitSet experiments
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 9, 2026
@rust-bors

rust-bors Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 524f8f3 (524f8f327bef00d806aadab2c3f1cf6d424c6f5a, parent: b41f22de2a13a0babd28771e96feef4c309f54aa)

@rust-timer

This comment has been minimized.

@lqd

lqd commented Mar 9, 2026

Copy link
Copy Markdown
Member

If you’re working on bitsets, it could be cool to take a look at #141325 and bring that to completion. It was a nice win and the author doesn’t have the time to rebase, and finish it.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (524f8f3): 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)
0.1% [0.1%, 0.1%] 2
Regressions ❌
(secondary)
0.6% [0.0%, 1.1%] 11
Improvements ✅
(primary)
-0.3% [-0.3%, -0.3%] 2
Improvements ✅
(secondary)
-0.2% [-0.4%, -0.1%] 18
All ❌✅ (primary) -0.1% [-0.3%, 0.1%] 4

Max RSS (memory usage)

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

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)
-5.7% [-10.3%, -1.1%] 2
Improvements ✅
(secondary)
-1.1% [-1.1%, -1.1%] 1
All ❌✅ (primary) -5.7% [-10.3%, -1.1%] 2

Cycles

Results (secondary 3.2%)

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

Binary size

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

Bootstrap: 478.517s -> 499.35s (4.35%)
Artifact size: 395.02 MiB -> 395.00 MiB (-0.00%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Mar 9, 2026
@Zalathar

Zalathar commented Mar 9, 2026

Copy link
Copy Markdown
Member Author

If you’re working on bitsets, it could be cool to take a look at #141325 and bring that to completion. It was a nice win and the author doesn’t have the time to rebase, and finish it.

One of my ambitions is to eventually allow a large subset of bitsets to allocate their word storage in a dropless arena (either a local arena or the one in TyCtxt), which could potentially cut down on a lot of allocation bookkeeping.

@Zalathar

Zalathar commented Mar 9, 2026

Copy link
Copy Markdown
Member Author

Let's make sure a simpler RawBitSet is perf-neutral, before trying to make ambitious changes.

@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 9, 2026
[EXPERIMENT] RawBitSet experiments
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 9, 2026
@rust-bors

rust-bors Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 1eba61e (1eba61e69a9a8e83369894aef1ff64dd0b8e66b2, parent: 98e7077b903559d7a4fafb775cd5292cc9427b67)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (1eba61e): comparison URL.

Overall result: ❌ regressions - 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)
0.2% [0.1%, 0.3%] 3
Regressions ❌
(secondary)
0.2% [0.0%, 0.3%] 8
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [0.1%, 0.3%] 3

Max RSS (memory usage)

Results (primary 2.4%)

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

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

Cycles

Results (primary 2.0%, secondary -2.6%)

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

mean range count
Regressions ❌
(primary)
2.0% [2.0%, 2.0%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.6% [-3.0%, -2.1%] 2
All ❌✅ (primary) 2.0% [2.0%, 2.0%] 1

Binary size

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

Bootstrap: 479.865s -> 479.014s (-0.18%)
Artifact size: 395.05 MiB -> 394.98 MiB (-0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 9, 2026
@Zalathar

Zalathar commented Mar 9, 2026

Copy link
Copy Markdown
Member Author

Hmm, it's frustrating that the monomorphic RawBitSet isn't perf-neutral, even with #[inline] sprinkled everywhere.

Will #[inline(always)] do the trick?

@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 9, 2026
[EXPERIMENT] RawBitSet experiments
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 9, 2026
@rust-bors

rust-bors Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 861e8d4 (861e8d4337f9d836ac906e4daf4a6de867cb24a9, parent: 98e7077b903559d7a4fafb775cd5292cc9427b67)

@panstromek

panstromek commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Yea, I've hit the same thing. This code is just absurdly sensitive to completely innocent changes. These results look very similar to the results in #161496 (comment), which literally just removes the formatting machinery from the assert in insert(): 233ee19.

match-stress seems to be super sensitive to this assert for unclear reason - I guess it's because insert() gets inlined into some super hot place in match checking. That's the only hypothesis I could come up with after staring at Cachegrind diffs for a few hours yesterday (sadly Cachegrind runs don't reproduce the regression overall, so that makes it more difficult to debug).

serde is also sensitive to BitSet changes in general, probably because of borrowck, it was the largest regression when Polonius was enabled. Here the change is probably related to MixedBitSet, which is used in there for dataflow.

@Zalathar

Copy link
Copy Markdown
Member Author

I've gone back to an as-is rebase of the last revision that actually managed to avoid regressions. Let's see if it still does.

@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 Aug 23, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 23, 2026
[EXPERIMENT] RawBitSet experiments
@Zalathar

Copy link
Copy Markdown
Member Author

Yea, I've hit the same thing. This code is just absurdly sensitive to completely innocent changes.

Yeah, this whole PR thread is me trying smaller and smaller changes (while also slapping #[inline] on everything), in an attempt to actually be able to make some progress without regressions.

@rust-bors

rust-bors Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 1469207 (14692074a67511bfd50e5cee835db6910da6b48d)
Base parent: baf1f7c (baf1f7cc4faa79b938148ad52c53e96c0102cbc4)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (1469207): comparison URL.

Overall result: ❌ regressions - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never rustc-perf
@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)
0.2% [0.2%, 0.2%] 5
Regressions ❌
(secondary)
0.5% [0.1%, 1.5%] 14
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [0.2%, 0.2%] 5

Max RSS (memory usage)

Results (secondary -2.3%)

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)
3.3% [3.3%, 3.3%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-7.9% [-7.9%, -7.9%] 1
All ❌✅ (primary) - - 0

Cycles

Results (primary 3.1%)

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

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

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 469.531s -> 470.579s (0.22%)
Artifact size: 400.26 MiB -> 400.24 MiB (-0.01%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 23, 2026
@Zalathar

Copy link
Copy Markdown
Member Author

OK, that was with a clean rebase, so clearly things have become more sensitive since my last successful perf run.

@Zalathar

Copy link
Copy Markdown
Member Author

Let's see what happens with just the first two commits:

@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 Aug 23, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Aug 23, 2026
[EXPERIMENT] RawBitSet experiments
@Zalathar

Copy link
Copy Markdown
Member Author

At some point it probably makes sense to just improve the code and not worry too much about losing 1% on a stress-test benchmark.

@panstromek

Copy link
Copy Markdown
Contributor

Yea, I also think that this is really a symptom of a problem in the calling code so it makes more sense to fix it there.

I think™ I got the match-stress problem. Outlining this insert call removes removes the regression from simplifying the assert for me locally:

if parent_intersection != parent_row_id {
parent_row.intersects_at_least.insert(parent_intersection);
}

I'll try to measure it in the original PR.

@rust-bors

rust-bors Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 0c30e88 (0c30e88c184b705d8b194655231141cd15cdab7f)
Base parent: be0ea33 (be0ea33bba5000ac134e58acde780af83d908e44)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (0c30e88): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

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

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

Results (primary -2.5%, secondary 7.3%)

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)
7.3% [7.3%, 7.3%] 1
Improvements ✅
(primary)
-2.5% [-2.5%, -2.5%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.5% [-2.5%, -2.5%] 1

Cycles

Results (primary 2.2%, secondary 4.6%)

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

mean range count
Regressions ❌
(primary)
2.2% [2.2%, 2.2%] 2
Regressions ❌
(secondary)
22.1% [16.0%, 26.8%] 5
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.2% [-7.2%, -0.9%] 10
All ❌✅ (primary) 2.2% [2.2%, 2.2%] 2

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 470.262s -> 469.29s (-0.21%)
Artifact size: 401.08 MiB -> 400.29 MiB (-0.20%)

@rustbot rustbot removed S-waiting-on-perf Status: Waiting on a perf run to be completed. perf-regression Performance regression. labels Aug 23, 2026
@panstromek

Copy link
Copy Markdown
Contributor

I think™ I got the match-stress problem.

I take this back, it still doesn't help in the assert case, on rustc-perf: #161496 (comment)

But at least your run is successful 🎉

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

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants