Skip to content

Replace take_run BufferBuilders with Vec - #10631

Open
cakeni wants to merge 1 commit into
apache:mainfrom
cakeni:perf/arrow-select-take-run-vecs
Open

Replace take_run BufferBuilders with Vec#10631
cakeni wants to merge 1 commit into
apache:mainfrom
cakeni:perf/arrow-select-take-run-vecs

Conversation

@cakeni

@cakeni cakeni commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Using Vec instead of BufferBuilder can benefit from Rust's optimized vector implementation. This updates the two builders used by the run-end encoded take path.

What changes are included in this PR?

  • Replace the run-end and value-index BufferBuilder instances in take_run with preallocated vectors.
  • Push values directly and construct the final ScalarBuffer objects from those vectors.
  • Leave the unrelated fixed-size binary BufferBuilder path unchanged.

Are these changes tested?

Yes. The following checks pass:

  • cargo +stable-x86_64-pc-windows-gnu fmt --all -- --check
  • cargo +stable-x86_64-pc-windows-gnu clippy -p arrow-select --all-targets --all-features --no-deps -- -D warnings
  • cargo +stable-x86_64-pc-windows-gnu test -p arrow-select --all-features (406 unit tests and 17 doctests passed)

Are there any user-facing changes?

No.

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

Copy link
Copy Markdown
Contributor

run benchmark take_kernels

@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c5263943685-1558-7dnqh 6.12.85+ #1 SMP Wed Jun 17 20:31:55 UTC 2026 aarch64 GNU/Linux

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

Comparing perf/arrow-select-take-run-vecs (6d85868) to fc16607 (merge-base) diff

Run configuration
run benchmark take_kernels

BENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental,object_store --bench take_kernels
Results will be posted here when complete


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/arrow-select-take-run-vecs (6d85868) to fc16607 (merge-base) diff

Run configuration
run benchmark take_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_arrow-select-take-run-vecs
-----                                                                     ----                                   -------------------------------
take bool 1024                                                            1.00   1033.2±1.58ns        ? ?/sec    1.00   1033.2±0.87ns        ? ?/sec
take bool 512                                                             1.00    574.1±1.43ns        ? ?/sec    1.00    574.6±0.33ns        ? ?/sec
take bool null indices 1024                                               1.00   770.3±28.55ns        ? ?/sec    1.11   858.4±22.93ns        ? ?/sec
take bool null values 1024                                                1.00      2.0±0.00µs        ? ?/sec    1.00      2.0±0.00µs        ? ?/sec
take bool null values null indices 1024                                   1.00  1442.5±18.10ns        ? ?/sec    1.10  1592.4±21.52ns        ? ?/sec
take check bounds i32 1024                                                1.13    666.0±1.45ns        ? ?/sec    1.00    587.1±8.24ns        ? ?/sec
take check bounds i32 512                                                 1.00    389.7±0.56ns        ? ?/sec    1.16    451.7±2.41ns        ? ?/sec
take fsb value len: 12, indices: 1024                                     1.00      2.5±0.01µs        ? ?/sec    1.01      2.5±0.01µs        ? ?/sec
take fsb value len: 12, null values, indices: 1024                        1.00      3.5±0.00µs        ? ?/sec    1.00      3.5±0.00µs        ? ?/sec
take fsb value optimized len: 16, indices: 1024                           1.00    590.2±1.76ns        ? ?/sec    1.00    591.5±1.68ns        ? ?/sec
take fsb value optimized len: 16, null values, indices: 1024              1.00   1615.8±4.21ns        ? ?/sec    1.00   1612.3±2.14ns        ? ?/sec
take i32 1024                                                             1.03    524.7±0.86ns        ? ?/sec    1.00    511.1±0.60ns        ? ?/sec
take i32 512                                                              1.00    351.2±0.53ns        ? ?/sec    1.00    350.4±0.74ns        ? ?/sec
take i32 null indices 1024                                                1.02    869.8±5.90ns        ? ?/sec    1.00    854.4±1.03ns        ? ?/sec
take i32 null values 1024                                                 1.01   1547.0±2.77ns        ? ?/sec    1.00   1536.5±2.16ns        ? ?/sec
take i32 null values null indices 1024                                    1.00   1656.1±2.65ns        ? ?/sec    1.02   1689.4±2.55ns        ? ?/sec
take list i32 1024                                                        1.00      8.7±0.02µs        ? ?/sec    1.01      8.8±0.02µs        ? ?/sec
take list i32 512                                                         1.00      4.6±0.02µs        ? ?/sec    1.01      4.7±0.03µs        ? ?/sec
take list i32 null indices 1024                                           1.00     10.2±0.02µs        ? ?/sec    1.00     10.2±0.01µs        ? ?/sec
take list i32 null values 1024                                            1.01      6.2±0.02µs        ? ?/sec    1.00      6.1±0.01µs        ? ?/sec
take list i32 null values null indices 1024                               1.00      6.9±0.03µs        ? ?/sec    1.01      6.9±0.03µs        ? ?/sec
take listview i32 1024                                                    1.10   1079.0±2.10ns        ? ?/sec    1.00    981.4±1.36ns        ? ?/sec
take listview i32 512                                                     1.00    602.9±1.81ns        ? ?/sec    1.01    611.2±1.26ns        ? ?/sec
take listview i32 null indices 1024                                       1.00   1615.2±1.43ns        ? ?/sec    1.00   1619.4±3.32ns        ? ?/sec
take listview i32 null values 1024                                        1.00      2.0±0.00µs        ? ?/sec    1.00      2.0±0.00µs        ? ?/sec
take listview i32 null values null indices 1024                           1.00      2.4±0.00µs        ? ?/sec    1.06      2.5±0.00µs        ? ?/sec
take primitive run logical len: 1024, physical len: 512, indices: 1024    1.07     16.5±0.02µs        ? ?/sec    1.00     15.4±0.02µs        ? ?/sec
take str 1024                                                             1.00      8.0±0.00µs        ? ?/sec    1.00      8.0±0.00µs        ? ?/sec
take str 512                                                              1.02      3.7±0.00µs        ? ?/sec    1.00      3.7±0.00µs        ? ?/sec
take str null indices 1024                                                1.01      4.3±0.07µs        ? ?/sec    1.00      4.3±0.06µs        ? ?/sec
take str null indices 512                                                 1.00      2.0±0.04µs        ? ?/sec    1.07      2.2±0.05µs        ? ?/sec
take str null values 1024                                                 1.01      5.0±0.06µs        ? ?/sec    1.00      4.9±0.05µs        ? ?/sec
take str null values null indices 1024                                    1.00      3.1±0.03µs        ? ?/sec    1.02      3.2±0.02µs        ? ?/sec
take stringview 1024                                                      1.00    731.6±1.87ns        ? ?/sec    1.24    910.5±2.34ns        ? ?/sec
take stringview 512                                                       1.00    470.5±0.92ns        ? ?/sec    1.18    557.0±0.95ns        ? ?/sec
take stringview null indices 1024                                         1.00    981.1±2.18ns        ? ?/sec    1.01    986.7±2.44ns        ? ?/sec
take stringview null indices 512                                          1.00    559.1±1.03ns        ? ?/sec    1.01    563.1±1.35ns        ? ?/sec
take stringview null values 1024                                          1.00   1788.4±1.34ns        ? ?/sec    1.05   1885.6±2.79ns        ? ?/sec
take stringview null values null indices 1024                             1.00   1643.4±1.87ns        ? ?/sec    1.06   1749.8±2.29ns        ? ?/sec
take_record_batch 5 primitive cols no nulls 1024                          1.02      3.5±0.02µs        ? ?/sec    1.00      3.4±0.01µs        ? ?/sec
take_record_batch 6 string/binary cols no nulls 1024                      1.00     27.2±0.04µs        ? ?/sec    1.01     27.4±0.03µs        ? ?/sec
take_record_batch 7 mixed cols null values 1024                           1.00     17.8±0.42µs        ? ?/sec    1.00     17.8±0.09µs        ? ?/sec
take_record_batch 7 mixed cols null values null indices 1024              1.00     14.2±0.14µs        ? ?/sec    1.04     14.8±0.04µs        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 410.1s
Peak memory 14.5 MiB
Avg memory 11.4 MiB
CPU user 403.3s
CPU sys 0.0s
Peak spill 0 B

branch

Metric Value
Wall time 410.1s
Peak memory 15.1 MiB
Avg memory 12.0 MiB
CPU user 405.5s
CPU sys 0.0s
Peak spill 0 B

File an issue against this benchmark runner

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants