perf(arrow): build partition filter mask with BooleanBufferBuilder - #3204
Merged
Merged
Conversation
The partition splitter built each group's selection mask as a throwaway `vec![false; num_rows]` and bit-packed it into a `BooleanArray` via `.into()`, allocating an n-byte `Vec<bool>` plus a full packing pass per group per batch on every partitioned write. Build the packed buffer directly with `BooleanBufferBuilder`, setting only the selected bits.
anoopj
force-pushed
the
perf-partition-filter-buffer
branch
from
September 11, 2026 23:54
651780d to
0766714
Compare
Fokko
approved these changes
Sep 13, 2026
Fokko
left a comment
Contributor
There was a problem hiding this comment.
Asked my LLM friend for a benchmark, and it is more than I expected:
Results
Micro-benchmark isolating exactly the changed code (building each group's selection mask), arrow 59.3, criterion, macOS. Each iteration builds masks for all groups in one batch (i.e. one full split):
┌──────────────────────────────┬───────────────┬──────────────────────────┬─────────┐
│ config (batch rows × groups) │ old Vec<bool> │ new BooleanBufferBuilder │ speedup │
├──────────────────────────────┼───────────────┼──────────────────────────┼─────────┤
│ 1024 × 1 │ 1.47 µs │ 1.07 µs │ 1.37× │
├──────────────────────────────┼───────────────┼──────────────────────────┼─────────┤
│ 1024 × 10 │ 3.65 µs │ 0.69 µs │ 5.30× │
├──────────────────────────────┼───────────────┼──────────────────────────┼─────────┤
│ 8192 × 1 │ 11.28 µs │ 8.34 µs │ 1.35× │
├──────────────────────────────┼───────────────┼──────────────────────────┼─────────┤
│ 8192 × 10 │ 24.12 µs │ 3.37 µs │ 7.15× │
├──────────────────────────────┼───────────────┼──────────────────────────┼─────────┤
│ 8192 × 100 │ 266.8 µs │ 7.67 µs │ 34.8× │
├──────────────────────────────┼───────────────┼──────────────────────────┼─────────┤
│ 65536 × 1 │ 89.3 µs │ 69.2 µs │ 1.29× │
├──────────────────────────────┼───────────────┼──────────────────────────┼─────────┤
│ 65536 × 10 │ 192.8 µs │ 24.7 µs │ 7.79× │
├──────────────────────────────┼───────────────┼──────────────────────────┼─────────┤
│ 65536 × 100 │ 2128.9 µs │ 35.8 µs │ 59.5× │
└──────────────────────────────┴───────────────┴──────────────────────────┴─────────┘
laskoviymishka
approved these changes
Sep 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes are included in this PR?
The partition splitter built each group's selection mask as a throwaway
vec![false; num_rows]and bit-packed it into aBooleanArrayvia.into(), allocating an n-byteVec<bool>plus a full packing pass per group per batch on every partitioned write. Build the packed buffer directly withBooleanBufferBuilder, setting only the selected bits.Are these changes tested?
Covered by existing tests