Dandandan commented on a change in pull request #8485:
URL: https://github.com/apache/arrow/pull/8485#discussion_r535140816



##########
File path: rust/arrow/src/array/builder.rs
##########
@@ -253,8 +253,18 @@ pub trait BufferBuilderTrait<T: ArrowPrimitiveType> {
 }
 
 impl<T: ArrowPrimitiveType> BufferBuilderTrait<T> for BufferBuilder<T> {
-    default fn new(capacity: usize) -> Self {
-        let buffer = MutableBuffer::new(capacity * 
mem::size_of::<T::Native>());
+    #[inline]
+    fn new(capacity: usize) -> Self {
+        let buffer = if T::DATA_TYPE == DataType::Boolean {

Review comment:
       @jorgecarleitao 
   
   I see this in profiling for the BufferBuilderTrait append function:
   
   
![image](https://user-images.githubusercontent.com/163737/101012554-4c1dfc00-3563-11eb-9b00-f92eac06b7ae.png)
   
   Which accounts for ~9% of the instruction fetches according to callgrind 
when running the TPHC 12 benchmark.
   
   So it seems the `if T::DATA_TYPE == DataType::Boolean` is not being 
optimized out and goes into the partial eq implementation (or the profiler is 
wrong), maybe because the implementation there is not easy to optimize / 
specialize for this case. I will check if another implementation (pattern 
match?) solves this.




----------------------------------------------------------------
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.

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


Reply via email to