Speed up binary kernels (30% faster and and or), add BooleanBuffer::from_bitwise_binary_op#9090
Merged
Dandandan merged 6 commits intoapache:mainfrom Jan 9, 2026
Merged
Conversation
alamb
commented
Jan 2, 2026
| /// ); | ||
| /// assert_eq!(result.inner().as_slice(), &[0b10101110u8, 0b00001111u8]); | ||
| /// ``` | ||
| pub fn from_bitwise_binary_op<F>( |
9d87a11 to
577dfa8
Compare
alamb
commented
Jan 2, 2026
| /// Apply a bitwise not to one input and return the result as a Buffer. | ||
| /// The input is treated as a bitmap, meaning that offset and length are specified in number of bits. | ||
| pub fn buffer_unary_not(left: &Buffer, offset_in_bits: usize, len_in_bits: usize) -> Buffer { | ||
| // TODO: should we deprecate this function in favor of the Buffer ! impl ? |
Contributor
Author
There was a problem hiding this comment.
there is no Buffer impl of ! (there is an implementation in BooleanBuffer)
Contributor
Author
|
run benchmark boolean_kernels |
|
🤖 |
This was referenced Jan 2, 2026
Closed
Closed
Closed
|
🤖: Benchmark completed Details
|
BooleanBuffer::from_bitwise_binary_opand and or), add BooleanBuffer::from_bitwise_binary_op
Dandandan
approved these changes
Jan 7, 2026
Dandandan
reviewed
Jan 7, 2026
arrow-buffer/src/buffer/boolean.rs
Outdated
| .iter() | ||
| .zip(right_chunks.iter()) | ||
| .map(|(left, right)| op(left, right)); | ||
| // Soundness: `BitChunks` is a `BitChunks` iterator which |
Contributor
Author
|
Thank you @Dandandan |
Dandandan
pushed a commit
to Dandandan/arrow-rs
that referenced
this pull request
Jan 15, 2026
…er::from_bitwise_binary_op` (apache#9090) # Which issue does this PR close? - Part of apache#8806 - Closes apache#8854 - Closes apache#8807 This is the next step after - apache#8996 # Rationale for this change - we can help rust / LLVM generate more optimal code by processing u64 words at a time when the buffer is already u64 aligned (see apache#8807) Also, it is hard to find the code to create new Buffers by applying bitwise unary operations. # What changes are included in this PR? - Introduce optimized `BooleanBuffer::from_bitwise_binary` - Migrate several kernels that use `bitwise_bin_op_helper` to use the new BooleanBuffer # Are these changes tested? Yes new tests are added Performance results show 30% performance improvement for the `and` and `or` kernels for aligned buffers (common case) # Are there any user-facing changes? A new API
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.
Which issue does this PR close?
Buffer::from_bitwise_unaryandBuffer::from_bitwise_binaryme… #8854This is the next step after
notkernel by 50%, addBooleanBuffer::from_bitwise_unary#8996Rationale for this change
Also, it is hard to find the code to create new Buffers by applying bitwise unary operations.
What changes are included in this PR?
BooleanBuffer::from_bitwise_binarybitwise_bin_op_helperto use the new BooleanBufferAre these changes tested?
Yes new tests are added
Performance results show 30% performance improvement for the
andandorkernels for aligned buffers (common case)Are there any user-facing changes?
A new API