You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "kowanietz (via GitHub)" <gi...@apache.org> on 2026/08/21 14:49:13 UTC
[PR] Use Vec for primitive array unary operations [arrow-rs]
kowanietz opened a new pull request, #10783:
URL: https://github.com/apache/arrow-rs/pull/10783
# Which issue does this PR close?
- part of #10245
# Rationale for this change
Replacing `BufferBuilder` with `Vec` improves the performenace of primitive array unary operations.
# What changes are included in this PR?
Replaces the `BufferBuilder<...>` usages in `PrimitiveArray::try_unary` and `PrimitiveArray::unary_opt` with `Vecs`.
Also adds benchmarks for both operations with and without input nulls
# Are these changes tested?
All tests pass:
- `cargo fmt --all -- --check`
- `cargo clippy -p arrow-array --all-targets --all-features --no-deps -- -D warnings`
- `cargo test -p arrow-array --all-features`
- `cargo bench -p arrow-array --bench primitive_array -- --test`
Local benchmark results for 65,536 `Int32` values:
| Benchmark | Before | After | Change |
|---|---:|---:|---:|
| `try_unary`, no input nulls | 10.600 µs | 8.865 µs | 16.4% faster |
| `try_unary`, 20% input nulls | 54.486 µs | 54.623 µs | no clear change |
| `unary_opt`, no input nulls | 48.641 µs | 49.630 µs | no clear change |
| `unary_opt`, 20% input nulls | 75.155 µs | 75.903 µs | no clear change |
I currently only have a MacBook available so benching this on Linux would probably make sense.
# Are there any user-facing changes?
No.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use Vec for primitive array unary operations [arrow-rs]
Posted by "adriangbot (via GitHub)" <gi...@apache.org>.
adriangbot commented on PR #10783:
URL: https://github.com/apache/arrow-rs/pull/10783#issuecomment-5374802732
🤖 Arrow criterion benchmark running (GKE) | [trigger](https://github.com/apache/arrow-rs/pull/10783#issuecomment-5374780982)
**Instance:** `c4a-highmem-16` (12 vCPU / 65 GiB) | `Linux bench-c5374780982-1852-vcr25 6.12.85+ #1 SMP Sat Jun 27 09:31:30 UTC 2026 aarch64 GNU/Linux`
<details><summary>CPU Details (lscpu)</summary>
```
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>
Comparing perf/primitive-array-vec (52b4cdd04a2261e53c0f8f3280c2f25ecee87606) to c837ee8 (merge-base) [diff](https://github.com/apache/arrow-rs/compare/c837ee83926e6c4f327405dcc220de3c7dd06b06..52b4cdd04a2261e53c0f8f3280c2f25ecee87606)
<details><summary>Run configuration</summary>
```yaml
run benchmark primitive_array
```
</details>
BENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental,object_store --bench primitive_array
Results will be posted here when complete
---
[File an issue](https://github.com/adriangb/datafusion-benchmarking/issues) against this benchmark runner
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use Vec for primitive array unary operations [arrow-rs]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey merged PR #10783:
URL: https://github.com/apache/arrow-rs/pull/10783
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use Vec for primitive array unary operations [arrow-rs]
Posted by "adriangbot (via GitHub)" <gi...@apache.org>.
adriangbot commented on PR #10783:
URL: https://github.com/apache/arrow-rs/pull/10783#issuecomment-5371467017
Hi @kowanietz, thanks for the request (https://github.com/apache/arrow-rs/pull/10783#issuecomment-5371466670). Only whitelisted users can trigger benchmarks. Allowed users: [2010YOUY01](https://github.com/2010YOUY01), [Dandandan](https://github.com/Dandandan), [Fokko](https://github.com/Fokko), [Jefffrey](https://github.com/Jefffrey), [Omega359](https://github.com/Omega359), [Rachelint](https://github.com/Rachelint), [Rich-T-kid](https://github.com/Rich-T-kid), [adriangb](https://github.com/adriangb), [alamb](https://github.com/alamb), [asubiotto](https://github.com/asubiotto), [brunal](https://github.com/brunal), [buraksenn](https://github.com/buraksenn), [cetra3](https://github.com/cetra3), [codephage2020](https://github.com/codephage2020), [coderfender](https://github.com/coderfender), [comphead](https://github.com/comphead), [erenavsarogullari](https://github.com/erenavsarogullari), [etseidl](https://github.com/etseidl), [friendlymatthew](https://github.com/friendlymatthew), [
gabotechs](https://github.com/gabotechs), [geoffreyclaude](https://github.com/geoffreyclaude), [grtlr](https://github.com/grtlr), [haohuaijin](https://github.com/haohuaijin), [jonathanc-n](https://github.com/jonathanc-n), [kevinjqliu](https://github.com/kevinjqliu), [klion26](https://github.com/klion26), [kosiew](https://github.com/kosiew), [kumarUjjawal](https://github.com/kumarUjjawal), [kunalsinghdadhwal](https://github.com/kunalsinghdadhwal), [liamzwbao](https://github.com/liamzwbao), [mbutrovich](https://github.com/mbutrovich), [mkleen](https://github.com/mkleen), [mzabaluev](https://github.com/mzabaluev), [neilconway](https://github.com/neilconway), [rluvaton](https://github.com/rluvaton), [sdf-jkl](https://github.com/sdf-jkl), [timsaucer](https://github.com/timsaucer), [xudong963](https://github.com/xudong963), [zhuqi-lucas](https://github.com/zhuqi-lucas).
---
[File an issue](https://github.com/adriangb/datafusion-benchmarking/issues) against this benchmark runner
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use Vec for primitive array unary operations [arrow-rs]
Posted by "kowanietz (via GitHub)" <gi...@apache.org>.
kowanietz commented on PR #10783:
URL: https://github.com/apache/arrow-rs/pull/10783#issuecomment-5371486080
Well, that's unfortunate.
Btw, in case the benchmark I added is out of scope, I'll remove it or move it to another PR :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use Vec for primitive array unary operations [arrow-rs]
Posted by "kowanietz (via GitHub)" <gi...@apache.org>.
kowanietz commented on PR #10783:
URL: https://github.com/apache/arrow-rs/pull/10783#issuecomment-5371466670
run benchmark take_kernels
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use Vec for primitive array unary operations [arrow-rs]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on PR #10783:
URL: https://github.com/apache/arrow-rs/pull/10783#issuecomment-5390909120
thanks @kowanietz & @Rich-T-kid
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use Vec for primitive array unary operations [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #10783:
URL: https://github.com/apache/arrow-rs/pull/10783#discussion_r3847343047
##########
arrow-array/src/array/primitive_array.rs:
##########
@@ -995,9 +995,8 @@ impl<T: ArrowPrimitiveType> PrimitiveArray<T> {
let len = self.len();
let nulls = self.nulls().cloned();
- let mut buffer = BufferBuilder::<O::Native>::new(len);
- buffer.append_n_zeroed(len);
- let slice = buffer.as_slice_mut();
+ let mut values = vec![O::Native::default(); len];
Review Comment:
🚀
love it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use Vec for primitive array unary operations [arrow-rs]
Posted by "adriangbot (via GitHub)" <gi...@apache.org>.
adriangbot commented on PR #10783:
URL: https://github.com/apache/arrow-rs/pull/10783#issuecomment-5374811970
🤖 Arrow criterion benchmark completed (GKE) | [trigger](https://github.com/apache/arrow-rs/pull/10783#issuecomment-5374780982)
**Instance:** `c4a-highmem-16` (12 vCPU / 65 GiB)
Comparing perf/primitive-array-vec (52b4cdd04a2261e53c0f8f3280c2f25ecee87606) to c837ee8 (merge-base) [diff](https://github.com/apache/arrow-rs/compare/c837ee83926e6c4f327405dcc220de3c7dd06b06..52b4cdd04a2261e53c0f8f3280c2f25ecee87606)
<details><summary>Run configuration</summary>
```yaml
run benchmark primitive_array
```
</details>
<details><summary>CPU Details (lscpu)</summary>
```
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>
**New benchmark — branch-only results (no baseline comparison)**
<details><summary>Details</summary>
<p>
```
group perf_primitive-array-vec
----- ------------------------
primitive_array_unary/try_unary/20pct_input_nulls 1.00 43.0±0.05µs ? ?/sec
primitive_array_unary/try_unary/no_input_nulls 1.00 5.0±0.01µs ? ?/sec
primitive_array_unary/unary_opt/20pct_input_nulls 1.00 48.6±0.28µs ? ?/sec
primitive_array_unary/unary_opt/no_input_nulls 1.00 39.3±0.14µs ? ?/sec
```
</p>
</details>
<details><summary>Resource Usage</summary>
**branch**
| Metric | Value |
|--------|-------|
| Wall time | 45.0s |
| Peak memory | 10.0 MiB |
| Avg memory | 6.1 MiB |
| CPU user | 39.9s |
| CPU sys | 0.0s |
| Peak spill | 0 B |
</details>
---
[File an issue](https://github.com/adriangb/datafusion-benchmarking/issues) against this benchmark runner
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use Vec for primitive array unary operations [arrow-rs]
Posted by "Rich-T-kid (via GitHub)" <gi...@apache.org>.
Rich-T-kid commented on PR #10783:
URL: https://github.com/apache/arrow-rs/pull/10783#issuecomment-5374780982
run benchmark primitive_array
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org