Skip to content

(arrow-row) Replace BufferBuilder with Vec in decode_binary - #10851

Merged
Jefffrey merged 1 commit into
apache:mainfrom
zhangxinyao88:codex/arrow-rs-10245-decode-binary
Aug 26, 2026
Merged

(arrow-row) Replace BufferBuilder with Vec in decode_binary#10851
Jefffrey merged 1 commit into
apache:mainfrom
zhangxinyao88:codex/arrow-rs-10245-decode-binary

Conversation

@zhangxinyao88

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

This replaces one of the remaining BufferBuilder callsites listed in #10245. Using Vec for the offsets avoids the builder overhead while preserving the resulting ScalarBuffer.

What changes are included in this PR?

decode_binary now constructs its offsets with Vec<I> instead of BufferBuilder<I>.

Are these changes tested?

Yes:

  • cargo fmt --all -- --check
  • cargo test -p arrow-row — 95 unit tests and 8 doc tests passed
  • cargo clippy -p arrow-row --all-targets --all-features -- -D warnings

Existing round-trip tests cover the changed path, so no new tests were added.

Benchmark: convert_rows 4096 string(100, 0)

Time
main 47.769 µs
This PR 45.488 µs

Criterion reported a 4.4% improvement.

Are there any user-facing changes?

No.

AI assistance

Codex was used to identify the callsite, prepare the focused refactor, run validation, and draft this description.

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

Copy link
Copy Markdown
Contributor

run benchmark row_format
env:
BENCH_FILTER: convert_rows

@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 codex/arrow-rs-10245-decode-binary (1b9cd7a) to 2a82e59 (merge-base) diff

Run configuration
run benchmark row_format
env:
  BENCH_FILTER: "convert_rows"
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                                                                                                             codex_arrow-rs-10245-decode-binary     main
-----                                                                                                             ----------------------------------     ----
convert_rows 10 large_list(0) of u64(0)                                                                           1.00   923.6±16.50ns        ? ?/sec    1.01    933.6±6.21ns        ? ?/sec
convert_rows 10 list(0) of u64(0)                                                                                 1.00   987.8±12.90ns        ? ?/sec    1.00    989.4±6.02ns        ? ?/sec
convert_rows 4096 4096 string_dictionary(20, 0.5), string_dictionary(30, 0), string_dictionary(100, 0), i64(0)    1.00    226.7±0.93µs        ? ?/sec    1.01    228.8±1.32µs        ? ?/sec
convert_rows 4096 53 columns                                                                                      1.01  1807.8±13.49µs        ? ?/sec    1.00  1794.1±13.36µs        ? ?/sec
convert_rows 4096 bool(0, 0.5)                                                                                    1.00     18.5±0.42µs        ? ?/sec    1.02     18.8±1.16µs        ? ?/sec
convert_rows 4096 bool(0.3, 0.5)                                                                                  1.00     18.9±0.61µs        ? ?/sec    1.02     19.2±1.12µs        ? ?/sec
convert_rows 4096 i64(0)                                                                                          1.00     31.1±0.46µs        ? ?/sec    1.01     31.6±1.15µs        ? ?/sec
convert_rows 4096 i64(0.3)                                                                                        1.00     31.6±0.78µs        ? ?/sec    1.01     31.8±1.16µs        ? ?/sec
convert_rows 4096 large_list(0) of u64(0)                                                                         1.00    173.4±0.68µs        ? ?/sec    1.00    173.1±1.29µs        ? ?/sec
convert_rows 4096 large_list(0) sliced to 10 of u64(0)                                                            1.00   1217.2±3.49ns        ? ?/sec    1.01   1230.5±8.46ns        ? ?/sec
convert_rows 4096 list(0) of u64(0)                                                                               1.00    161.7±0.66µs        ? ?/sec    1.07    173.0±1.50µs        ? ?/sec
convert_rows 4096 list(0) sliced to 10 of u64(0)                                                                  1.00   1334.3±6.21ns        ? ?/sec    1.01   1345.5±7.97ns        ? ?/sec
convert_rows 4096 run_primitive(1024 physical)                                                                    1.00     83.6±0.60µs        ? ?/sec    1.01     84.0±1.31µs        ? ?/sec
convert_rows 4096 run_primitive(256 physical)                                                                     1.00     60.7±0.74µs        ? ?/sec    1.00     60.4±1.29µs        ? ?/sec
convert_rows 4096 run_primitive(512 physical)                                                                     1.00     68.6±0.69µs        ? ?/sec    1.00     68.7±1.30µs        ? ?/sec
convert_rows 4096 string view(1..100, 0)                                                                          1.00     70.9±0.63µs        ? ?/sec    1.01     71.5±1.19µs        ? ?/sec
convert_rows 4096 string view(1..100, 0.5)                                                                        1.00     46.7±0.51µs        ? ?/sec    1.02     47.8±1.25µs        ? ?/sec
convert_rows 4096 string view(10, 0)                                                                              1.00     48.4±0.39µs        ? ?/sec    1.00     48.5±1.29µs        ? ?/sec
convert_rows 4096 string view(100, 0)                                                                             1.00    102.0±0.54µs        ? ?/sec    1.03    104.6±1.45µs        ? ?/sec
convert_rows 4096 string view(100, 0.5)                                                                           1.08     67.3±0.54µs        ? ?/sec    1.00     62.0±1.35µs        ? ?/sec
convert_rows 4096 string view(30, 0)                                                                              1.01     64.3±0.52µs        ? ?/sec    1.00     63.6±1.23µs        ? ?/sec
convert_rows 4096 string(10, 0)                                                                                   1.00     46.6±0.70µs        ? ?/sec    1.02     47.6±1.06µs        ? ?/sec
convert_rows 4096 string(100, 0)                                                                                  1.00    103.7±0.43µs        ? ?/sec    1.01    104.7±1.31µs        ? ?/sec
convert_rows 4096 string(100, 0.5)                                                                                1.00     62.5±0.47µs        ? ?/sec    1.01     62.9±1.17µs        ? ?/sec
convert_rows 4096 string(20, 0.5), string(30, 0), string(100, 0), i64(0)                                          1.00    226.2±0.73µs        ? ?/sec    1.02    229.9±1.19µs        ? ?/sec
convert_rows 4096 string(30, 0)                                                                                   1.03     70.9±0.50µs        ? ?/sec    1.00     69.0±1.20µs        ? ?/sec
convert_rows 4096 string_dictionary(10, 0)                                                                        1.05     48.1±0.48µs        ? ?/sec    1.00     45.7±1.08µs        ? ?/sec
convert_rows 4096 string_dictionary(100, 0)                                                                       1.00    104.4±0.51µs        ? ?/sec    1.00    104.7±1.19µs        ? ?/sec
convert_rows 4096 string_dictionary(100, 0.5)                                                                     1.00     62.4±0.48µs        ? ?/sec    1.01     63.3±1.15µs        ? ?/sec
convert_rows 4096 string_dictionary(30, 0)                                                                        1.01     70.1±0.49µs        ? ?/sec    1.00     69.1±1.24µs        ? ?/sec
convert_rows 4096 string_dictionary_low_cardinality(10, 0)                                                        1.02     46.5±0.46µs        ? ?/sec    1.00     45.5±1.13µs        ? ?/sec
convert_rows 4096 string_dictionary_low_cardinality(100, 0)                                                       1.00    103.9±0.49µs        ? ?/sec    1.00    104.1±1.20µs        ? ?/sec
convert_rows 4096 string_dictionary_low_cardinality(30, 0)                                                        1.01     70.0±0.50µs        ? ?/sec    1.00     69.1±1.21µs        ? ?/sec
convert_rows 4096 u64(0)                                                                                          1.00     31.3±0.69µs        ? ?/sec    1.00     31.4±1.20µs        ? ?/sec
convert_rows 4096 u64(0.3)                                                                                        1.00     31.5±0.80µs        ? ?/sec    1.00     31.6±1.17µs        ? ?/sec
convert_rows 8192 53 columns                                                                                      1.00      4.6±0.58ms        ? ?/sec    1.02      4.7±0.60ms        ? ?/sec
convert_rows_parsed 4096 string view(1..100, 0)                                                                   1.22     90.5±0.35µs        ? ?/sec    1.00     74.0±0.13µs        ? ?/sec
convert_rows_parsed 4096 string view(1..100, 0.5)                                                                 1.61     74.0±0.48µs        ? ?/sec    1.00     46.1±0.07µs        ? ?/sec
convert_rows_parsed 4096 string view(10, 0)                                                                       1.00     50.2±0.14µs        ? ?/sec    1.00     50.1±0.31µs        ? ?/sec
convert_rows_parsed 4096 string view(100, 0)                                                                      1.03    112.7±0.30µs        ? ?/sec    1.00    109.8±0.12µs        ? ?/sec
convert_rows_parsed 4096 string view(100, 0.5)                                                                    1.08     69.4±0.22µs        ? ?/sec    1.00     64.2±0.64µs        ? ?/sec
convert_rows_parsed 4096 string view(30, 0)                                                                       1.00     61.9±0.08µs        ? ?/sec    1.00     62.0±0.12µs        ? ?/sec
convert_rows_parsed 4096 string(10, 0)                                                                            1.02     45.4±0.10µs        ? ?/sec    1.00     44.7±0.24µs        ? ?/sec
convert_rows_parsed 4096 string(100, 0)                                                                           1.00    116.8±0.26µs        ? ?/sec    1.00    117.2±0.16µs        ? ?/sec
convert_rows_parsed 4096 string(100, 0.5)                                                                         1.00     67.8±0.24µs        ? ?/sec    1.00     67.8±0.31µs        ? ?/sec
convert_rows_parsed 4096 string(30, 0)                                                                            1.05     74.4±0.08µs        ? ?/sec    1.00     71.0±0.64µs        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 455.1s
Peak memory 21.2 MiB
Avg memory 9.5 MiB
CPU user 452.3s
CPU sys 0.1s
Peak spill 0 B

branch

Metric Value
Wall time 450.1s
Peak memory 21.3 MiB
Avg memory 10.0 MiB
CPU user 447.5s
CPU sys 0.1s
Peak spill 0 B

File an issue against this benchmark runner

@Jefffrey
Jefffrey merged commit 736090f into apache:main Aug 26, 2026
26 checks passed
@Jefffrey Jefffrey changed the title Replace BufferBuilder with Vec in decode_binary (arrow-row) Replace BufferBuilder with Vec in decode_binary Aug 26, 2026
@Jefffrey

Copy link
Copy Markdown
Contributor

thanks @zhangxinyao88

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants