You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "giladkl (via GitHub)" <gi...@apache.org> on 2026/08/14 19:21:29 UTC
[PR] Perf/byte view scalar eq [arrow-rs]
giladkl opened a new pull request, #10689:
URL: https://github.com/apache/arrow-rs/pull/10689
# Which issue does this PR close?
- Closes #10688
# Rationale for this change
col = 'x' / col <> '' over a Utf8View or BinaryView column is one of the hottest kernels in an analytical scan, and today it goes through the generic ArrayOrd path: each row is reached through a closure over an (array, index) pair, and settling it walks the full 128-bit view through a sequence of branches.
For a short constant almost none of that is needed. A constant of four bytes or fewer is described entirely by a view's low 64 bits, which hold the length and the first four bytes, so masking those and comparing them against the constant resolved once up front settles a row with a single narrow integer compare over the flat &[u128] view slice. That loop is branch-free and vectorizes.
# What changes are included in this PR?
- arrow-ord: an eq_inline_scalar helper, and a guard in compare_op that routes to it for Op::Equal / Op::NotEqual when one side is a scalar. Everything else falls through to the existing generic path untouched: dictionary and REE inputs, a null scalar (which the fast path's null handling cannot express), non-view types, and constants longer than four bytes.
- arrow: a stringview_scalar_eq benchmark group in comparison_kernels.rs sweeping three sizes, so the cache-resident and bandwidth-bound ends of the range are both visible.
Constants wider than four bytes are deliberately left alone. They need the whole 128-bit view, and comparing that measured slower than the generic path's early exit on a length mismatch (a six-byte constant regressed 11.8%), so the cap is a measured limit rather than an arbitrary one.
# Are these changes tested?
Yes. Three tests are added alongside the existing byte-view comparison tests:
- test_byte_view_eq_null_scalar — a null constant makes every row null, covering the shape the fast path declines.
- test_byte_view_eq_null_row — null rows in the values array stay null.
- test_byte_view_eq_scalar_either_side — the scalar on the left gives the same answer as on the right.
The existing arrow-ord suite (272 tests) passes unchanged.
Benchmark evidence, cargo bench --bench comparison_kernels -- stringview_scalar_eq on an Intel Xeon @ 2.80GHz (66 MiB L3):
┌───────────┬─────────┬─────────┬─────────┬────────┐
│ rows │ views │ before │ after │ change │
├───────────┼─────────┼─────────┼─────────┼────────┤
│ 65,536 │ 1 MiB │ 111.4us │ 47.7us │ -57.2% │
├───────────┼─────────┼─────────┼─────────┼────────┤
│ 1,048,576 │ 16 MiB │ 2.04ms │ 983.2us │ -51.7% │
├───────────┼─────────┼─────────┼─────────┼────────┤
│ 8,388,608 │ 128 MiB │ 19.71ms │ 14.85ms │ -24.7% │
└───────────┴─────────┴─────────┴─────────┴────────┘
The win narrows at the largest size, where the views no longer fit in cache and the kernel becomes bound by memory bandwidth rather than by the comparison.
# Are there any user-facing changes?
Nope :)
--
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] Speed up eq/neq of a byte-view array against a short scalar [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #10689:
URL: https://github.com/apache/arrow-rs/pull/10689#issuecomment-5332032762
show benchmark queue
--
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] Speed up eq/neq of a byte-view array against a short scalar [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #10689:
URL: https://github.com/apache/arrow-rs/pull/10689#issuecomment-5332034844
run benchmark comparison_kernels
```
env:
BENCH_FILTER: stringview
```
--
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] Speed up eq/neq of a byte-view array against a short scalar [arrow-rs]
Posted by "adriangbot (via GitHub)" <gi...@apache.org>.
adriangbot commented on PR #10689:
URL: https://github.com/apache/arrow-rs/pull/10689#issuecomment-5332098064
🤖 Arrow criterion benchmark completed (GKE) | [trigger](https://github.com/apache/arrow-rs/pull/10689#issuecomment-5332034844)
**Instance:** `c4a-highmem-16` (12 vCPU / 65 GiB)
Comparing perf/byte-view-scalar-eq (64171db290dd1926460ed804603c7ab62acb871c) to 7c306e4 (merge-base) [diff](https://github.com/apache/arrow-rs/compare/7c306e401c0f22a0c39f34989148c018af95ace8..64171db290dd1926460ed804603c7ab62acb871c)
<details><summary>Run configuration</summary>
```yaml
run benchmark comparison_kernels
env:
BENCH_FILTER: "stringview"
```
</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>
<details><summary>Details</summary>
<p>
```
group main perf_byte-view-scalar-eq
----- ---- ------------------------
stringview_scalar_eq/eq_scalar(rows=1048576) 2.50 1040.6±7.31µs 961.0 MElem/sec 1.00 416.5±8.88µs 2.3 GElem/sec
stringview_scalar_eq/eq_scalar(rows=65536) 2.53 60.4±0.40µs 1034.1 MElem/sec 1.00 23.9±0.05µs 2.6 GElem/sec
stringview_scalar_eq/eq_scalar(rows=8388608) 1.60 9.1±0.17ms 877.3 MElem/sec 1.00 5.7±0.04ms 1407.4 MElem/sec
```
</p>
</details>
<details><summary>Resource Usage</summary>
**base (merge-base)**
| Metric | Value |
|--------|-------|
| Wall time | 40.0s |
| Peak memory | 2.1 GiB |
| Avg memory | 1.5 GiB |
| CPU user | 34.4s |
| CPU sys | 0.5s |
| Peak spill | 0 B |
**branch**
| Metric | Value |
|--------|-------|
| Wall time | 40.0s |
| Peak memory | 2.1 GiB |
| Avg memory | 1.5 GiB |
| CPU user | 33.6s |
| CPU sys | 0.5s |
| 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] Speed up eq/neq of a byte-view array against a short scalar [arrow-rs]
Posted by "adriangbot (via GitHub)" <gi...@apache.org>.
adriangbot commented on PR #10689:
URL: https://github.com/apache/arrow-rs/pull/10689#issuecomment-5332033076
Hi @alamb, you asked to view the benchmark queue (https://github.com/apache/arrow-rs/pull/10689#issuecomment-5332032762).
No pending jobs.
---
[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] Speed up eq/neq of a byte-view array against a short scalar [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #10689:
URL: https://github.com/apache/arrow-rs/pull/10689#discussion_r3789228027
##########
arrow-ord/src/cmp.rs:
##########
@@ -274,6 +274,28 @@ fn compare_op(op: Op, lhs: &dyn Datum, rhs: &dyn Datum) -> Result<BooleanArray,
ree: r_ree_info.as_ref().map(|(_, info)| info),
};
+ // Equality against an inlined constant is a scan of fixed-width integers
Review Comment:
maybe you could also mention this is a special case for comparing short strings with the inlined prefix of a view 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
Re: [PR] Speed up eq/neq of a byte-view array against a short scalar [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #10689:
URL: https://github.com/apache/arrow-rs/pull/10689#issuecomment-5331473553
Merged up from main to get https://github.com/apache/arrow-rs/pull/10728
--
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] Optimizer Utf8View / ByteView comparison for short strings [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #10689:
URL: https://github.com/apache/arrow-rs/pull/10689#discussion_r3789222452
##########
arrow-ord/src/cmp.rs:
##########
@@ -370,6 +392,44 @@ impl SideInfo<'_> {
}
}
+/// Longest constant whose length and bytes both fit a view's low 64 bits
+const MAX_LOW_HALF_LEN: u32 = 4;
+
+/// Compares every value of a byte-view array against an inlined constant
+///
+/// `None` for any other shape, which the generic path below then handles.
Review Comment:
"returns None" ?
##########
arrow-ord/src/cmp.rs:
##########
@@ -370,6 +392,44 @@ impl SideInfo<'_> {
}
}
+/// Longest constant whose length and bytes both fit a view's low 64 bits
+const MAX_LOW_HALF_LEN: u32 = 4;
+
+/// Compares every value of a byte-view array against an inlined constant
Review Comment:
Maybe point out this attempts a special case with a shot constant
--
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] Speed up eq/neq of a byte-view array against a short scalar [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #10689:
URL: https://github.com/apache/arrow-rs/pull/10689#issuecomment-5331495601
run benchmark comparison_kernels
```
env:
BENCH_FILTER: stringview
```
--
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] Speed up eq/neq of a byte-view array against a short scalar [arrow-rs]
Posted by "adriangbot (via GitHub)" <gi...@apache.org>.
adriangbot commented on PR #10689:
URL: https://github.com/apache/arrow-rs/pull/10689#issuecomment-5332068929
🤖 Arrow criterion benchmark running (GKE) | [trigger](https://github.com/apache/arrow-rs/pull/10689#issuecomment-5332034844)
**Instance:** `c4a-highmem-16` (12 vCPU / 65 GiB) | `Linux bench-c5332034844-1659-qd5lp 6.12.85+ #1 SMP Wed Jun 17 20:31:55 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/byte-view-scalar-eq (64171db290dd1926460ed804603c7ab62acb871c) to 7c306e4 (merge-base) [diff](https://github.com/apache/arrow-rs/compare/7c306e401c0f22a0c39f34989148c018af95ace8..64171db290dd1926460ed804603c7ab62acb871c)
<details><summary>Run configuration</summary>
```yaml
run benchmark comparison_kernels
env:
BENCH_FILTER: "stringview"
```
</details>
BENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental,object_store --bench comparison_kernels
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] perf(arrow-cmp): Speed up eq/neq of a byte-view array against a short scalar [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #10689:
URL: https://github.com/apache/arrow-rs/pull/10689
--
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] Perf/byte view scalar eq [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #10689:
URL: https://github.com/apache/arrow-rs/pull/10689#discussion_r3789219465
##########
arrow/benches/comparison_kernels.rs:
##########
@@ -530,6 +530,23 @@ fn add_benchmark(c: &mut Criterion) {
b.iter(|| eq(&dict_arr_a, &dict_arr_b).unwrap())
});
+ // eq scalar benchmarks across sizes: 16 bytes of view a row, so the largest is bandwidth-bound
+
+ let mut group = c.benchmark_group("stringview_scalar_eq");
Review Comment:
Can you please add this benchmark as a separate PR so I can use our automated benchmarking scripts?
--
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] Speed up eq/neq of a byte-view array against a short scalar [arrow-rs]
Posted by "adriangbot (via GitHub)" <gi...@apache.org>.
adriangbot commented on PR #10689:
URL: https://github.com/apache/arrow-rs/pull/10689#issuecomment-5331547645
Benchmark for [this request](https://github.com/apache/arrow-rs/pull/10689#issuecomment-5331495601) failed before finishing (Kubernetes reason: `BackoffLimitExceeded`).
Benchmarks requested: `comparison_kernels`
<details><summary>Kubernetes message</summary>
```
Job has reached the specified backoff limit
```
</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] Speed up eq/neq of a byte-view array against a short scalar [arrow-rs]
Posted by "giladkl (via GitHub)" <gi...@apache.org>.
giladkl commented on PR #10689:
URL: https://github.com/apache/arrow-rs/pull/10689#issuecomment-5330024531
@alamb Split the bench into a different PR (#10728) and added a new commit with the docs changes :)
--
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] Speed up eq/neq of a byte-view array against a short scalar [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #10689:
URL: https://github.com/apache/arrow-rs/pull/10689#issuecomment-5332294347
<img width="937" height="165" alt="Screenshot 2026-08-18 at 2 20 03 PM" src="https://github.com/user-attachments/assets/958bc7c3-fd43-444a-9b5e-ae12d398be34" />
🚀
--
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] Speed up eq/neq of a byte-view array against a short scalar [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #10689:
URL: https://github.com/apache/arrow-rs/pull/10689#issuecomment-5301922475
I reviewed this code and it looks good and correct to me. I would just like to get some confirmation on the performance from our benchmark runner and then I think we cna merge it in. Thank you @giladkl
--
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