Skip to content

perf: optimize loops for primitive types binary kernels. - #10518

Draft
Anakin100100 wants to merge 2 commits into
apache:mainfrom
Anakin100100:perf/arithmetic-buffer-optimization
Draft

perf: optimize loops for primitive types binary kernels. #10518
Anakin100100 wants to merge 2 commits into
apache:mainfrom
Anakin100100:perf/arithmetic-buffer-optimization

Conversation

@Anakin100100

Copy link
Copy Markdown

Which issue does this PR close?

Part of #10245

Rationale for this change

Improves performance of the arithmetic kernels operating on primite types.

What changes are included in this PR?

I read the issue and focused on try_binary and discovered a few other optimizations there. All mentions of benchmarks here refer to decimal_arithmetic benchmark which covers addition and subtraction on

binary: replaced iterator collect with a direct loop which LLVM can better optimize and avoids option checks. The loop overhead here is a large part of the runtime when the underlying op is simple.

try_binary: in the null path uses Vec directly to create the buffer instead of going through the BufferBuilder. I tested it with a benchmark with 10-90% nulls and there is 5-9% improvement to the overall runtime. I don't think there's reason to include this benchmark in the library because it's very specific to this path and not general enough to be useful in the future.

try_binary_no_nulls: the typed array slice write can be vectorized more easily, Independent of that I verified that removing the no-inline annotation increases performance by additional 5% which makes sense with a more direct loop.

On average these changes increase the throughput of the kernels by 26-27% on same scale and 14-15% of different scale benchamrks for 32 and 64 bit types because the loop is a smaller fraction in the second case.

decimal32_equal_scale/sub
                        time:   [917.00 ns 923.95 ns 932.62 ns]
                        thrpt:  [1.0980 Gelem/s 1.1083 Gelem/s 1.1167 Gelem/s]
                 change:
                        time:   [−23.032% −21.954% −20.901%] (p = 0.00 < 0.05)
                        thrpt:  [+26.424% +28.130% +29.924%]
decimal64_different_scale/add
                        time:   [1.9084 µs 1.9212 µs 1.9366 µs]
                        thrpt:  [528.77 Melem/s 533.00 Melem/s 536.59 Melem/s]
                 change:
                        time:   [−15.134% −14.025% −12.902%] (p = 0.00 < 0.05)
                        thrpt:  [+14.813% +16.313% +17.833%]

On 128 and 256 bit types there is around 5% speedup because of more complex math behind the underlying op.

Are these changes tested?

Yes, already covered by tests.

Are there any user-facing changes?

No

@github-actions github-actions Bot added arrow Changes to the arrow crate arrow-arith labels Aug 2, 2026
@Jefffrey

Jefffrey commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

run benchmarks arithmetic_kernels bitwise_kernel decimal_arithmetic

@adriangbot

This comment was marked as duplicate.

@adriangbot

This comment was marked as duplicate.

@adriangbot

This comment was marked as duplicate.

@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark completed (GKE) | trigger

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

Comparing perf/arithmetic-buffer-optimization (9f4e3b3) to ed92960 (merge-base) diff

Run configuration
run benchmark bitwise_kernel
CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected
Details

group                                                                  main                                   perf_arithmetic-buffer-optimization
-----                                                                  ----                                   -----------------------------------
bench bitwise array scalar: and/bitwise array and, 20% nulls           1.00      7.1±0.01µs        ? ?/sec    1.05      7.5±0.04µs        ? ?/sec
bench bitwise array scalar: and/bitwise array scalar and, no nulls     1.01      7.4±0.04µs        ? ?/sec    1.00      7.3±0.02µs        ? ?/sec
bench bitwise array scalar: or/bitwise array scalar or, 20% nulls      1.00      7.1±0.05µs        ? ?/sec    1.06      7.5±0.03µs        ? ?/sec
bench bitwise array scalar: or/bitwise array scalar or, no nulls       1.00      7.2±0.03µs        ? ?/sec    1.00      7.2±0.02µs        ? ?/sec
bench bitwise array scalar: xor/bitwise array scalar xor, 20% nulls    1.00      7.1±0.02µs        ? ?/sec    1.05      7.4±0.04µs        ? ?/sec
bench bitwise array scalar: xor/bitwise array scalar xor, no nulls     1.00      7.2±0.02µs        ? ?/sec    1.01      7.2±0.03µs        ? ?/sec
bench bitwise array: and/bitwise array and, 20% nulls                  1.00     14.5±0.05µs        ? ?/sec    1.03     15.0±0.05µs        ? ?/sec
bench bitwise array: and/bitwise array and, no nulls                   1.05     14.5±0.67µs        ? ?/sec    1.00     13.8±0.09µs        ? ?/sec
bench bitwise: not/bitwise array not, 20% nulls                        1.00      7.3±0.03µs        ? ?/sec    1.05      7.7±0.02µs        ? ?/sec
bench bitwise: not/bitwise array not, no nulls                         1.03      7.5±0.04µs        ? ?/sec    1.00      7.3±0.02µs        ? ?/sec
bench bitwise: or/bitwise array or, 20% nulls                          1.00     14.5±0.06µs        ? ?/sec    1.01     14.7±0.05µs        ? ?/sec
bench bitwise: or/bitwise array or, no nulls                           1.05     14.5±0.04µs        ? ?/sec    1.00     13.7±0.06µs        ? ?/sec
bench bitwise: xor/bitwise array xor, 20% nulls                        1.00     14.5±0.06µs        ? ?/sec    1.02     14.7±0.05µs        ? ?/sec
bench bitwise: xor/bitwise array xor, no nulls                         1.04     14.5±0.03µs        ? ?/sec    1.00     13.9±0.03µs        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 130.0s
Peak memory 11.9 MiB
Avg memory 10.3 MiB
CPU user 125.9s
CPU sys 0.0s
Peak spill 0 B

branch

Metric Value
Wall time 130.0s
Peak memory 15.1 MiB
Avg memory 14.1 MiB
CPU user 126.2s
CPU sys 0.0s
Peak spill 0 B

File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark completed (GKE) | trigger

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

Comparing perf/arithmetic-buffer-optimization (9f4e3b3) to ed92960 (merge-base) diff

Run configuration
run benchmark decimal_arithmetic
CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected
Details

group                             main                                     perf_arithmetic-buffer-optimization
-----                             ----                                     -----------------------------------
decimal128_different_scale/add    1.17      2.7±0.04µs 368.1 MElem/sec     1.00      2.3±0.00µs 432.3 MElem/sec
decimal128_different_scale/sub    1.16      2.6±0.02µs 372.8 MElem/sec     1.00      2.3±0.00µs 430.7 MElem/sec
decimal128_equal_scale/add        1.14  1418.5±187.37ns 688.5 MElem/sec    1.00   1244.7±6.79ns 784.6 MElem/sec
decimal128_equal_scale/sub        1.15  1419.3±183.39ns 688.1 MElem/sec    1.00   1236.2±2.86ns 790.0 MElem/sec
decimal256_different_scale/add    1.01     18.1±0.13µs 53.9 MElem/sec      1.00     17.9±0.03µs 54.5 MElem/sec
decimal256_different_scale/sub    1.01     18.4±0.06µs 53.0 MElem/sec      1.00     18.3±0.07µs 53.4 MElem/sec
decimal256_equal_scale/add        1.00      3.2±0.28µs 303.2 MElem/sec     1.02      3.3±0.12µs 297.1 MElem/sec
decimal256_equal_scale/sub        1.00      2.9±0.15µs 334.4 MElem/sec     1.13      3.3±0.12µs 297.2 MElem/sec
decimal32_different_scale/add     1.17      2.7±0.00µs 368.0 MElem/sec     1.00      2.3±0.00µs 431.7 MElem/sec
decimal32_different_scale/sub     1.18      2.7±0.01µs 368.0 MElem/sec     1.00      2.3±0.00µs 432.5 MElem/sec
decimal32_equal_scale/add         1.00   1255.6±2.98ns 777.7 MElem/sec     1.00   1259.2±0.80ns 775.5 MElem/sec
decimal32_equal_scale/sub         1.00  1248.4±12.80ns 782.3 MElem/sec     1.01   1261.2±0.92ns 774.3 MElem/sec
decimal64_different_scale/add     1.16      2.6±0.01µs 372.4 MElem/sec     1.00      2.3±0.00µs 432.5 MElem/sec
decimal64_different_scale/sub     1.16      2.6±0.00µs 372.7 MElem/sec     1.00      2.3±0.00µs 432.8 MElem/sec
decimal64_equal_scale/add         1.00   1229.6±2.94ns 794.2 MElem/sec     1.01   1236.4±3.53ns 789.9 MElem/sec
decimal64_equal_scale/sub         1.00   1228.6±2.91ns 794.9 MElem/sec     1.00   1233.4±1.69ns 791.8 MElem/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 165.0s
Peak memory 8.9 MiB
Avg memory 4.7 MiB
CPU user 161.9s
CPU sys 0.0s
Peak spill 0 B

branch

Metric Value
Wall time 165.0s
Peak memory 9.1 MiB
Avg memory 4.4 MiB
CPU user 159.2s
CPU sys 0.0s
Peak spill 0 B

File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark completed (GKE) | trigger

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

Comparing perf/arithmetic-buffer-optimization (9f4e3b3) to ed92960 (merge-base) diff

Run configuration
run benchmark arithmetic_kernels
CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected
Details

group                    main                                   perf_arithmetic-buffer-optimization
-----                    ----                                   -----------------------------------
add(0)                   1.00      6.3±0.13µs        ? ?/sec    1.00      6.3±0.01µs        ? ?/sec
add(0.1)                 1.00      6.8±0.03µs        ? ?/sec    1.09      7.4±0.02µs        ? ?/sec
add(0.5)                 1.00      6.9±0.02µs        ? ?/sec    1.03      7.1±0.03µs        ? ?/sec
add(0.9)                 1.00      7.1±0.02µs        ? ?/sec    1.00      7.1±0.03µs        ? ?/sec
add(1)                   1.00      6.9±0.02µs        ? ?/sec    1.02      7.1±0.02µs        ? ?/sec
add_checked(0)           1.00      6.2±0.02µs        ? ?/sec    1.00      6.2±0.02µs        ? ?/sec
add_checked(0.1)         1.00      6.8±0.02µs        ? ?/sec    1.06      7.2±0.01µs        ? ?/sec
add_checked(0.5)         1.00      7.1±0.01µs        ? ?/sec    1.00      7.1±0.02µs        ? ?/sec
add_checked(0.9)         1.00      7.1±0.01µs        ? ?/sec    1.00      7.1±0.01µs        ? ?/sec
add_checked(1)           1.00      6.9±0.01µs        ? ?/sec    1.02      7.1±0.01µs        ? ?/sec
add_scalar(0)            1.00      3.6±0.02µs        ? ?/sec    1.03      3.7±0.01µs        ? ?/sec
add_scalar(0.1)          1.02      3.6±0.01µs        ? ?/sec    1.00      3.5±0.01µs        ? ?/sec
add_scalar(0.5)          1.01      3.6±0.02µs        ? ?/sec    1.00      3.5±0.02µs        ? ?/sec
add_scalar(0.9)          1.00      3.5±0.01µs        ? ?/sec    1.00      3.5±0.01µs        ? ?/sec
add_scalar(1)            1.00      3.5±0.00µs        ? ?/sec    1.01      3.6±0.01µs        ? ?/sec
divide(0)                1.00     16.7±0.02µs        ? ?/sec    1.00     16.7±0.01µs        ? ?/sec
divide(0.1)              1.00     17.1±0.01µs        ? ?/sec    1.01     17.3±0.02µs        ? ?/sec
divide(0.5)              1.00     17.1±0.01µs        ? ?/sec    1.01     17.2±0.01µs        ? ?/sec
divide(0.9)              1.00     17.1±0.01µs        ? ?/sec    1.01     17.3±0.01µs        ? ?/sec
divide(1)                1.00     17.2±0.01µs        ? ?/sec    1.01     17.3±0.01µs        ? ?/sec
divide_scalar(0)         1.00     16.6±0.04µs        ? ?/sec    1.00     16.6±0.02µs        ? ?/sec
divide_scalar(0.1)       1.00     16.6±0.02µs        ? ?/sec    1.00     16.6±0.02µs        ? ?/sec
divide_scalar(0.5)       1.00     16.6±0.01µs        ? ?/sec    1.00     16.6±0.01µs        ? ?/sec
divide_scalar(0.9)       1.00     16.6±0.01µs        ? ?/sec    1.00     16.6±0.01µs        ? ?/sec
divide_scalar(1)         1.00     16.6±0.01µs        ? ?/sec    1.00     16.6±0.01µs        ? ?/sec
modulo(0)                1.01    207.6±0.24µs        ? ?/sec    1.00    204.8±0.42µs        ? ?/sec
modulo(0.1)              1.01    245.7±0.56µs        ? ?/sec    1.00    242.1±0.32µs        ? ?/sec
modulo(0.5)              1.00    382.2±0.71µs        ? ?/sec    1.02    391.3±0.70µs        ? ?/sec
modulo(0.9)              1.00    175.8±1.77µs        ? ?/sec    1.01    176.8±2.79µs        ? ?/sec
modulo(1)                1.00    136.0±4.06µs        ? ?/sec    1.17    158.8±4.80µs        ? ?/sec
modulo_scalar(0)         1.00    396.0±2.22µs        ? ?/sec    1.00    396.2±2.19µs        ? ?/sec
modulo_scalar(0.1)       1.00    370.2±4.21µs        ? ?/sec    1.00    369.8±4.07µs        ? ?/sec
modulo_scalar(0.5)       1.00    259.7±0.28µs        ? ?/sec    1.00    259.7±0.30µs        ? ?/sec
modulo_scalar(0.9)       1.01    155.6±3.31µs        ? ?/sec    1.00    153.9±2.94µs        ? ?/sec
modulo_scalar(1)         1.00    133.5±3.56µs        ? ?/sec    1.05    140.1±9.25µs        ? ?/sec
multiply(0)              1.05      6.5±0.03µs        ? ?/sec    1.00      6.2±0.02µs        ? ?/sec
multiply(0.1)            1.00      6.7±0.02µs        ? ?/sec    1.11      7.5±0.02µs        ? ?/sec
multiply(0.5)            1.00      6.9±0.02µs        ? ?/sec    1.02      7.1±0.01µs        ? ?/sec
multiply(0.9)            1.00      7.0±0.01µs        ? ?/sec    1.02      7.1±0.02µs        ? ?/sec
multiply(1)              1.00      6.9±0.02µs        ? ?/sec    1.03      7.1±0.01µs        ? ?/sec
multiply_checked(0)      1.00      6.2±0.01µs        ? ?/sec    1.00      6.2±0.00µs        ? ?/sec
multiply_checked(0.1)    1.00      6.7±0.02µs        ? ?/sec    1.08      7.3±0.01µs        ? ?/sec
multiply_checked(0.5)    1.00      6.9±0.02µs        ? ?/sec    1.02      7.1±0.01µs        ? ?/sec
multiply_checked(0.9)    1.00      7.0±0.02µs        ? ?/sec    1.01      7.1±0.01µs        ? ?/sec
multiply_checked(1)      1.00      6.9±0.02µs        ? ?/sec    1.02      7.1±0.01µs        ? ?/sec
multiply_scalar(0)       1.00      3.5±0.01µs        ? ?/sec    1.02      3.6±0.01µs        ? ?/sec
multiply_scalar(0.1)     1.01      3.5±0.01µs        ? ?/sec    1.00      3.5±0.01µs        ? ?/sec
multiply_scalar(0.5)     1.00      3.5±0.00µs        ? ?/sec    1.01      3.5±0.01µs        ? ?/sec
multiply_scalar(0.9)     1.00      3.5±0.00µs        ? ?/sec    1.02      3.6±0.01µs        ? ?/sec
multiply_scalar(1)       1.00      3.6±0.01µs        ? ?/sec    1.05      3.7±0.01µs        ? ?/sec
subtract(0)              1.00      6.2±0.03µs        ? ?/sec    1.00      6.2±0.02µs        ? ?/sec
subtract(0.1)            1.00      6.8±0.01µs        ? ?/sec    1.07      7.3±0.01µs        ? ?/sec
subtract(0.5)            1.00      6.9±0.01µs        ? ?/sec    1.03      7.1±0.02µs        ? ?/sec
subtract(0.9)            1.00      7.0±0.01µs        ? ?/sec    1.02      7.1±0.01µs        ? ?/sec
subtract(1)              1.00      7.1±0.01µs        ? ?/sec    1.00      7.1±0.01µs        ? ?/sec
subtract_checked(0)      1.01      6.3±0.03µs        ? ?/sec    1.00      6.2±0.02µs        ? ?/sec
subtract_checked(0.1)    1.00      6.8±0.02µs        ? ?/sec    1.09      7.4±0.03µs        ? ?/sec
subtract_checked(0.5)    1.00      7.0±0.02µs        ? ?/sec    1.03      7.1±0.02µs        ? ?/sec
subtract_checked(0.9)    1.00      7.0±0.03µs        ? ?/sec    1.01      7.1±0.02µs        ? ?/sec
subtract_checked(1)      1.00      7.0±0.01µs        ? ?/sec    1.02      7.1±0.02µs        ? ?/sec
subtract_scalar(0)       1.00      3.6±0.01µs        ? ?/sec    1.01      3.6±0.00µs        ? ?/sec
subtract_scalar(0.1)     1.05      3.7±0.01µs        ? ?/sec    1.00      3.5±0.01µs        ? ?/sec
subtract_scalar(0.5)     1.00      3.5±0.01µs        ? ?/sec    1.00      3.6±0.01µs        ? ?/sec
subtract_scalar(0.9)     1.00      3.5±0.01µs        ? ?/sec    1.00      3.5±0.01µs        ? ?/sec
subtract_scalar(1)       1.06      3.8±0.01µs        ? ?/sec    1.00      3.6±0.01µs        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 600.1s
Peak memory 10.0 MiB
Avg memory 5.4 MiB
CPU user 593.4s
CPU sys 0.1s
Peak spill 0 B

