You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2020/12/03 11:36:22 UTC

[GitHub] [arrow] Dandandan commented on a change in pull request #8485: ARROW-10002: [Rust] Remove trait specialization from arrow crate

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 BufferBuilderTrait append:
   
   ![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:
users@infra.apache.org