Skip to content

support suffix white space in arrow-cast parse#10396

Merged
alamb merged 11 commits into
apache:mainfrom
Rich-T-kid:rich-T-kid/support-suffix-white-space
Jul 25, 2026
Merged

support suffix white space in arrow-cast parse#10396
alamb merged 11 commits into
apache:mainfrom
Rich-T-kid:rich-T-kid/support-suffix-white-space

Conversation

@Rich-T-kid

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

What changes are included in this PR?

this PR adds support for suffix white space when calling parse

Are these changes tested?

yes

Are there any user-facing changes?

yes, users will be able to parse strings that have white space prefixed/suffixed onto numbers/floats.

@github-actions github-actions Bot added the arrow Changes to the arrow crate label Jul 20, 2026
@alamb

alamb commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

run benchmark cast_kernels
env:
BENCH_FILTER: utf8 to f32

@adriangbot

This comment has been minimized.

@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               main                                   rich-T-kid_support-suffix-white-space
-----               ----                                   -------------------------------------
cast utf8 to f32    1.00      5.6±0.03µs        ? ?/sec    1.12      6.3±0.02µs        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 15.0s
Peak memory 7.4 MiB
Avg memory 5.3 MiB
CPU user 10.7s
CPU sys 0.0s
Peak spill 0 B

branch

Metric Value
Wall time 10.0s
Peak memory 7.4 MiB
Avg memory 5.4 MiB
CPU user 7.0s
CPU sys 0.0s
Peak spill 0 B

File an issue against this benchmark runner

@alamb

alamb commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

🤔 it seems to be slower

@alamb

alamb commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

run benchmark cast_kernels
env:
BENCH_FILTER: utf8 to f32

1 similar comment
@alamb

alamb commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

run benchmark cast_kernels
env:
BENCH_FILTER: utf8 to f32

@adriangbot

This comment has been minimized.

@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               main                                   rich-T-kid_support-suffix-white-space
-----               ----                                   -------------------------------------
cast utf8 to f32    1.00      5.6±0.03µs        ? ?/sec    1.12      6.3±0.03µs        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 15.0s
Peak memory 7.3 MiB
Avg memory 5.3 MiB
CPU user 10.8s
CPU sys 0.0s
Peak spill 0 B

branch

Metric Value
Wall time 10.0s
Peak memory 7.4 MiB
Avg memory 5.4 MiB
CPU user 7.0s
CPU sys 0.0s
Peak spill 0 B

File an issue against this benchmark runner

@adriangbot

This comment has been minimized.

@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               main                                   rich-T-kid_support-suffix-white-space
-----               ----                                   -------------------------------------
cast utf8 to f32    1.00      5.7±0.03µs        ? ?/sec    1.12      6.3±0.03µs        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 15.0s
Peak memory 7.4 MiB
Avg memory 5.3 MiB
CPU user 10.7s
CPU sys 0.0s
Peak spill 0 B

branch

Metric Value
Wall time 10.0s
Peak memory 7.4 MiB
Avg memory 5.3 MiB
CPU user 7.0s
CPU sys 0.0s
Peak spill 0 B

File an issue against this benchmark runner

@Rich-T-kid

Copy link
Copy Markdown
Contributor Author

yea its consistently slower

🤔 for the case where there is no white space we do three comparissions (1 for the prefix, 1 for the suffix, 1 for the suffix again)

@Jefffrey

Copy link
Copy Markdown
Contributor

run benchmark cast_kernels
env:
BENCH_FILTER: utf8 to f32

@adriangbot

This comment was marked as duplicate.

@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark completed (GKE) | trigger

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

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               main                                   rich-T-kid_support-suffix-white-space
-----               ----                                   -------------------------------------
cast utf8 to f32    1.00      5.6±0.03µs        ? ?/sec    1.13      6.4±0.02µs        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 15.0s
Peak memory 7.4 MiB
Avg memory 5.3 MiB
CPU user 10.6s
CPU sys 0.0s
Peak spill 0 B

branch

Metric Value
Wall time 10.0s
Peak memory 7.4 MiB
Avg memory 5.4 MiB
CPU user 7.0s
CPU sys 0.0s
Peak spill 0 B

File an issue against this benchmark runner

@Rich-T-kid

Copy link
Copy Markdown
Contributor Author

I don't think theres a way to avoid the extra checks white-spase stripping requires. Even when there is no extra space, this pr adds a prefix check, a suffix check and another suffix check just to do nothing else.

we could add a conditional compilation attribute but that may be overkill.

@Jefffrey

Copy link
Copy Markdown
Contributor

im just curious how the previous PR seemed to suggest 0 regressions, meanwhile adding one more causes a noticeable bump

though we are at the single digit microsecond scale

@Rich-T-kid

Rich-T-kid commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

im just curious how the previous PR seemed to suggest 0 regressions, meanwhile adding one more causes a noticeable bump

though we are at the single digit microsecond scale

@Jefffrey i am as-well. I think it has to do with the number of checks.

In the previous PR, we only added three comparisons:

  1. Check if the byte slice is empty (is_some_and())
  2. Check if the first byte is ASCII (range check matches!(*self, '0'..='9'))
  3. Based on the result of comparison #/2, decide whether to call trim_ascii()

this PR has those exact same checks but twice and we also have two exta comparissions for the
match (prefix,suffix){} statment as well.

so about 8 extra comparisons. we could add something like std::hint::cold_path() but I'm not sure if adding 8 micro seconds is super important here. ideally there would be no regression but we need each of the 8 comparisons

@Rich-T-kid

Rich-T-kid commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

mabey?

#[inline]
fn trim_pre_and_post_whitespace(string: &str) -> &str {
    let bytes = string.as_bytes();
    let prefix = bytes.first().is_some_and(|b| !b.is_ascii_digit());
    let suffix = bytes.last().is_some_and(|b| !b.is_ascii_digit());
    match (prefix, suffix) {
        (false, false) => string,
        (true, false) => {
            cold_path();
            string.trim_ascii_start()
        }
        (false, true) => {
            cold_path();
            string.trim_ascii_end()
        }
        (true, true) => {
            cold_path();
            string.trim_ascii()
        }
    }
}

this looks a bit clunky to me

@Jefffrey

Copy link
Copy Markdown
Contributor

something silly we could do is always assume the best case and have the worst case (need to trim) as a fallback

impl Parser for Float32Type {
    fn parse(string: &str) -> Option<f32> {
        if let Ok(n) = lexical_core::parse(string.as_bytes()) {
            Some(n)
        } else {
            let string = string.trim_ascii();
            lexical_core::parse(string.as_bytes()).ok()
        }
    }
}

since the benchmarks are testing the casting of arrays themselves (and not just a microbenchmark of this parse function) i think it would be good to aim for a way to avoid regressions if possible 🤔

that being said, its worth noting our benchmark only checks f32, and tests arrays of fixed 512 length, so its not like the suite is comprehensive to the changes being made here

@Rich-T-kid

Copy link
Copy Markdown
Contributor Author

something silly we could do is always assume the best case and have the worst case (need to trim) as a fallback

makes sense to me. Could we run the benchmarks again

@Jefffrey

Copy link
Copy Markdown
Contributor

run benchmark cast_kernels
env:
BENCH_FILTER: utf8 to f32

@adriangbot

This comment was marked as duplicate.

@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark completed (GKE) | trigger

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

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               main                                   rich-T-kid_support-suffix-white-space
-----               ----                                   -------------------------------------
cast utf8 to f32    1.01      5.7±0.06µs        ? ?/sec    1.00      5.6±0.03µs        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 10.0s
Peak memory 7.4 MiB
Avg memory 5.7 MiB
CPU user 7.8s
CPU sys 0.0s
Peak spill 0 B

branch

Metric Value
Wall time 15.0s
Peak memory 7.4 MiB
Avg memory 5.1 MiB
CPU user 10.0s
CPU sys 0.0s
Peak spill 0 B

File an issue against this benchmark runner

@Jefffrey

Copy link
Copy Markdown
Contributor

run benchmark cast_kernels
env:
BENCH_FILTER: utf8 to f32

@adriangbot

This comment was marked as duplicate.

@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark completed (GKE) | trigger

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

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               main                                   rich-T-kid_support-suffix-white-space
-----               ----                                   -------------------------------------
cast utf8 to f32    1.02      5.8±0.10µs        ? ?/sec    1.00      5.7±0.03µs        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 10.0s
Peak memory 7.4 MiB
Avg memory 5.7 MiB
CPU user 7.8s
CPU sys 0.0s
Peak spill 0 B

branch

Metric Value
Wall time 15.0s
Peak memory 7.3 MiB
Avg memory 5.1 MiB
CPU user 10.0s
CPU sys 0.0s
Peak spill 0 B

File an issue against this benchmark runner

@Rich-T-kid

Copy link
Copy Markdown
Contributor Author

cast utf8 to f32 1.02 5.8±0.10µs ? ?/sec 1.00 5.7±0.03µs ? ?/sec

nice

Comment thread arrow-cast/src/parse.rs
Comment thread arrow-cast/src/parse.rs
fn parse(mut string: &str) -> Option<Self::Native> {
if !string.as_bytes().last().is_some_and(|x| x.is_ascii_digit()) {
return None;
fn parse(string: &str) -> Option<Self::Native> {

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.

perhaps we can add one benchmark for i32 just so we have a reference

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.

added those here #10421

@Rich-T-kid Rich-T-kid mentioned this pull request Jul 24, 2026
Jefffrey pushed a commit that referenced this pull request Jul 24, 2026
# 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.
-->

- none.

# Rationale for this change
see #10396 (comment)
<!--
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.
-->

# What changes are included in this PR?
adds benchmarks for str -> i32
<!--
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.
-->

# Are these changes tested?
n/a
<!--
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.
-->

# 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
@Jefffrey

Copy link
Copy Markdown
Contributor

run benchmark cast_kernels
env:
BENCH_FILTER: utf8 to i32

@adriangbot

This comment was marked as duplicate.

@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark completed (GKE) | trigger

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

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               main                                   rich-T-kid_support-suffix-white-space
-----               ----                                   -------------------------------------
cast utf8 to i32    1.01      5.2±0.03µs        ? ?/sec    1.00      5.1±0.04µs        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 15.0s
Peak memory 12.0 MiB
Avg memory 5.6 MiB
CPU user 10.6s
CPU sys 0.0s
Peak spill 0 B

branch

Metric Value
Wall time 15.0s
Peak memory 7.6 MiB
Avg memory 4.7 MiB
CPU user 9.0s
CPU sys 0.0s
Peak spill 0 B

File an issue against this benchmark runner

@alamb

alamb commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

@alamb alamb left a comment

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.

Thank you @Rich-T-kid and @Jefffrey

Comment thread arrow-cast/src/parse.rs
if let Ok(raw_float) = lexical_core::parse(string.as_bytes()) {
return Some(f16::from_f32(raw_float));
}
let string = trim_pre_and_post_whitespace(string);

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.

this is a good strategy -- try the common/ fast path first and then fallback to checking whitespace afterwards

@alamb
alamb merged commit cd47d4a into apache:main Jul 25, 2026
30 checks passed
@alamb

alamb commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

🚀

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.

arrow-cast numeric parsers fail to parse whitespace-padded strings

4 participants