branch

Metric Value
Wall time 600.1s
Peak memory 10.7 MiB
Avg memory 5.9 MiB
CPU user 594.6s
CPU sys 0.1s
Peak spill 0 B

File an issue against this benchmark runner

Comment thread arrow-arith/src/arity.rs

let buffer: Vec<_> = values.collect();
let len = a.len();
let byte_width = O::Native::get_byte_width();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

binary: replaced iterator collect with a direct loop which LLVM can better optimize and avoids option checks. The loop overhead here is a large part of the runtime when the underlying op is simple.

this seems surprising to me since as we were iterating+zipping over values() there wouldnt be any option checks going on

Comment thread arrow-arith/src/arity.rs
F: Fn(A::Item, B::Item) -> Result<O::Native, ArrowError>,
{
let mut buffer = MutableBuffer::new(len * O::Native::get_byte_width());
let byte_width = O::Native::get_byte_width();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this get better performance than simply using a vec here?

Comment thread arrow-arith/src/arity.rs
Comment on lines +299 to 300
let values = Buffer::from(buffer).into();
Ok(PrimitiveArray::new(values, Some(nulls)))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let values = Buffer::from(buffer).into();
Ok(PrimitiveArray::new(values, Some(nulls)))
Ok(PrimitiveArray::new(buffer.into(), Some(nulls)))

@alamb
alamb marked this pull request as draft August 4, 2026 17:43
@alamb

alamb commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Marking as draft as I think this PR is no longer waiting on feedback and I am trying to make it easier to find PRs in need of review. Please mark it as ready for review when it is ready for another look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate arrow-arith performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants