Skip to content

Commit 70d5d21

Browse files
authored
Merge pull request #536 from RoaringBitmap/bsi-correctness-benchmarks
Optimize roaring64 BSI BatchEqual and int64 comparisons
2 parents 44559cd + 132f8df commit 70d5d21

6 files changed

Lines changed: 885 additions & 8 deletions

File tree

roaring64/BSI_BENCHMARKS.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# BSI64 Benchmarks
2+
3+
These notes capture local benchmark results for the BSI64 `BatchEqual` and
4+
comparison paths. They are intended as reproducible PR evidence, not as
5+
contractual performance guarantees.
6+
7+
Environment:
8+
9+
- CPU: 12th Gen Intel(R) Core(TM) i7-1255U
10+
- OS/arch: linux/amd64
11+
- Package: `github.com/RoaringBitmap/roaring/v2/roaring64`
12+
13+
Commands:
14+
15+
```sh
16+
go test ./roaring64 -count=1
17+
go test ./roaring64 -run '^$' -bench 'BenchmarkBSI64BatchEqual' -benchmem -count 3
18+
go test ./roaring64 -run '^$' -bench 'BenchmarkBSI64Compare(Big)?Value|BenchmarkBSI64BatchEqual(Big)?LargeAgeFixture' -benchmem -count 1
19+
```
20+
21+
Representative results:
22+
23+
| Benchmark | Before | After | Notes |
24+
| --- | ---: | ---: | --- |
25+
| `BenchmarkBSI64BatchEqualLargeAgeFixture` | ~13-14s/op, ~12.4GB/op | ~145-205ms/op, ~25.5MB/op | Avoids row-by-row `GetBigValue` for int64-width values. |
26+
| `BenchmarkBSI64BatchEqualM128Scattered` | ~1.25s/op, ~458MB/op | ~11-17ms/op, ~12.5MB/op | Detects complete bit-cube value patterns. |
27+
| `BenchmarkBSI64CompareValueEQLargeAgeFixture` | ~4.44s/op, ~461MB/op | ~100-118ms/op, ~19.7MB/op | `EQ` delegates to optimized `BatchEqual`. |
28+
| `BenchmarkBSI64CompareValueRangeLargeAgeFixture` | ~7.49s/op, ~501MB/op | ~204-224ms/op, ~122.6MB/op | Uses bitmap-native signed int64 comparison. |
29+
| `BenchmarkBSI64CompareValueGELargeAgeFixture` | ~3.45s/op, ~500MB/op | ~168-184ms/op, ~82.3MB/op | Uses bitmap-native signed int64 comparison. |
30+
31+
Compatibility:
32+
33+
- Public method signatures are unchanged.
34+
- `CompareBigValue` and `BatchEqualBig` internally delegate to the optimized
35+
int64 paths only when the BSI and query values fit in signed 64-bit space.
36+
- True wider-than-64-bit values continue to use the existing generic paths.
37+
- `BatchEqualBig` now keys values by sign and magnitude so positive and negative
38+
values with the same magnitude do not collide.
39+
40+
Follow-up:
41+
42+
- This change is scoped to `roaring64`. The 32-bit `BitSliceIndexing` package
43+
already has separate `BatchEqual` coverage, and `CompareValue` parity can be
44+
addressed in a follow-up PR with its own benchmarks and signed-value tests.

0 commit comments

Comments
 (0)