Skip to content

Union with serialized bitmap, continued - #361

Draft
harry-hao wants to merge 17 commits into
RoaringBitmap:mainfrom
harry-hao:union-patched
Draft

Union with serialized bitmap, continued#361
harry-hao wants to merge 17 commits into
RoaringBitmap:mainfrom
harry-hao:union-patched

Conversation

@harry-hao

Copy link
Copy Markdown

This is a follow-up to #343.

Regarding the benchmark diffs, I made some changes to pairwise_ops_with_serialized:

  1. Move serialization out of setup. Although setup is not timed, it runs interleaved with the routine in the loop and may pollute the cache.
  2. Rearrange the pair as (small, large) to reduce iteration count, matching real-world usage patterns.
  3. Remove .cloned() from dataset.bitmaps.iter().cloned().tuple_windows(), so that setup clones references to RoaringBitmaps instead of owned instances.
  4. Use iter_batched_ref instead of iter_batched, which passes input by reference.

With this fix applied, no regression is observed from introducing union_with_serialized_unchecked:

Benchmarking pairwise_intersection_with_serialized_unchecked/ref_own/census-income: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 7.1s, enable flat sampling, or reduce sample count to 50.
pairwise_intersection_with_serialized_unchecked/ref_own/census-income
                        time:   [1.2515 ms 1.2538 ms 1.2566 ms]
                        change: [+0.8260% +1.1517% +1.4760%] (p = 0.00 < 0.05)
                        Change within noise threshold.
Found 11 outliers among 100 measurements (11.00%)
  2 (2.00%) low mild
  2 (2.00%) high mild
  7 (7.00%) high severe
pairwise_intersection_with_serialized_unchecked/ref_own/census-income_srt
                        time:   [568.28 µs 569.10 µs 569.82 µs]
                        change: [-0.4029% -0.1253% +0.1804%] (p = 0.38 > 0.05)
                        No change in performance detected.
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high severe
pairwise_intersection_with_serialized_unchecked/ref_own/census1881
                        time:   [74.959 µs 75.139 µs 75.286 µs]
                        change: [-1.2120% -0.2504% +0.5939%] (p = 0.58 > 0.05)
                        No change in performance detected.
pairwise_intersection_with_serialized_unchecked/ref_own/census1881_srt
                        time:   [36.953 µs 37.187 µs 37.381 µs]
                        change: [-1.1594% -0.1838% +0.8941%] (p = 0.73 > 0.05)
                        No change in performance detected.
pairwise_intersection_with_serialized_unchecked/ref_own/weather_sept_85
                        time:   [5.2642 ms 5.2671 ms 5.2699 ms]
                        change: [-0.4152% -0.3363% -0.2595%] (p = 0.00 < 0.05)
                        Change within noise threshold.
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high mild
Benchmarking pairwise_intersection_with_serialized_unchecked/ref_own/weather_sept_85_srt: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 7.2s, enable flat sampling, or reduce sample count to 50.
pairwise_intersection_with_serialized_unchecked/ref_own/weather_sept_85_srt
                        time:   [1.0374 ms 1.0389 ms 1.0402 ms]
                        change: [+0.1271% +0.5279% +0.9522%] (p = 0.01 < 0.05)
                        Change within noise threshold.
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high mild
pairwise_intersection_with_serialized_unchecked/ref_own/wikileaks-noquotes
                        time:   [232.54 µs 232.78 µs 233.07 µs]
                        change: [+0.0371% +0.2912% +0.6248%] (p = 0.03 < 0.05)
                        Change within noise threshold.
Found 11 outliers among 100 measurements (11.00%)
  1 (1.00%) low mild
  5 (5.00%) high mild
  5 (5.00%) high severe
pairwise_intersection_with_serialized_unchecked/ref_own/wikileaks-noquotes_srt
                        time:   [97.167 µs 97.428 µs 97.685 µs]
                        change: [-0.9497% -0.3258% +0.2987%] (p = 0.32 > 0.05)
                        No change in performance detected.
Found 2 outliers among 100 measurements (2.00%)
  1 (1.00%) high mild
  1 (1.00%) high severe

The fixed benchmark also runs faster compared to before:

Dataset change (CI) verdict
census-income [-0.98, -0.36, +0.30] no
census-income_srt [-3.16, -2.15, -1.19] imp
census1881 [-33.69, -32.56, -31.38] imp
census1881_srt [-47.96, -47.21, -46.51] imp
weather_sept_85 [-0.11, +0.29, +0.71] no
weather_sept_85_srt [-4.49, -3.82, -3.14] imp
wikileaks-noquotes [-16.06, -15.66, -15.26] imp
wikileaks-noquotes_srt [-27.17, -26.65, -26.13] imp

(imp = improved, no = no significant change)

Next steps

Unlike intersection, union cannot skip containers — both sides must be fully merged. Whether union_with_serialized can deliver net performance gains, and if so how, remains an open question. I'll keep investigating and post findings to this PR.

forsaken628 and others added 8 commits January 16, 2026 11:37
harry-hao and others added 7 commits August 11, 2026 10:13
…lized_impl

Tight while loop is what 5c60dd40 used; extend_from_slice does not show
a measurable benefit on top of with_capacity (capacity is already reserved).

Co-Authored-By: Claude Opus 4.7 <[email protected]>
Three scenarios track who gets the "larger side as rhs" treatment:
  both_swap    — baseline and compare both swap
  none_swap    — neither swaps (original order)
  ws_only_swap — only compare swaps when USE_WITH_SERIALIZED is set

Setup is unconditional; swap is decided per-bench, independent of env var,
so baseline and compare see consistent inputs in both_swap / none_swap.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants