Skip to content

Remove redundant benchmarks in cast_kernels#9789

Open
alamb wants to merge 1 commit intoapache:mainfrom
alamb:alamb/prune-cast-benchmarks
Open

Remove redundant benchmarks in cast_kernels#9789
alamb wants to merge 1 commit intoapache:mainfrom
alamb:alamb/prune-cast-benchmarks

Conversation

@alamb
Copy link
Copy Markdown
Contributor

@alamb alamb commented Apr 22, 2026

Which issue does this PR close?

Rationale for this change

#9729, added many new cases to cast_kernels but many of these are redundant and increase the benchmark runtime without providing proportional value in coverage.

This PR reduces the redundancy by:

  1. Keeps one representative benchmark for each major physical code path (e.g., i128 vs i256 storage).
  2. Removes redundant combinations of target types (e.g., casting decimal128 to every integer width when int64 is sufficient).
  3. Consolidating invalid/error path testing into a single representative case.
  4. Reducing the total number of benchmark cases from over 60 new additions to 10 high-value cases.

What changes are included in this PR?

  • Pruned redundant decimal-to-integer/float and string/float-to-decimal benchmarks in arrow/benches/cast_kernels.rs.
  • Added create_primitive_array_range helper to arrow/src/util/bench_util.rs

Compared to main before PR #9729, the following benchmarks will be new after my PR #9789 is merged:

  1. New Decimal Casting Benchmarks
    These cases cover the core performance paths for casting to and from decimals using representative physical storage types (i128 and i256):
  • cast string to decimal128(38, 3)
  • cast float64 to decimal128(32, 3)
  • cast invalid float64 to to decimal128(32, 3) (Error path testing)
  • cast decimal128 to float64
  • cast decimal128 to int64
  • cast decimal256 to float64
  • cast decimal256 to int64
  • cast decimal128 to decimal128 512 with lower scale (infallible) (specifically testing the fast path for infallible

Are these changes tested?

CI covers verification.

Are there any user-facing changes?

No.

@github-actions github-actions Bot added parquet Changes to the parquet crate arrow Changes to the arrow crate labels Apr 22, 2026
@alamb alamb force-pushed the alamb/prune-cast-benchmarks branch from 55fa12a to 580a1e1 Compare April 22, 2026 14:48
@github-actions github-actions Bot removed the parquet Changes to the parquet crate label Apr 22, 2026
@alamb alamb changed the title Prune redundant benchmarks in cast_kernels Remove redundant benchmarks in cast_kernels Apr 22, 2026
@alamb alamb changed the title Remove redundant benchmarks in cast_kernels Remove redundant benchmarks in cast_kernels Apr 22, 2026
@alamb
Copy link
Copy Markdown
Contributor Author

alamb commented Apr 22, 2026

run benchmark cast_kernels

@adriangbot
Copy link
Copy Markdown

🤖 Arrow criterion benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c4297853605-1756-pjl59 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 alamb/prune-cast-benchmarks (580a1e1) to 9a2b49c (merge-base) diff
BENCH_NAME=cast_kernels
BENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental,object_store --bench cast_kernels
BENCH_FILTER=
Results will be posted here when complete


File an issue against this benchmark runner

@alamb alamb marked this pull request as ready for review April 22, 2026 16:09
Copy link
Copy Markdown
Contributor

@scovich scovich left a comment

Choose a reason for hiding this comment

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

LGTM, always nice to see a PR that reduces code size 🎉

@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                                                              alamb_prune-cast-benchmarks            main
-----                                                              ---------------------------            ----
"cast decimal128 to float32"                                                                              1.00     27.3±0.01µs        ? ?/sec
"cast decimal128 to float64"                                       1.00     27.1±0.02µs        ? ?/sec    1.00     27.1±0.01µs        ? ?/sec
"cast decimal128 to int16"                                                                                1.00     52.9±0.66µs        ? ?/sec
"cast decimal128 to int32"                                                                                1.00     38.0±0.09µs        ? ?/sec
"cast decimal128 to int64"                                         1.01     36.9±0.07µs        ? ?/sec    1.00     36.4±0.09µs        ? ?/sec
"cast decimal128 to int8"                                                                                 1.00     51.4±0.57µs        ? ?/sec
"cast decimal128 to uint16"                                                                               1.00     54.3±0.70µs        ? ?/sec
"cast decimal128 to uint32"                                                                               1.00     36.0±0.08µs        ? ?/sec
"cast decimal128 to uint64"                                                                               1.00     35.1±0.20µs        ? ?/sec
"cast decimal128 to uint8"                                                                                1.00     49.8±0.42µs        ? ?/sec
"cast decimal256 to float32"                                                                              1.00     70.4±0.05µs        ? ?/sec
"cast decimal256 to float64"                                       1.00     68.3±0.06µs        ? ?/sec    1.00     68.5±0.03µs        ? ?/sec
"cast decimal256 to int16"                                                                                1.00    165.7±0.86µs        ? ?/sec
"cast decimal256 to int32"                                                                                1.00    144.4±0.17µs        ? ?/sec
"cast decimal256 to int64"                                         1.00    142.8±1.61µs        ? ?/sec    1.00    142.1±0.78µs        ? ?/sec
"cast decimal256 to int8"                                                                                 1.00    161.7±0.99µs        ? ?/sec
"cast decimal256 to uint16"                                                                               1.00    166.4±0.67µs        ? ?/sec
"cast decimal256 to uint32"                                                                               1.00    132.8±0.56µs        ? ?/sec
"cast decimal256 to uint64"                                                                               1.00    132.6±0.42µs        ? ?/sec
"cast decimal256 to uint8"                                                                                1.00    163.3±0.45µs        ? ?/sec
"cast decimal32 to float32"                                                                               1.00      6.8±0.00µs        ? ?/sec
"cast decimal32 to float64"                                                                               1.00      6.9±0.00µs        ? ?/sec
"cast decimal32 to int16"                                                                                 1.00     23.6±1.28µs        ? ?/sec
"cast decimal32 to int32"                                                                                 1.00     20.1±0.19µs        ? ?/sec
"cast decimal32 to int64"                                                                                 1.00     20.1±0.27µs        ? ?/sec
"cast decimal32 to int8"                                                                                  1.00     33.3±0.59µs        ? ?/sec
"cast decimal32 to uint16"                                                                                1.00     23.8±1.30µs        ? ?/sec
"cast decimal32 to uint32"                                                                                1.00     20.3±0.21µs        ? ?/sec
"cast decimal32 to uint64"                                                                                1.00     20.3±0.23µs        ? ?/sec
"cast decimal32 to uint8"                                                                                 1.00     35.7±0.57µs        ? ?/sec
"cast decimal64 to float32"                                                                               1.00      6.8±0.00µs        ? ?/sec
"cast decimal64 to float64"                                                                               1.00      6.8±0.00µs        ? ?/sec
"cast decimal64 to int16"                                                                                 1.00     33.9±0.33µs        ? ?/sec
"cast decimal64 to int32"                                                                                 1.00     26.4±0.07µs        ? ?/sec
"cast decimal64 to int64"                                                                                 1.00     26.5±0.08µs        ? ?/sec
"cast decimal64 to int8"                                                                                  1.00     34.2±0.25µs        ? ?/sec
"cast decimal64 to uint16"                                                                                1.00     34.4±0.25µs        ? ?/sec
"cast decimal64 to uint32"                                                                                1.00     26.2±0.08µs        ? ?/sec
"cast decimal64 to uint64"                                                                                1.00     25.8±0.05µs        ? ?/sec
"cast decimal64 to uint8"                                                                                 1.00     34.0±0.29µs        ? ?/sec
"cast float32 to decimal128(32, 3)"                                                                       1.00     33.7±0.25µs        ? ?/sec
"cast float32 to decimal256(76, 4)"                                                                       1.00    501.8±5.17µs        ? ?/sec
"cast float32 to decimal32(9, 2)"                                                                         1.00     20.7±0.99µs        ? ?/sec
"cast float32 to decimal64(18, 2"                                                                         1.00     22.3±1.28µs        ? ?/sec
"cast float64 to decimal128(32, 3)"                                1.01     32.1±0.36µs        ? ?/sec    1.00     32.0±0.46µs        ? ?/sec
"cast float64 to decimal256(76, 4)"                                                                       1.00    500.6±6.24µs        ? ?/sec
"cast float64 to decimal32(9, 2)"                                                                         1.00     21.2±1.32µs        ? ?/sec
"cast float64 to decimal64(18, 2"                                                                         1.00     21.5±0.60µs        ? ?/sec
"cast invalid float32 to decimal128(32, 3)"                                                               1.00     23.1±1.00µs        ? ?/sec
"cast invalid float32 to decimal256(76, 4)"                                                               1.00     39.9±0.61µs        ? ?/sec
"cast invalid float32 to decimal32(9, 2)"                                                                 1.00     23.4±2.59µs        ? ?/sec
"cast invalid float32 to decimal64(18, 2"                                                                 1.00     23.8±2.34µs        ? ?/sec
"cast invalid float64 to decimal32(9, 2)"                                                                 1.00     21.3±1.54µs        ? ?/sec
"cast invalid float64 to to decimal128(32, 3)"                     1.00     23.1±0.80µs        ? ?/sec    1.03     23.8±2.35µs        ? ?/sec
"cast invalid float64 to to decimal256(76, 4)"                                                            1.00     39.4±0.97µs        ? ?/sec
"cast invalid float64 to to decimal64(18, 2)"                                                             1.00     23.5±2.59µs        ? ?/sec
"cast invalid string to decimal128(38, 3)"                                                                1.00    712.6±0.73µs        ? ?/sec
"cast invalid string to decimal256(76, 4)"                                                                1.00    712.7±0.92µs        ? ?/sec
"cast invalid string to decimal32(9, 2)"                                                                  1.00    682.0±0.79µs        ? ?/sec
"cast invalid string to decimal64(18, 2)"                                                                 1.00    685.2±0.94µs        ? ?/sec
"cast string to decimal128(38, 3)"                                 1.00    645.5±0.62µs        ? ?/sec    1.00    642.5±0.56µs        ? ?/sec
"cast string to decimal256(76, 4)"                                                                        1.00    658.9±0.59µs        ? ?/sec
"cast string to decimal32(9, 2)"                                                                          1.00    792.0±0.30µs        ? ?/sec
"cast string to decimal64(18, 2)"                                                                         1.00    619.2±0.46µs        ? ?/sec
cast binary view to string                                         1.03     60.4±3.26µs        ? ?/sec    1.00     58.5±0.42µs        ? ?/sec
cast binary view to string view                                    1.02     65.4±0.27µs        ? ?/sec    1.00     64.0±1.21µs        ? ?/sec
cast binary view to wide string                                    1.00     58.7±0.45µs        ? ?/sec    1.01     59.4±0.74µs        ? ?/sec
cast date32 to date64 512                                          1.00    321.5±0.69ns        ? ?/sec    1.00    321.2±1.74ns        ? ?/sec
cast date64 to date32 512                                          1.02    411.8±0.69ns        ? ?/sec    1.00    403.2±2.10ns        ? ?/sec
cast decimal128 to decimal128 512                                  1.00      6.9±0.00µs        ? ?/sec    1.00      6.9±0.01µs        ? ?/sec
cast decimal128 to decimal128 512 lower precision                  1.00     13.5±0.04µs        ? ?/sec    1.08     14.5±0.04µs        ? ?/sec
cast decimal128 to decimal128 512 with lower scale (infallible)    1.01     46.1±0.06µs        ? ?/sec    1.00     45.8±0.05µs        ? ?/sec
cast decimal128 to decimal128 512 with same scale                  1.00     76.4±0.49ns        ? ?/sec    1.00     76.5±0.35ns        ? ?/sec
cast decimal128 to decimal256 512                                  1.00     26.3±0.05µs        ? ?/sec    1.00     26.2±0.02µs        ? ?/sec
cast decimal256 to decimal128 512                                  1.01    311.6±0.34µs        ? ?/sec    1.00    309.9±0.34µs        ? ?/sec
cast decimal256 to decimal256 512                                  1.00     82.0±0.12µs        ? ?/sec    1.00     82.1±0.07µs        ? ?/sec
cast decimal256 to decimal256 512 with same scale                  1.00     77.6±0.62ns        ? ?/sec    1.01     78.1±1.43ns        ? ?/sec
cast decimal32 to decimal32 512                                                                           1.00      8.6±0.01µs        ? ?/sec
cast decimal32 to decimal32 512 lower precision                                                           1.00     10.1±0.05µs        ? ?/sec
cast decimal32 to decimal64 512                                                                           1.00      3.4±0.01µs        ? ?/sec
cast decimal64 to decimal32 512                                                                           1.00     32.4±0.02µs        ? ?/sec
cast decimal64 to decimal64 512                                                                           1.00      3.5±0.07µs        ? ?/sec
cast dict to string view                                           1.00     40.5±1.49µs        ? ?/sec    1.01     40.9±1.68µs        ? ?/sec
cast f32 to string 512                                             1.01     11.8±0.06µs        ? ?/sec    1.00     11.6±0.04µs        ? ?/sec
cast f64 to string 512                                             1.00     15.4±0.04µs        ? ?/sec    1.00     15.4±0.04µs        ? ?/sec
cast float32 to int32 512                                          1.02  1403.4±11.20ns        ? ?/sec    1.00  1381.2±12.24ns        ? ?/sec
cast float64 to float32 512                                        1.04    713.8±2.08ns        ? ?/sec    1.00    683.1±5.42ns        ? ?/sec
cast float64 to uint64 512                                         1.05   1442.8±7.56ns        ? ?/sec    1.00   1378.0±5.13ns        ? ?/sec
cast i64 to string 512                                             1.01      8.9±0.06µs        ? ?/sec    1.00      8.8±0.04µs        ? ?/sec
cast int32 to float32 512                                          1.00    696.1±5.98ns        ? ?/sec    1.01    699.6±5.58ns        ? ?/sec
cast int32 to float64 512                                          1.00    689.1±2.51ns        ? ?/sec    1.05    720.9±4.84ns        ? ?/sec
cast int32 to int32 512                                            1.00    172.8±1.09ns        ? ?/sec    1.02    176.9±2.45ns        ? ?/sec
cast int32 to int64 512                                            1.00    677.1±4.80ns        ? ?/sec    1.05    712.5±4.91ns        ? ?/sec
cast int32 to uint32 512                                           1.01   1394.1±8.46ns        ? ?/sec    1.00   1385.3±7.36ns        ? ?/sec
cast int64 to int32 512                                            1.00   1497.0±3.30ns        ? ?/sec    1.00   1503.0±3.87ns        ? ?/sec
cast no runs of int32s to ree<int32>                               1.04     59.0±2.30µs        ? ?/sec    1.00     56.9±0.57µs        ? ?/sec
cast runs of 10 string to ree<int32>                               1.00      8.7±0.06µs        ? ?/sec    1.01      8.8±0.02µs        ? ?/sec
cast runs of 1000 int32s to ree<int32>                             1.00      3.4±0.01µs        ? ?/sec    1.00      3.4±0.01µs        ? ?/sec
cast string single run to ree<int32>                               1.00     27.3±0.02µs        ? ?/sec    1.00     27.4±0.02µs        ? ?/sec
cast string to binary view 512                                     1.00      2.3±0.02µs        ? ?/sec    1.01      2.3±0.03µs        ? ?/sec
cast string view to binary view                                    1.03     76.1±1.99ns        ? ?/sec    1.00     74.1±0.74ns        ? ?/sec
cast string view to dict                                           1.00    174.4±0.59µs        ? ?/sec    1.00    174.5±0.65µs        ? ?/sec
cast string view to string                                         1.00     44.7±2.30µs        ? ?/sec    1.00     44.6±2.44µs        ? ?/sec
cast string view to wide string                                    1.00     46.9±1.96µs        ? ?/sec    1.00     46.7±2.13µs        ? ?/sec
cast time32s to time32ms 512                                       1.00    138.7±0.64ns        ? ?/sec    1.00    138.7±1.74ns        ? ?/sec
cast time32s to time64us 512                                       1.00    322.0±0.57ns        ? ?/sec    1.00    321.5±1.70ns        ? ?/sec
cast time64ns to time32s 512                                       1.00    402.5±0.24ns        ? ?/sec    1.00    403.7±1.80ns        ? ?/sec
cast timestamp_ms to i64 512                                       1.02    255.6±3.15ns        ? ?/sec    1.00    251.3±0.79ns        ? ?/sec
cast timestamp_ms to timestamp_ns 512                              1.02   1864.9±1.47ns        ? ?/sec    1.00   1829.0±3.19ns        ? ?/sec
cast timestamp_ns to timestamp_s 512                               1.00    172.0±1.51ns        ? ?/sec    1.01    172.9±1.20ns        ? ?/sec
cast utf8 to date32 512                                            1.01      6.4±0.03µs        ? ?/sec    1.00      6.4±0.03µs        ? ?/sec
cast utf8 to date64 512                                            1.00     33.8±0.30µs        ? ?/sec    1.00     33.8±0.12µs        ? ?/sec
cast utf8 to f32                                                   1.01      5.6±0.03µs        ? ?/sec    1.00      5.6±0.03µs        ? ?/sec
cast wide string to binary view 512                                1.00      4.0±0.08µs        ? ?/sec    1.01      4.1±0.08µs        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 1135.3s
Peak memory 2.7 GiB
Avg memory 2.7 GiB
CPU user 1130.2s
CPU sys 0.8s
Peak spill 0 B

branch

Metric Value
Wall time 515.1s
Peak memory 2.7 GiB
Avg memory 2.7 GiB
CPU user 512.3s
CPU sys 0.2s
Peak spill 0 B

File an issue against this benchmark runner

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.

3 participants