-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Optimize performance of math::trunc
(~2.5x faster)
#12909
Conversation
let num_array = num.as_primitive::<Float32Type>(); | ||
let precision_array = precision.as_primitive::<Int64Type>(); | ||
let result: PrimitiveArray<Float32Type> = | ||
arrow_arith::arity::binary(num_array, precision_array, |x, y| { |
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.
Is this the same function as this? https://docs.rs/arrow/latest/arrow/compute/fn.binary.html
If so you could remove the new dependency (although it is in the dependency closure anyway already)
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.
@simonvandel Thanks so much for reviewing
Is this the same function as this? https://docs.rs/arrow/latest/arrow/compute/fn.binary.html
Oh, yes it is. Nice!
Signed-off-by: Tai Le Manh <[email protected]>
27c8635
to
7e6f820
Compare
math::trunc
(~2.5x faster)
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.
Thanks @tlm365 and @simonvandel
ColumnarValue::Scalar(Int64(Some(0))) => Ok(Arc::new( | ||
make_function_scalar_inputs!(num, "num", Float64Array, { f64::trunc }), | ||
) as ArrayRef), | ||
ColumnarValue::Array(precision) => Ok(Arc::new(make_function_inputs2!( |
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've broadened #12923 to cover this too
I merged up from main to resolve a conflict on this branch |
🚀 thanks again |
Rationale for this change
Same idea as #12881. Using the
unary
/binary
functions allow faster processing (most likely auto-vectorized code) by avoiding branching on nulls.What changes are included in this PR?
unary
andbinary
Are these changes tested?
Existing testcases.
Are there any user-facing changes?
No.
**BENCHMARK RESULT