viirya commented on code in PR #2740:
URL: https://github.com/apache/arrow-rs/pull/2740#discussion_r973635166


##########
arrow/src/compute/kernels/arity.rs:
##########
@@ -298,36 +297,41 @@ where
     let len = a.len();
 
     if a.null_count() == 0 && b.null_count() == 0 {
-        let values = a.values().iter().zip(b.values()).map(|(l, r)| op(*l, 
*r));
-        let buffer = unsafe { Buffer::try_from_trusted_len_iter(values) }?;
-        // JUSTIFICATION
-        //  Benefit
-        //      ~75% speedup
-        //  Soundness
-        //      `values` is an iterator with a known size from a PrimitiveArray
-        return Ok(unsafe { build_primitive_array(len, buffer, 0, None) });
+        let mut buffer = BufferBuilder::<O::Native>::new(len);
+        buffer.append_n_zeroed(len);

Review Comment:
   Tried another way to iterate the values from both side. But still the 
regression.
   
   I think when we call `value_unchecked` to get values iteratively, it is an 
indirect access pattern compared with `values` where we simply process on a 
slice. It makes LLVM hard to optimize it as vectorized access.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to