Replace bits-and-blooms/bitset with roaring bitmaps#2386
Replace bits-and-blooms/bitset with roaring bitmaps#2386ValentaTomas wants to merge 7 commits intomainfrom
Conversation
PR SummaryMedium Risk Overview Reviewed by Cursor Bugbot for commit fa35957. Bugbot is set up for automated code reviews on this repo. Configure here. |
fc7f1b4 to
0205899
Compare
6ec4c90 to
b81ec2a
Compare
b81ec2a to
b6fa8a5
Compare
Use roaring v2.17.0 with the new Ranges() iterator throughout. Remove bitset as a direct dependency.
b6fa8a5 to
b0717ba
Compare
Point roaring/v2 at e2b-dev/roaring@efficient-range-iteration until the Ranges() iterator fix is merged upstream. This resolves CI failures from the efficient range iteration implementation.
The process_dies_with_cgroups test gives 5s for the OOM killer to fire after `sleep 1 && tail /dev/zero` with a 1MB memory limit. On ARM64 runners the OOM kill can take longer, causing the context to time out before the process is killed. Increase to 15s.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 405f3d0. Configure here.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fa35957fa3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| tool github.com/vektra/mockery/v3 | ||
|
|
||
| replace github.com/RoaringBitmap/roaring/v2 => github.com/e2b-dev/roaring/v2 v2.16.1-0.20260414062913-60ea6a744802 |
There was a problem hiding this comment.
Yes, waiting for them to merge my bugfix upstream.
There was a problem hiding this comment.
|
|
||
| return bitsetOffsets(t.b.Clone(), t.BlockSize()) | ||
| } | ||
| snapshot := t.b.Clone() |
| return &header.DiffMetadata{ | ||
| Dirty: bitset.From(res.Payload.Resident), | ||
| Empty: bitset.From(res.Payload.Empty), | ||
| Dirty: roaring.FromDense(res.Payload.Resident, false), |
There was a problem hiding this comment.
could you explain why with doCopy=false and why you don't call RunOptimize
| allPages := roaring.New() | ||
| allPages.AddRange(0, uint64(numberOfPages)) | ||
|
|
||
| empty = empty.Difference(dirty) | ||
| empty := roaring.AndNot(allPages, dirty) |
There was a problem hiding this comment.
wouldn't this work better?
| allPages := roaring.New() | |
| allPages.AddRange(0, uint64(numberOfPages)) | |
| empty = empty.Difference(dirty) | |
| empty := roaring.AndNot(allPages, dirty) | |
| empty := roaring.FlipInt(dirty, 0, uint64(numberOfPages)) |
| } | ||
|
|
||
| dirty := diffInfo.Dirty.Difference(diffInfo.Empty) | ||
| dirty := roaring.AndNot(diffInfo.Dirty, diffInfo.Empty) |
There was a problem hiding this comment.
use
| dirty := roaring.AndNot(diffInfo.Dirty, diffInfo.Empty) | |
| diffInfo.Dirty.AndNot(diffInfo.Empty) |
to prevent allocating an extra bitmap
then in
header.DiffMetadata{
Dirty: diffInfo.Dirty,
| } | ||
|
|
||
| maxTimeout := time.Second * 5 | ||
| maxTimeout := time.Second * 15 |
There was a problem hiding this comment.
unrelated to the change, right?
| } | ||
|
|
||
| diffMetadata := header.NewDiffMetadata(c.blockSize, c.dirty.BitSet()) | ||
| diffMetadata := header.NewDiffMetadata(c.blockSize, c.dirty.Bitmap()) |
There was a problem hiding this comment.
0/5 nit: Do we need to clone under the RLock here, or (since we are holding c.mu - maybe we can operate on dirty's data directly here?
| } | ||
|
|
||
| return slices.Collect(b.EachSet()) | ||
| result := make([]uint, 0, b.GetCardinality()) |
There was a problem hiding this comment.
0/5 nit: This function is called only in tests, should it be moved there? I flagged the allocation, but it's fine for the use case.
|
|
||
| roaring "github.com/RoaringBitmap/roaring/v2" | ||
| "github.com/bits-and-blooms/bitset" | ||
| "github.com/RoaringBitmap/roaring/v2" |
There was a problem hiding this comment.
0/5 now that it is always roaring and we intermix it with explicit roaring sets in the code, rename the package to syncroaring? the generic atomicbitset is no longer intention-revealing?
| } | ||
|
|
||
| func (b *Bitset) BitSet() *bitset.BitSet { | ||
| func (b *Bitset) Bitmap() *roaring.Bitmap { |
There was a problem hiding this comment.
See my comment in ExportToDiff - I question the need to do this.

Replace all direct usage of
bits-and-blooms/bitsetwithroaring/v2(v2.17.0). Uses the newRanges()iterator (#522) for range iteration inCreateMappingandBitmapRanges.