Skip to content

Replace concat_elements_bytes BufferBuilders with Vec - #10632

Open
cakeni wants to merge 1 commit into
apache:mainfrom
cakeni:perf/arrow-string-concat-bytes-vecs
Open

Replace concat_elements_bytes BufferBuilders with Vec#10632
cakeni wants to merge 1 commit into
apache:mainfrom
cakeni:perf/arrow-string-concat-bytes-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 value and offset builders in concat_elements_bytes.

What changes are included in this PR?

  • Replace the output value and offset BufferBuilder instances with capacity-matched vectors.
  • Use extend_from_slice and push while preserving the existing offset calculations.
  • Convert both vectors directly into the buffers used by ArrayDataBuilder.

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-string --all-targets --all-features --no-deps -- -D warnings
  • cargo +stable-x86_64-pc-windows-gnu test -p arrow-string --all-features (182 unit tests and 10 doctests passed)

Are there any user-facing changes?

No.

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

Copy link
Copy Markdown
Contributor

run benchmark concatenate_elements

@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c5263956732-1559-c7rhm 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-string-concat-bytes-vecs (0b2f7df) to fc16607 (merge-base) diff

Run configuration
run benchmark concatenate_elements

BENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental,object_store --bench concatenate_elements
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-string-concat-bytes-vecs (0b2f7df) to fc16607 (merge-base) diff

Run configuration
run benchmark concatenate_elements
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-string-concat-bytes-vecs
-----                                                          ----                                   -----------------------------------
concat str 1024                                                1.05     12.2±0.39µs        ? ?/sec    1.00     11.6±0.40µs        ? ?/sec
concat str 8192                                                1.18   173.8±24.61µs        ? ?/sec    1.00   147.7±18.28µs        ? ?/sec
concat str nulls 1024                                          1.32      8.9±0.16µs        ? ?/sec    1.00      6.8±0.14µs        ? ?/sec
concat str nulls 8192 over 100 arrays                          1.14     88.2±3.12µs        ? ?/sec    1.00     77.5±2.23µs        ? ?/sec
concat utf8_view  max_str_len=128 null_density=0               1.00     89.7±0.90µs        ? ?/sec    1.04     93.1±1.08µs        ? ?/sec
concat utf8_view  max_str_len=128 null_density=0.2             1.00     81.5±0.32µs        ? ?/sec    1.01     82.0±0.58µs        ? ?/sec
concat utf8_view  max_str_len=20 null_density=0                1.03     55.3±0.02µs        ? ?/sec    1.00     53.8±0.03µs        ? ?/sec
concat utf8_view  max_str_len=20 null_density=0.2              1.01     61.5±0.07µs        ? ?/sec    1.00     61.2±0.10µs        ? ?/sec
concat utf8_view all_inline max_str_len=12 null_density=0      1.00     49.7±0.02µs        ? ?/sec    1.00     49.7±0.03µs        ? ?/sec
concat utf8_view all_inline max_str_len=12 null_density=0.2    1.00     58.3±0.08µs        ? ?/sec    1.00     58.4±0.07µs        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 105.0s
Peak memory 26.9 MiB
Avg memory 17.4 MiB
CPU user 98.9s
CPU sys 0.0s
Peak spill 0 B

branch

Metric Value
Wall time 95.0s
Peak memory 14.0 MiB
Avg memory 11.8 MiB
CPU user 92.1s
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-string performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants