Skip to content

Improve take_bytes perf in the null cases between 10-25%#9625

Draft
AdamGS wants to merge 3 commits intoapache:mainfrom
AdamGS:adamg/faster-take-bytes
Draft

Improve take_bytes perf in the null cases between 10-25%#9625
AdamGS wants to merge 3 commits intoapache:mainfrom
AdamGS:adamg/faster-take-bytes

Conversation

@AdamGS
Copy link
Copy Markdown
Contributor

@AdamGS AdamGS commented Mar 30, 2026

Which issue does this PR close?

  • Closes #NNN.

Rationale for this change

Just improves performance, I was profiling some things downstream and got curious about how it works.

What changes are included in this PR?

The main idea is to use a two-pass approach:

  1. Compute byte offsets and collects (start, end) byte ranges
  2. Copy byte data via raw pointer writes (copy_byte_ranges)

This PR also reduces the branching from 4 (one for each nullability combination) to only two.

Are these changes tested?

Existing tests

Are there any user-facing changes?

None

@github-actions github-actions bot added the arrow Changes to the arrow crate label Mar 30, 2026
@AdamGS AdamGS force-pushed the adamg/faster-take-bytes branch from a41e896 to 57cacc4 Compare March 30, 2026 10:40
@AdamGS
Copy link
Copy Markdown
Contributor Author

AdamGS commented Mar 30, 2026

Running the take_kernels benchmark locally (MacBook Pro, M3 Max), I get the following results, seems like the non-null cases have some variability in the results, across multiple runs they are +/-3%

Benchmarking take str 512: Collecting 100 samples in estimated 5.0094 s (1.7M iteratiotake str 512            time:   [2.9368 µs 2.9759 µs 3.0239 µs]
                        change: [+2.2019% +3.8482% +5.6373%] (p = 0.00 < 0.05)
                        Performance has regressed.
Found 21 outliers among 100 measurements (21.00%)
  19 (19.00%) high mild
  2 (2.00%) high severe

Benchmarking take str 1024: Collecting 100 samples in estimated 5.0295 s (752k iteratitake str 1024           time:   [6.8638 µs 6.9733 µs 7.0946 µs]
                        change: [+1.5596% +2.8349% +4.2869%] (p = 0.00 < 0.05)
                        Performance has regressed.

Benchmarking take str null indices 512: Collecting 100 samples in estimated 5.0064 s (take str null indices 512
                        time:   [1.7367 µs 1.7383 µs 1.7401 µs]
                        change: [−12.578% −12.355% −12.130%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 14 outliers among 100 measurements (14.00%)
  1 (1.00%) low severe
  1 (1.00%) low mild
  10 (10.00%) high mild
  2 (2.00%) high severe

Benchmarking take str null indices 1024: Collecting 100 samples in estimated 5.0038 s take str null indices 1024
                        time:   [4.1551 µs 4.1610 µs 4.1670 µs]
                        change: [−5.7784% −5.6160% −5.4566%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 8 outliers among 100 measurements (8.00%)
  3 (3.00%) low severe
  1 (1.00%) low mild
  3 (3.00%) high mild
  1 (1.00%) high severe

Benchmarking take str null values 1024: Collecting 100 samples in estimated 5.0192 s (take str null values 1024
                        time:   [4.4388 µs 4.4466 µs 4.4537 µs]
                        change: [−12.466% −12.197% −11.916%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 5 outliers among 100 measurements (5.00%)
  2 (2.00%) low severe
  1 (1.00%) low mild
  1 (1.00%) high mild
  1 (1.00%) high severe

Benchmarking take str null values null indices 1024: Collecting 100 samples in estimattake str null values null indices 1024
                        time:   [2.7090 µs 2.7227 µs 2.7356 µs]
                        change: [−26.967% −26.737% −26.506%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 4 outliers among 100 measurements (4.00%)
  4 (4.00%) high mild

@Dandandan
Copy link
Copy Markdown
Contributor

run benchmark take_kernels

T::Offset::from_usize(capacity)
.ok_or_else(|| ArrowError::OffsetOverflowError(capacity))?,
);
ranges.push((start, end));
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.

Won't for this case be faster to just keep the previous implementation?

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.

we can use the unsafe if it helps

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

let me try it out

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah it seems to be more consistently ~5% faster locally, I've used unsafe in what I think is a sound way

@adriangbot
Copy link
Copy Markdown

🤖 Arrow criterion benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c4154384283-602-gvzgb 6.12.55+ #1 SMP Sun Feb 1 08:59:41 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 adamg/faster-take-bytes (57cacc4) to aa9432c (merge-base) diff
BENCH_NAME=take_kernels
BENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental,object_store --bench take_kernels
BENCH_FILTER=
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)

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                                                                     adamg_faster-take-bytes                main
-----                                                                     -----------------------                ----
take bool 1024                                                            1.00   1032.6±1.20ns        ? ?/sec    1.01   1039.3±0.72ns        ? ?/sec
take bool 512                                                             1.00    576.5±0.68ns        ? ?/sec    1.00    576.4±0.56ns        ? ?/sec
take bool null indices 1024                                               1.14    869.3±4.13ns        ? ?/sec    1.00   764.5±27.41ns        ? ?/sec
take bool null values 1024                                                1.01      2.1±0.00µs        ? ?/sec    1.00      2.1±0.00µs        ? ?/sec
take bool null values null indices 1024                                   1.13   1625.2±1.12ns        ? ?/sec    1.00  1439.1±12.75ns        ? ?/sec
take check bounds i32 1024                                                1.00    657.0±0.75ns        ? ?/sec    1.01    665.8±0.78ns        ? ?/sec
take check bounds i32 512                                                 1.16    453.3±0.77ns        ? ?/sec    1.00    390.5±0.83ns        ? ?/sec
take fsb value len: 12, indices: 1024                                     1.02      2.7±0.19µs        ? ?/sec    1.00      2.6±0.15µs        ? ?/sec
take fsb value len: 12, null values, indices: 1024                        1.02      3.8±0.19µs        ? ?/sec    1.00      3.7±0.15µs        ? ?/sec
take fsb value optimized len: 16, indices: 1024                           1.10    752.0±1.52ns        ? ?/sec    1.00    686.3±2.73ns        ? ?/sec
take fsb value optimized len: 16, null values, indices: 1024              1.00   1751.0±1.77ns        ? ?/sec    1.00   1747.6±1.98ns        ? ?/sec
take i32 1024                                                             1.00    515.8±1.39ns        ? ?/sec    1.02    525.8±1.06ns        ? ?/sec
take i32 512                                                              1.00    352.9±0.80ns        ? ?/sec    1.00    351.2±0.89ns        ? ?/sec
take i32 null indices 1024                                                1.00    856.0±1.60ns        ? ?/sec    1.00    858.0±2.26ns        ? ?/sec
take i32 null values 1024                                                 1.00   1541.4±1.70ns        ? ?/sec    1.01   1550.7±2.28ns        ? ?/sec
take i32 null values null indices 1024                                    1.05   1743.5±2.28ns        ? ?/sec    1.00   1662.5±1.83ns        ? ?/sec
take primitive run logical len: 1024, physical len: 512, indices: 1024    1.00     17.0±0.06µs        ? ?/sec    1.00     17.0±0.06µs        ? ?/sec
take str 1024                                                             1.00      7.4±0.01µs        ? ?/sec    1.14      8.4±0.04µs        ? ?/sec
take str 512                                                              1.00      3.4±0.00µs        ? ?/sec    1.14      3.9±0.03µs        ? ?/sec
take str null indices 1024                                                1.00      5.0±0.01µs        ? ?/sec    1.17      5.8±0.01µs        ? ?/sec
take str null indices 512                                                 1.00      2.4±0.01µs        ? ?/sec    1.15      2.8±0.01µs        ? ?/sec
take str null values 1024                                                 1.00      5.4±0.02µs        ? ?/sec    1.19      6.5±0.02µs        ? ?/sec
take str null values null indices 1024                                    1.00      3.4±0.01µs        ? ?/sec    1.49      5.1±0.01µs        ? ?/sec
take stringview 1024                                                      1.00    735.4±1.34ns        ? ?/sec    1.09    802.5±1.83ns        ? ?/sec
take stringview 512                                                       1.00    472.3±1.11ns        ? ?/sec    1.00    471.3±2.68ns        ? ?/sec
take stringview null indices 1024                                         1.08    989.5±1.81ns        ? ?/sec    1.00    915.9±1.91ns        ? ?/sec
take stringview null indices 512                                          1.00    564.4±1.04ns        ? ?/sec    1.00    564.4±2.31ns        ? ?/sec
take stringview null values 1024                                          1.00   1780.0±1.20ns        ? ?/sec    1.01   1799.0±1.95ns        ? ?/sec
take stringview null values null indices 1024                             1.06   1769.8±1.20ns        ? ?/sec    1.00   1671.0±6.77ns        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 272.2s
Peak memory 2.1 GiB
Avg memory 2.1 GiB
CPU user 271.2s
CPU sys 0.7s
Disk read 0 B
Disk write 587.8 MiB

branch

Metric Value
Wall time 274.1s
Peak memory 2.1 GiB
Avg memory 2.1 GiB
CPU user 273.9s
CPU sys 0.1s
Disk read 0 B
Disk write 2.3 MiB

File an issue against this benchmark runner

@AdamGS AdamGS force-pushed the adamg/faster-take-bytes branch from b6143ff to 089c9a9 Compare March 30, 2026 12:53
@Dandandan
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-c4155109394-604-twzwj 6.12.55+ #1 SMP Sun Feb 1 08:59:41 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 adamg/faster-take-bytes (089c9a9) to aa9432c (merge-base) diff
BENCH_NAME=take_kernels
BENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental,object_store --bench take_kernels
BENCH_FILTER=
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)

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                                                                     adamg_faster-take-bytes                main
-----                                                                     -----------------------                ----
take bool 1024                                                            1.00   1037.3±3.07ns        ? ?/sec    1.02  1063.2±14.96ns        ? ?/sec
take bool 512                                                             1.00    574.3±4.08ns        ? ?/sec    1.01    579.0±0.47ns        ? ?/sec
take bool null indices 1024                                               1.14    873.1±2.01ns        ? ?/sec    1.00   767.6±27.59ns        ? ?/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.13   1640.8±1.41ns        ? ?/sec    1.00  1446.2±12.18ns        ? ?/sec
take check bounds i32 1024                                                1.00    656.4±0.78ns        ? ?/sec    1.01    663.5±3.63ns        ? ?/sec
take check bounds i32 512                                                 1.17    453.2±0.91ns        ? ?/sec    1.00    387.4±4.64ns        ? ?/sec
take fsb value len: 12, indices: 1024                                     1.00      2.7±0.16µs        ? ?/sec    1.02      2.7±0.19µs        ? ?/sec
take fsb value len: 12, null values, indices: 1024                        1.00      3.7±0.16µs        ? ?/sec    1.01      3.8±0.19µs        ? ?/sec
take fsb value optimized len: 16, indices: 1024                           1.01    764.1±1.09ns        ? ?/sec    1.00    753.5±2.20ns        ? ?/sec
take fsb value optimized len: 16, null values, indices: 1024              1.00   1746.5±4.83ns        ? ?/sec    1.00   1748.8±1.38ns        ? ?/sec
take i32 1024                                                             1.00    515.3±1.08ns        ? ?/sec    1.01    520.8±5.44ns        ? ?/sec
take i32 512                                                              1.00    352.7±1.17ns        ? ?/sec    1.01    356.7±7.09ns        ? ?/sec
take i32 null indices 1024                                                1.00    857.9±2.00ns        ? ?/sec    1.00    857.7±1.27ns        ? ?/sec
take i32 null values 1024                                                 1.00   1541.6±2.21ns        ? ?/sec    1.01   1551.7±1.76ns        ? ?/sec
take i32 null values null indices 1024                                    1.05   1745.3±2.80ns        ? ?/sec    1.00   1664.8±2.77ns        ? ?/sec
take primitive run logical len: 1024, physical len: 512, indices: 1024    1.00     17.0±0.06µs        ? ?/sec    1.00     17.1±0.06µs        ? ?/sec
take str 1024                                                             1.00      8.0±0.01µs        ? ?/sec    1.04      8.4±0.03µs        ? ?/sec
take str 512                                                              1.00      3.7±0.00µs        ? ?/sec    1.06      3.9±0.02µs        ? ?/sec
take str null indices 1024                                                1.00      4.8±0.15µs        ? ?/sec    1.21      5.9±0.02µs        ? ?/sec
take str null indices 512                                                 1.00      2.3±0.10µs        ? ?/sec    1.21      2.8±0.01µs        ? ?/sec
take str null values 1024                                                 1.00      5.3±0.10µs        ? ?/sec    1.20      6.4±0.02µs        ? ?/sec
take str null values null indices 1024                                    1.00      3.4±0.03µs        ? ?/sec    1.54      5.2±0.01µs        ? ?/sec
take stringview 1024                                                      1.00    736.8±1.57ns        ? ?/sec    1.00    735.7±1.68ns        ? ?/sec
take stringview 512                                                       1.00    470.8±1.39ns        ? ?/sec    1.01    474.8±3.78ns        ? ?/sec
take stringview null indices 1024                                         1.00    915.3±1.53ns        ? ?/sec    1.00    912.6±0.79ns        ? ?/sec
take stringview null indices 512                                          1.12    630.3±2.00ns        ? ?/sec    1.00    561.1±0.94ns        ? ?/sec
take stringview null values 1024                                          1.04   1785.4±2.85ns        ? ?/sec    1.00   1718.7±3.11ns        ? ?/sec
take stringview null values null indices 1024                             1.06   1742.5±3.77ns        ? ?/sec    1.00   1647.0±1.40ns        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 272.6s
Peak memory 2.1 GiB
Avg memory 2.1 GiB
CPU user 271.4s
CPU sys 0.9s
Disk read 0 B
Disk write 550.5 MiB

branch

Metric Value
Wall time 274.3s
Peak memory 2.1 GiB
Avg memory 2.1 GiB
CPU user 274.1s
CPU sys 0.1s
Disk read 0 B
Disk write 2.1 MiB

File an issue against this benchmark runner

@Dandandan
Copy link
Copy Markdown
Contributor

Dandandan commented Mar 30, 2026

57cacc4

take str 1024                                                             1.00      7.4±0.01µs        ? ?/sec    1.14      8.4±0.04µs        ? ?/sec
take str 512                                                              1.00      3.4±0.00µs        ? ?/sec    1.14      3.9±0.03µs        ? ?/sec

vs 089c9a9

take str 1024                                                             1.00      8.0±0.01µs        ? ?/sec    1.04      8.4±0.03µs        ? ?/sec
take str 512                                                              1.00      3.7±0.00µs        ? ?/sec    1.06      3.9±0.02µs        ? ?/sec

Earlier one looks slightly better, I'll run once more

@Dandandan
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-c4155360140-605-t4kxs 6.12.55+ #1 SMP Sun Feb 1 08:59:41 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 adamg/faster-take-bytes (089c9a9) to aa9432c (merge-base) diff
BENCH_NAME=take_kernels
BENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental,object_store --bench take_kernels
BENCH_FILTER=
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)

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                                                                     adamg_faster-take-bytes                main
-----                                                                     -----------------------                ----
take bool 1024                                                            1.00   1032.7±0.91ns        ? ?/sec    1.01   1039.8±1.47ns        ? ?/sec
take bool 512                                                             1.00    572.7±0.33ns        ? ?/sec    1.01    580.4±0.77ns        ? ?/sec
take bool null indices 1024                                               1.14    874.8±4.21ns        ? ?/sec    1.00   765.8±28.86ns        ? ?/sec
take bool null values 1024                                                1.00      2.0±0.00µs        ? ?/sec    1.01      2.0±0.00µs        ? ?/sec
take bool null values null indices 1024                                   1.12   1624.8±4.53ns        ? ?/sec    1.00   1449.7±9.24ns        ? ?/sec
take check bounds i32 1024                                                1.00    654.1±0.49ns        ? ?/sec    1.02    666.0±1.60ns        ? ?/sec
take check bounds i32 512                                                 1.16    454.6±2.54ns        ? ?/sec    1.00    390.7±1.07ns        ? ?/sec
take fsb value len: 12, indices: 1024                                     1.00      2.7±0.15µs        ? ?/sec    1.02      2.7±0.19µs        ? ?/sec
take fsb value len: 12, null values, indices: 1024                        1.00      3.7±0.15µs        ? ?/sec    1.02      3.8±0.19µs        ? ?/sec
take fsb value optimized len: 16, indices: 1024                           1.00    689.6±1.74ns        ? ?/sec    1.09    754.2±1.53ns        ? ?/sec
take fsb value optimized len: 16, null values, indices: 1024              1.00   1750.0±3.40ns        ? ?/sec    1.00   1753.5±3.50ns        ? ?/sec
take i32 1024                                                             1.00    514.0±0.72ns        ? ?/sec    1.02    525.6±1.75ns        ? ?/sec
take i32 512                                                              1.00    352.3±0.87ns        ? ?/sec    1.00    352.2±0.62ns        ? ?/sec
take i32 null indices 1024                                                1.00    856.3±0.88ns        ? ?/sec    1.00    859.9±2.08ns        ? ?/sec
take i32 null values 1024                                                 1.00   1537.5±1.63ns        ? ?/sec    1.01   1552.2±2.04ns        ? ?/sec
take i32 null values null indices 1024                                    1.05   1740.4±2.20ns        ? ?/sec    1.00   1661.6±2.33ns        ? ?/sec
take primitive run logical len: 1024, physical len: 512, indices: 1024    1.00     17.2±0.05µs        ? ?/sec    1.01     17.3±0.07µs        ? ?/sec
take str 1024                                                             1.00      8.0±0.01µs        ? ?/sec    1.06      8.5±0.05µs        ? ?/sec
take str 512                                                              1.00      3.7±0.00µs        ? ?/sec    1.04      3.9±0.02µs        ? ?/sec
take str null indices 1024                                                1.00      4.9±0.15µs        ? ?/sec    1.21      5.9±0.02µs        ? ?/sec
take str null indices 512                                                 1.00      2.3±0.09µs        ? ?/sec    1.20      2.8±0.01µs        ? ?/sec
take str null values 1024                                                 1.00      5.3±0.10µs        ? ?/sec    1.20      6.4±0.02µs        ? ?/sec
take str null values null indices 1024                                    1.00      3.4±0.04µs        ? ?/sec    1.52      5.1±0.01µs        ? ?/sec
take stringview 1024                                                      1.00    731.3±1.29ns        ? ?/sec    1.01    741.8±1.02ns        ? ?/sec
take stringview 512                                                       1.00    469.4±1.49ns        ? ?/sec    1.14    537.2±2.78ns        ? ?/sec
take stringview null indices 1024                                         1.00    917.4±1.56ns        ? ?/sec    1.01    925.5±5.68ns        ? ?/sec
take stringview null indices 512                                          1.00    560.1±1.73ns        ? ?/sec    1.01    563.7±1.13ns        ? ?/sec
take stringview null values 1024                                          1.00   1729.0±4.47ns        ? ?/sec    1.00   1728.7±1.03ns        ? ?/sec
take stringview null values null indices 1024                             1.02   1724.0±1.68ns        ? ?/sec    1.00   1682.5±2.10ns        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 276.5s
Peak memory 2.1 GiB
Avg memory 2.1 GiB
CPU user 275.7s
CPU sys 0.6s
Disk read 4.0 KiB
Disk write 1.4 GiB

branch

Metric Value
Wall time 273.1s
Peak memory 2.1 GiB
Avg memory 2.1 GiB
CPU user 273.0s
CPU sys 0.1s
Disk read 0 B
Disk write 2.1 MiB

File an issue against this benchmark runner

capacity: usize,
values: &mut Vec<u8>,
) {
values.reserve(capacity);
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.

What is the expected behavior if the vec is non-empty? Currently its a bit inconsistent in reserving additional capacity, but then overwriting any existing content. I think appending might make sense, which means the assert and dst pointer below should be based on Vec::spare_capacity_mut.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah this might be a bit confusing, this being a function is a remanent of a previous iteration but I might just inline it which I think makes it clearer.

Signed-off-by: Adam Gutglick <adam@spiraldb.com>
@AdamGS
Copy link
Copy Markdown
Contributor Author

AdamGS commented Apr 1, 2026

I've made both branches use spare_capacity_mut and removed the extra function, which makes the overall flow clearer IMO

@alamb
Copy link
Copy Markdown
Contributor

alamb commented Apr 6, 2026

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-c4194806555-912-fsqcg 6.12.55+ #1 SMP Sun Feb 1 08:59:41 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 adamg/faster-take-bytes (1b3d1fa) to aa9432c (merge-base) diff
BENCH_NAME=take_kernels
BENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental,object_store --bench take_kernels
BENCH_FILTER=
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)

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                                                                     adamg_faster-take-bytes                main
-----                                                                     -----------------------                ----
take bool 1024                                                            1.00   1038.3±0.71ns        ? ?/sec    1.00   1037.9±3.72ns        ? ?/sec
take bool 512                                                             1.01    577.5±0.46ns        ? ?/sec    1.00    573.2±2.93ns        ? ?/sec
take bool null indices 1024                                               1.16    890.8±4.15ns        ? ?/sec    1.00   769.0±27.87ns        ? ?/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.15   1668.5±2.87ns        ? ?/sec    1.00  1444.7±11.51ns        ? ?/sec
take check bounds i32 1024                                                1.00    654.4±0.66ns        ? ?/sec    1.01    664.1±0.68ns        ? ?/sec
take check bounds i32 512                                                 1.16    451.3±0.96ns        ? ?/sec    1.00    388.6±0.84ns        ? ?/sec
take fsb value len: 12, indices: 1024                                     1.00      2.7±0.16µs        ? ?/sec    1.01      2.7±0.16µs        ? ?/sec
take fsb value len: 12, null values, indices: 1024                        1.00      3.7±0.16µs        ? ?/sec    1.01      3.7±0.16µs        ? ?/sec
take fsb value optimized len: 16, indices: 1024                           1.00    685.7±1.53ns        ? ?/sec    1.01    690.4±2.46ns        ? ?/sec
take fsb value optimized len: 16, null values, indices: 1024              1.00   1745.4±1.44ns        ? ?/sec    1.00   1741.2±1.96ns        ? ?/sec
take i32 1024                                                             1.00    514.9±0.73ns        ? ?/sec    1.02    525.3±1.36ns        ? ?/sec
take i32 512                                                              1.00    351.4±1.21ns        ? ?/sec    1.00    350.4±0.79ns        ? ?/sec
take i32 null indices 1024                                                1.00    863.5±1.03ns        ? ?/sec    1.00    867.0±3.10ns        ? ?/sec
take i32 null values 1024                                                 1.00   1543.2±1.57ns        ? ?/sec    1.00   1543.8±3.53ns        ? ?/sec
take i32 null values null indices 1024                                    1.05   1738.0±1.94ns        ? ?/sec    1.00   1659.5±3.92ns        ? ?/sec
take primitive run logical len: 1024, physical len: 512, indices: 1024    1.00     17.2±0.08µs        ? ?/sec    1.00     17.2±0.06µs        ? ?/sec
take str 1024                                                             1.00      8.3±0.01µs        ? ?/sec    1.01      8.4±0.05µs        ? ?/sec
take str 512                                                              1.00      3.9±0.01µs        ? ?/sec    1.02      3.9±0.03µs        ? ?/sec
take str null indices 1024                                                1.00      4.5±0.14µs        ? ?/sec    1.27      5.7±0.02µs        ? ?/sec
take str null indices 512                                                 1.00      2.2±0.06µs        ? ?/sec    1.30      2.8±0.01µs        ? ?/sec
take str null values 1024                                                 1.00      5.2±0.14µs        ? ?/sec    1.23      6.4±0.02µs        ? ?/sec
take str null values null indices 1024                                    1.00      3.3±0.07µs        ? ?/sec    1.59      5.3±0.01µs        ? ?/sec
take stringview 1024                                                      1.09    800.7±0.68ns        ? ?/sec    1.00    731.5±0.73ns        ? ?/sec
take stringview 512                                                       1.13    537.0±0.78ns        ? ?/sec    1.00    477.2±1.27ns        ? ?/sec
take stringview null indices 1024                                         1.07    981.0±1.17ns        ? ?/sec    1.00    914.6±0.59ns        ? ?/sec
take stringview null indices 512                                          1.01    563.2±0.95ns        ? ?/sec    1.00    557.6±1.04ns        ? ?/sec
take stringview null values 1024                                          1.05   1811.1±1.15ns        ? ?/sec    1.00   1720.9±0.93ns        ? ?/sec
take stringview null values null indices 1024                             1.06   1771.0±1.28ns        ? ?/sec    1.00   1673.1±2.30ns        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 275.0s
Peak memory 2.1 GiB
Avg memory 2.1 GiB
CPU user 274.1s
CPU sys 0.7s
Peak spill 0 B

branch

Metric Value
Wall time 277.0s
Peak memory 2.1 GiB
Avg memory 2.1 GiB
CPU user 276.8s
CPU sys 0.1s
Peak spill 0 B

File an issue against this benchmark runner

@AdamGS
Copy link
Copy Markdown
Contributor Author

AdamGS commented Apr 8, 2026

regressions in "take stringview" might be significant, I'll look into it.

@alamb
Copy link
Copy Markdown
Contributor

alamb commented Apr 9, 2026

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

@alamb alamb marked this pull request as draft April 9, 2026 12:31
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants