Repository navigation
Speedup filter (up to ~1.5x) FilterBuilder::Optimize/BitIndexIterator/iter_set_bits_rev - #9229
Conversation
|
run benchmarks filter_kernels |
|
🤖 Hi @Dandandan, thanks for the request (#9229 (comment)).
Please choose one or more of these with |
|
run benchmark filter_kernels |
|
🤖 |
|
run benchmark arrow_reader arrow_reader_clickbench |
|
🤖 |
| if self.current_chunk != 0 { | ||
| let bit_pos = self.current_chunk.trailing_zeros(); | ||
| self.current_chunk ^= 1 << bit_pos; | ||
| self.current_chunk &= self.current_chunk - 1; |
There was a problem hiding this comment.
This generates much more efficient code
| return Some(chunk_idx + (bit_pos as usize)); | ||
| if rev_chunk != 0 { | ||
| let bit_pos = rev_chunk.trailing_zeros(); | ||
| rev_chunk &= rev_chunk - 1; |
There was a problem hiding this comment.
Applying the same optimization here
|
run benchmark filter_kernels |
FilterBuilder::Optimize/BitIndexIterator/iter_set_bits_rev
|
🤖: Benchmark completed Details
|
|
🤖 |
| } | ||
|
|
||
| /// Collect this iterator as a [`Vec`] | ||
| pub fn collect(mut self) -> Vec<usize> { |
There was a problem hiding this comment.
Faster collect for IndexIterator (as we cannot use TrustedLen yet in stable)
There was a problem hiding this comment.
Maybe it is worth a comment explaining that we can avoid this code when TrustedLengh is stable
Seems it might not give the speed up on intel cpu (or at least not on the default cpu target). |
| } | ||
|
|
||
| /// Collect this iterator as a [`Vec`] | ||
| pub fn collect(mut self) -> Vec<usize> { |
There was a problem hiding this comment.
Maybe it is worth a comment explaining that we can avoid this code when TrustedLengh is stable
| if self.current_chunk != 0 { | ||
| let bit_pos = self.current_chunk.trailing_zeros(); | ||
| self.current_chunk ^= 1 << bit_pos; | ||
| self.current_chunk &= self.current_chunk - 1; |
|
🤖: Benchmark completed Details
|
|
🤖 |
|
🤖: Benchmark completed Details
|
|
🤖 |
|
🤖: Benchmark completed Details
|
Nice |
Which issue does this PR close?
Rationale for this change
Makes 50% selection optimize / filter roughly 1.5x as fast:
Also apply the optimization for Parquet:
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?