ritchie46 edited a comment on pull request #9860:
URL: https://github.com/apache/arrow/pull/9860#issuecomment-810995348


   > @ritchie46 did you have some perf results on this?
   > I think it definitely makes sense, especially as the functions are wrapped 
in (unnecessary) `Result` now which might make things worse. Sometimes inlining 
makes things worse performance wise, that's why I think we should have some 
numbers.
   
   There are quite some functions, but for met the most important one is the 
primitive builder.
   
   Running this benchmark:
   
   ```rust
   fn create_primitive_array(n: usize) -> PrimitiveArray<Int64Type> {
       let mut builder = PrimitiveBuilder::new(n);
   
       for i in 0..n {
           builder.append_value(i as i64).unwrap();
       }
   
       builder.finish()
   }
   
   fn add_benchmark(c: &mut Criterion) {
       c.bench_function("512", |b| b.iter(|| create_primitive_array(512)));
       c.bench_function("4096", |b| b.iter(|| create_primitive_array(4096)));
   }
   
   ```
   
   Gave the following improvement:
   
   ```
   Gnuplot not found, using plotters backend
   512                     time:   [848.60 ns 848.70 ns 848.81 ns]              
   
                           change: [-54.476% -54.424% -54.383%] (p = 0.00 < 
0.05)
                           Performance has improved.
   Found 6 outliers among 100 measurements (6.00%)
     2 (2.00%) low mild
     1 (1.00%) high mild
     3 (3.00%) high severe
   
   4096                    time:   [5.3370 us 5.3449 us 5.3539 us]              
    
                           change: [-62.787% -62.696% -62.617%] (p = 0.00 < 
0.05)
                           Performance has improved.
   Found 2 outliers among 100 measurements (2.00%)
     1 (1.00%) high mild
     1 (1.00%) high severe
   
   ```
   
   For a `StringBuilder` it shows the following results. Still improvements, 
but less, because the function call is a smaller part of the work.
   
   ```
   Gnuplot not found, using plotters backend
   512                     time:   [6.1797 us 6.1825 us 6.1851 us]              
   
                           change: [-9.0882% -9.0515% -9.0141%] (p = 0.00 < 
0.05)
                           Performance has improved.
   Found 1 outliers among 100 measurements (1.00%)
     1 (1.00%) high severe
   
   4096                    time:   [37.948 us 37.957 us 37.965 us]              
    
                           change: [-13.363% -13.248% -13.149%] (p = 0.00 < 
0.05)
                           Performance has improved.
   Found 2 outliers among 100 measurements (2.00%)
     1 (1.00%) high mild
     1 (1.00%) high severe
   ```


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