-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: Branchless Parquet Prefiltering #19190
base: main
Are you sure you want to change the base?
perf: Branchless Parquet Prefiltering #19190
Conversation
i64: num_traits::AsPrimitive<P>, | ||
D: DecoderFunction<P, T>, | ||
{ | ||
let mut num_read = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this loop can be written more efficiently.
let num_valid = validity.count_ones();
let mut num_written = 0;
while filter != 0 {
let offset = filter.trailing_zeros();
validity >>= offset;
let idx = num_valid - validity.count_ones();
let v = if validity & 1 != 0 {
dfn.decode(unsafe { values.get_unchecked(idx) })
} else {
T::zeroed()
};
*out.add(num_written) = v;
num_written += 1;
filter >>= offset + 1;
validity >>= 1;
}
(num_valid, num_written)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even better I believe:
let num_available = validity.count_ones();
let mut num_written = 0;
while filter != 0 {
let offset = filter.trailing_zeros();
let idx_to_read = num_available - (validity >> offset).count_ones();
let v = if validity & 1 != 0 {
dfn.decode(unsafe { values.get_unchecked(idx_to_read) })
} else {
T::zeroed()
};
*out.add(num_written) = v;
num_written += 1;
filter &= filter - 1; // Clear least significant bit.
}
(num_available, num_written)
|
||
let mut v = v; | ||
let mut f = f; | ||
let mut num_read = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idem.
// @NOTE: We have to cast to u64 here to avoid the `shr` overflow on the filter. | ||
let mut f = f as u64; | ||
let mut v = v as u64; | ||
let mut num_read = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idem.
678577f
to
45a3078
Compare
290d953
to
36b8d51
Compare
Change the Parquet decoders to use branchless filtering for the
prefiltered
methods.This rewrites most of the decoders.