You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "Jefffrey (via GitHub)" <gi...@apache.org> on 2026/07/01 14:00:24 UTC
[PR] Validate short view strings in separate buffer in arrow-row [arrow-rs]
Jefffrey opened a new pull request, #10250:
URL: https://github.com/apache/arrow-rs/pull/10250
# Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax.
-->
- Closes #6057
# Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
Reduce output string view values buffer size when decoding from row format & validating utf8
# What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
Introduce separate vec to append inline short strings to for one shot utf8 validation; previously we mixed short + long strings in the values buffer for ease of utf8 validation, but this means the output view array has more memory usage than strictly required.
# Are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
If this PR claims a performance improvement, please include evidence such as benchmark results.
-->
Existing tests.
# Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
If there are any breaking changes to public APIs, please call them out.
-->
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] Validate short view strings in separate buffer in arrow-row [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #10250:
URL: https://github.com/apache/arrow-rs/pull/10250#discussion_r3509192249
##########
arrow-row/src/variable.rs:
##########
@@ -309,42 +309,40 @@ pub fn decode_binary<I: OffsetSizeTrait>(
}
}
-fn decode_binary_view_inner(
+fn decode_binary_view_inner<const VALIDATE_UTF8: bool>(
rows: &mut [&[u8]],
options: SortOptions,
- validate_utf8: bool,
) -> BinaryViewArray {
let len = rows.len();
let inline_str_max_len = MAX_INLINE_VIEW_LEN as usize;
let nulls = decode_nulls_sentinel(rows, options);
- // If we are validating UTF-8, decode all string values (including short strings)
- // into the values buffer and validate UTF-8 once. If not validating,
- // we save memory by only copying long strings to the values buffer, as short strings
- // will be inlined into the view and do not need to be stored redundantly.
- let values_capacity = if validate_utf8 {
- // Capacity for all long and short strings
- rows.iter().map(|row| decoded_len(row, options)).sum()
+ // Capacity for all long strings plus room for one short string
+ let mut values_capacity = inline_str_max_len;
+ let mut inline_capacity = 0;
+ for row in rows.iter() {
+ let len = decoded_len(row, options);
+ if len > inline_str_max_len {
+ values_capacity += len;
+ } else if VALIDATE_UTF8 {
+ inline_capacity += len;
+ }
+ }
+ let mut values = MutableBuffer::new(values_capacity);
+ let mut view_utf8_validation_buffer = if VALIDATE_UTF8 {
+ Vec::with_capacity(inline_capacity)
Review Comment:
so this is a new allocation, but given the benchmark it seems to be more than paid for with the additional performance
##########
arrow-row/src/lib.rs:
##########
@@ -4819,66 +4819,6 @@ mod tests {
}
}
- #[test]
- fn test_values_buffer_smaller_when_utf8_validation_disabled() {
Review Comment:
maybe it is worth updating this test to verify that when utf8 validation is enabled, the values only contain data for the long strings (not the short strings(
--
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] Validate short view strings in separate buffer in arrow-row [arrow-rs]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on code in PR #10250:
URL: https://github.com/apache/arrow-rs/pull/10250#discussion_r3506542760
##########
arrow-row/src/variable.rs:
##########
@@ -309,42 +309,40 @@ pub fn decode_binary<I: OffsetSizeTrait>(
}
}
-fn decode_binary_view_inner(
+fn decode_binary_view_inner<const VALIDATE_UTF8: bool>(
Review Comment:
decided to take this opportunity to hoist the validate_utf8 option into a generic since it was used in the hot loop
--
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] Validate short view strings in separate buffer in arrow-row [arrow-rs]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on PR #10250:
URL: https://github.com/apache/arrow-rs/pull/10250#issuecomment-4855871093
run benchmark row_format
env:
BENCH_FILTER: convert_rows.*string\sview
--
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] Validate short view strings in separate buffer in arrow-row [arrow-rs]
Posted by "adriangbot (via GitHub)" <gi...@apache.org>.
adriangbot commented on PR #10250:
URL: https://github.com/apache/arrow-rs/pull/10250#issuecomment-4855948734
🤖 Arrow criterion benchmark completed (GKE) | [trigger](https://github.com/apache/arrow-rs/pull/10250#issuecomment-4855871093)
**Instance:** `c4a-highmem-16` (12 vCPU / 65 GiB)
<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 row-short-utf8-validation
----- ---- -------------------------
convert_rows 4096 string view(1..100, 0) 1.01 79.1±0.34µs ? ?/sec 1.00 78.1±0.30µs ? ?/sec
convert_rows 4096 string view(1..100, 0.5) 1.02 69.1±0.38µs ? ?/sec 1.00 67.7±0.42µs ? ?/sec
convert_rows 4096 string view(10, 0) 1.00 43.2±0.07µs ? ?/sec 1.00 43.1±0.06µs ? ?/sec
convert_rows 4096 string view(100, 0) 1.02 96.6±0.18µs ? ?/sec 1.00 94.8±0.07µs ? ?/sec
convert_rows 4096 string view(100, 0.5) 1.02 61.9±0.13µs ? ?/sec 1.00 60.8±0.16µs ? ?/sec
convert_rows 4096 string view(30, 0) 1.00 58.1±0.07µs ? ?/sec 1.00 58.1±0.04µs ? ?/sec
```
</p>
</details>
<details><summary>Resource Usage</summary>
**base (merge-base)**
| Metric | Value |
|--------|-------|
| Wall time | 65.0s |
| Peak memory | 9.3 MiB |
| Avg memory | 7.4 MiB |
| CPU user | 58.6s |
| CPU sys | 0.0s |
| Peak spill | 0 B |
**branch**
| Metric | Value |
|--------|-------|
| Wall time | 60.0s |
| Peak memory | 12.4 MiB |
| Avg memory | 7.9 MiB |
| CPU user | 57.1s |
| 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] Validate short view strings in separate buffer in arrow-row [arrow-rs]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey merged PR #10250:
URL: https://github.com/apache/arrow-rs/pull/10250
--
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] Validate short view strings in separate buffer in arrow-row [arrow-rs]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on PR #10250:
URL: https://github.com/apache/arrow-rs/pull/10250#issuecomment-4884307810
thanks @alamb
--
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] Validate short view strings in separate buffer in arrow-row [arrow-rs]
Posted by "adriangbot (via GitHub)" <gi...@apache.org>.
adriangbot commented on PR #10250:
URL: https://github.com/apache/arrow-rs/pull/10250#issuecomment-4855905817
🤖 Arrow criterion benchmark running (GKE) | [trigger](https://github.com/apache/arrow-rs/pull/10250#issuecomment-4855871093)
**Instance:** `c4a-highmem-16` (12 vCPU / 65 GiB) | `Linux bench-c4855871093-774-psktj 6.12.85+ #1 SMP Mon May 11 08:17:35 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 row-short-utf8-validation (23069fd138fa142f6e05be38ff4fcab0d0a326bd) to fbe75a3 (merge-base) [diff](https://github.com/apache/arrow-rs/compare/fbe75a3bd9df6d66658e2954e14163e5a93a4187..23069fd138fa142f6e05be38ff4fcab0d0a326bd)
BENCH_NAME=row_format
BENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental,object_store --bench row_format
BENCH_FILTER=convert_rows.*string\sview
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