Skip to content

perf(parquet): Vectorize dict-index bounds check in RleDecoder::get_batch_with_dict (up to -7.9%)#9746

Open
Dandandan wants to merge 2 commits intoapache:mainfrom
Dandandan:rle-dict-max-reduction
Open

perf(parquet): Vectorize dict-index bounds check in RleDecoder::get_batch_with_dict (up to -7.9%)#9746
Dandandan wants to merge 2 commits intoapache:mainfrom
Dandandan:rle-dict-max-reduction

Conversation

@Dandandan
Copy link
Copy Markdown
Contributor

@Dandandan Dandandan commented Apr 16, 2026

Which issue does this PR close?

Close: #9747

Rationale for this change

Rewrite the code to generate more SIMD instructions / amortize loop/branching overhead.

What changes are included in this PR?

One-file change in parquet/src/encodings/rle.rs:

  • u32 max-reduction bounds check over CHUNK = 16 indices
  • #[cold] #[inline(never)] fn oob for the panic path
  • get_unchecked gather after the vectorised check
type main this-pr Δ
UInt64Array 60.6 ± 7.75 µs 55.8 ± 0.58 µs −7.9%
Int64Array 58.2 ± 0.77 µs 55.3 ± 0.34 µs −5.0%
INT32 Decimal128 88.5 ± 2.07 µs 84.3 ± 0.35 µs −4.7%
Int32Array 49.6 ± 0.47 µs 47.4 ± 0.50 µs −4.4%
UInt8Array 53.0 ± 0.42 µs 50.9 ± 0.60 µs −4.0%
Int16Array 53.6 ± 0.49 µs 51.7 ± 1.38 µs −3.6%
UInt16Array 53.2 ± 0.34 µs 51.7 ± 0.90 µs −2.8%
UInt32Array 49.7 ± 4.23 µs 48.4 ± 1.23 µs −2.6%
INT64 Decimal128 96.4 ± 2.10 µs 94.9 ± 1.47 µs −1.5%
Int8Array 53.2 ± 0.61 µs 52.8 ± 5.21 µs −0.7%

Are these changes tested?

Existing tests

Are there any user-facing changes?

No — no API change; decoded output is identical, panic behaviour on out-of-bounds indices is preserved.

🤖 Generated with Claude Code

@github-actions github-actions bot added the parquet Changes to the parquet crate label Apr 16, 2026
@Dandandan Dandandan force-pushed the rle-dict-max-reduction branch from b3b75e2 to b429fc1 Compare April 16, 2026 18:44
@Dandandan Dandandan marked this pull request as ready for review April 16, 2026 19:54
@github-actions github-actions bot added the arrow Changes to the arrow crate label Apr 16, 2026
@Dandandan Dandandan changed the title perf(parquet): vectorise dict-index bounds check in RleDecoder::get_batch_with_dict perf(parquet): vectorise dict-index bounds check in RleDecoder::get_batch_with_dict (-2-6%) Apr 16, 2026
@Dandandan
Copy link
Copy Markdown
Contributor Author

run benchmark arrow_reader_clickbench

@Dandandan Dandandan force-pushed the rle-dict-max-reduction branch from 0f17b76 to b429fc1 Compare April 16, 2026 19:58
@adriangbot
Copy link
Copy Markdown

🤖 Arrow criterion benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c4263000224-1400-f5cb4 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 rle-dict-max-reduction (b429fc1) to 89b1497 (merge-base) diff
BENCH_NAME=arrow_reader_clickbench
BENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental,object_store --bench arrow_reader_clickbench
BENCH_FILTER=
Results will be posted here when complete


File an issue against this benchmark runner

@github-actions github-actions bot removed the arrow Changes to the arrow crate label Apr 16, 2026
…batch_with_dict`

Replace `idx_chunk.iter().all(|&i| (i as usize) < dict_len)` with a
u32 max-reduction (`fold(0u32, |acc, &i| acc.max(i as u32))`). `.all`
short-circuits and so blocks autovectorisation; on aarch64 the old
form compiled to eight serialised `ldrsw` + `cmp` + `b.ls` pairs per
8-index chunk, followed by eight separate scalar gather loads.

The max-reduction has no early exit, so LLVM now lowers the check to
a single `ldp q1, q0` + `umax.4s` + `umaxv.4s` + one `cmp` + `b.ls`,
then reuses the loaded NEON registers for the gather that follows.
Negative `i32` values cast to `u32` become large, so the bounds
check still rejects them.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Dandandan Dandandan force-pushed the rle-dict-max-reduction branch from b429fc1 to ab6e019 Compare April 16, 2026 20:00
@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                                   rle-dict-max-reduction
-----                                             ----                                   ----------------------
arrow_reader_clickbench/async/Q1                  1.00   1097.9±4.61µs        ? ?/sec    1.00   1101.9±5.50µs        ? ?/sec
arrow_reader_clickbench/async/Q10                 1.01      6.7±0.16ms        ? ?/sec    1.00      6.6±0.19ms        ? ?/sec
arrow_reader_clickbench/async/Q11                 1.00      7.6±0.26ms        ? ?/sec    1.01      7.7±0.24ms        ? ?/sec
arrow_reader_clickbench/async/Q12                 1.00     14.4±0.29ms        ? ?/sec    1.02     14.8±0.31ms        ? ?/sec
arrow_reader_clickbench/async/Q13                 1.00     17.0±0.32ms        ? ?/sec    1.02     17.3±0.34ms        ? ?/sec
arrow_reader_clickbench/async/Q14                 1.00     16.1±0.25ms        ? ?/sec    1.02     16.5±0.33ms        ? ?/sec
arrow_reader_clickbench/async/Q19                 1.00      3.0±0.06ms        ? ?/sec    1.00      3.0±0.05ms        ? ?/sec
arrow_reader_clickbench/async/Q20                 1.00     72.9±0.45ms        ? ?/sec    1.22     89.2±1.05ms        ? ?/sec
arrow_reader_clickbench/async/Q21                 1.00     81.2±0.63ms        ? ?/sec    1.20    97.7±10.88ms        ? ?/sec
arrow_reader_clickbench/async/Q22                 1.08    128.7±6.49ms        ? ?/sec    1.00    119.4±4.59ms        ? ?/sec
arrow_reader_clickbench/async/Q23                 1.00    245.4±5.69ms        ? ?/sec    1.00    245.0±4.13ms        ? ?/sec
arrow_reader_clickbench/async/Q24                 1.00     19.5±0.38ms        ? ?/sec    1.01     19.7±0.45ms        ? ?/sec
arrow_reader_clickbench/async/Q27                 1.02     58.1±0.73ms        ? ?/sec    1.00     57.0±0.60ms        ? ?/sec
arrow_reader_clickbench/async/Q28                 1.00     58.0±0.60ms        ? ?/sec    1.00     58.2±0.64ms        ? ?/sec
arrow_reader_clickbench/async/Q30                 1.00     18.4±0.15ms        ? ?/sec    1.01     18.6±0.22ms        ? ?/sec
arrow_reader_clickbench/async/Q36                 1.05     15.6±0.67ms        ? ?/sec    1.00     15.0±0.40ms        ? ?/sec
arrow_reader_clickbench/async/Q37                 1.02      5.5±0.09ms        ? ?/sec    1.00      5.4±0.08ms        ? ?/sec
arrow_reader_clickbench/async/Q38                 1.04     13.9±0.39ms        ? ?/sec    1.00     13.4±0.30ms        ? ?/sec
arrow_reader_clickbench/async/Q39                 1.06     25.3±0.61ms        ? ?/sec    1.00     23.9±0.33ms        ? ?/sec
arrow_reader_clickbench/async/Q40                 1.00      5.6±0.10ms        ? ?/sec    1.04      5.9±0.04ms        ? ?/sec
arrow_reader_clickbench/async/Q41                 1.00      5.0±0.07ms        ? ?/sec    1.02      5.1±0.08ms        ? ?/sec
arrow_reader_clickbench/async/Q42                 1.00      3.5±0.05ms        ? ?/sec    1.00      3.5±0.03ms        ? ?/sec
arrow_reader_clickbench/async_object_store/Q1     1.00   1065.0±6.85µs        ? ?/sec    1.01   1070.4±4.59µs        ? ?/sec
arrow_reader_clickbench/async_object_store/Q10    1.00      6.4±0.22ms        ? ?/sec    1.01      6.5±0.22ms        ? ?/sec
arrow_reader_clickbench/async_object_store/Q11    1.00      7.4±0.24ms        ? ?/sec    1.00      7.4±0.24ms        ? ?/sec
arrow_reader_clickbench/async_object_store/Q12    1.00     14.3±0.28ms        ? ?/sec    1.04     14.8±0.27ms        ? ?/sec
arrow_reader_clickbench/async_object_store/Q13    1.01     17.3±0.09ms        ? ?/sec    1.00     17.1±0.40ms        ? ?/sec
arrow_reader_clickbench/async_object_store/Q14    1.00     15.8±0.36ms        ? ?/sec    1.02     16.1±0.33ms        ? ?/sec
arrow_reader_clickbench/async_object_store/Q19    1.00      2.9±0.03ms        ? ?/sec    1.00      2.9±0.04ms        ? ?/sec
arrow_reader_clickbench/async_object_store/Q20    1.01     71.8±0.77ms        ? ?/sec    1.00     71.3±0.51ms        ? ?/sec
arrow_reader_clickbench/async_object_store/Q21    1.01     80.6±0.63ms        ? ?/sec    1.00     80.1±0.58ms        ? ?/sec
arrow_reader_clickbench/async_object_store/Q22    1.00     98.1±0.88ms        ? ?/sec    1.00     98.4±1.01ms        ? ?/sec
arrow_reader_clickbench/async_object_store/Q23    1.10    232.6±5.63ms        ? ?/sec    1.00    211.5±1.80ms        ? ?/sec
arrow_reader_clickbench/async_object_store/Q24    1.00     19.3±0.40ms        ? ?/sec    1.01     19.4±0.42ms        ? ?/sec
arrow_reader_clickbench/async_object_store/Q27    1.01     57.4±0.75ms        ? ?/sec    1.00     56.7±0.52ms        ? ?/sec
arrow_reader_clickbench/async_object_store/Q28    1.00     57.4±0.66ms        ? ?/sec    1.01     57.7±0.64ms        ? ?/sec
arrow_reader_clickbench/async_object_store/Q30    1.00     18.1±0.16ms        ? ?/sec    1.01     18.3±0.28ms        ? ?/sec
arrow_reader_clickbench/async_object_store/Q36    1.02     15.0±0.63ms        ? ?/sec    1.00     14.7±0.52ms        ? ?/sec
arrow_reader_clickbench/async_object_store/Q37    1.01      5.3±0.08ms        ? ?/sec    1.00      5.3±0.08ms        ? ?/sec
arrow_reader_clickbench/async_object_store/Q38    1.04     13.5±0.54ms        ? ?/sec    1.00     13.0±0.40ms        ? ?/sec
arrow_reader_clickbench/async_object_store/Q39    1.02     24.2±0.61ms        ? ?/sec    1.00     23.7±0.44ms        ? ?/sec
arrow_reader_clickbench/async_object_store/Q40    1.00      5.5±0.11ms        ? ?/sec    1.03      5.7±0.04ms        ? ?/sec
arrow_reader_clickbench/async_object_store/Q41    1.00      4.7±0.07ms        ? ?/sec    1.02      4.8±0.08ms        ? ?/sec
arrow_reader_clickbench/async_object_store/Q42    1.00      3.4±0.05ms        ? ?/sec    1.00      3.4±0.03ms        ? ?/sec
arrow_reader_clickbench/sync/Q1                   1.00   876.4±29.39µs        ? ?/sec    1.01    883.5±4.41µs        ? ?/sec
arrow_reader_clickbench/sync/Q10                  1.00      5.1±0.08ms        ? ?/sec    1.00      5.1±0.06ms        ? ?/sec
arrow_reader_clickbench/sync/Q11                  1.00      6.0±0.09ms        ? ?/sec    1.01      6.0±0.08ms        ? ?/sec
arrow_reader_clickbench/sync/Q12                  1.00     21.8±0.45ms        ? ?/sec    1.02     22.3±0.23ms        ? ?/sec
arrow_reader_clickbench/sync/Q13                  1.06     30.0±0.80ms        ? ?/sec    1.00     28.4±0.77ms        ? ?/sec
arrow_reader_clickbench/sync/Q14                  1.00     22.9±0.19ms        ? ?/sec    1.03     23.6±0.37ms        ? ?/sec
arrow_reader_clickbench/sync/Q19                  1.00      2.7±0.06ms        ? ?/sec    1.00      2.7±0.04ms        ? ?/sec
arrow_reader_clickbench/sync/Q20                  1.00    123.5±0.99ms        ? ?/sec    1.00    123.0±0.98ms        ? ?/sec
arrow_reader_clickbench/sync/Q21                  1.01     93.0±0.65ms        ? ?/sec    1.00     92.6±0.69ms        ? ?/sec
arrow_reader_clickbench/sync/Q22                  1.00    136.7±1.00ms        ? ?/sec    1.06    145.5±3.40ms        ? ?/sec
arrow_reader_clickbench/sync/Q23                  1.00   278.1±14.59ms        ? ?/sec    1.01   279.8±15.08ms        ? ?/sec
arrow_reader_clickbench/sync/Q24                  1.00     27.1±0.43ms        ? ?/sec    1.01     27.4±0.54ms        ? ?/sec
arrow_reader_clickbench/sync/Q27                  1.03    109.5±0.89ms        ? ?/sec    1.00    106.3±0.79ms        ? ?/sec
arrow_reader_clickbench/sync/Q28                  1.01    105.8±0.71ms        ? ?/sec    1.00    104.9±0.79ms        ? ?/sec
arrow_reader_clickbench/sync/Q30                  1.00     18.6±0.22ms        ? ?/sec    1.01     18.8±0.26ms        ? ?/sec
arrow_reader_clickbench/sync/Q36                  1.01     22.9±0.07ms        ? ?/sec    1.00     22.6±0.06ms        ? ?/sec
arrow_reader_clickbench/sync/Q37                  1.00      6.9±0.08ms        ? ?/sec    1.00      6.9±0.07ms        ? ?/sec
arrow_reader_clickbench/sync/Q38                  1.01     11.6±0.14ms        ? ?/sec    1.00     11.5±0.09ms        ? ?/sec
arrow_reader_clickbench/sync/Q39                  1.02     21.4±0.37ms        ? ?/sec    1.00     20.9±0.32ms        ? ?/sec
arrow_reader_clickbench/sync/Q40                  1.00      5.1±0.10ms        ? ?/sec    1.00      5.1±0.10ms        ? ?/sec
arrow_reader_clickbench/sync/Q41                  1.00      5.6±0.07ms        ? ?/sec    1.01      5.7±0.07ms        ? ?/sec
arrow_reader_clickbench/sync/Q42                  1.00      4.4±0.06ms        ? ?/sec    1.00      4.4±0.06ms        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 780.1s
Peak memory 3.1 GiB
Avg memory 2.9 GiB
CPU user 707.7s
CPU sys 72.5s
Peak spill 0 B

branch

Metric Value
Wall time 782.5s
Peak memory 3.3 GiB
Avg memory 3.1 GiB
CPU user 710.7s
CPU sys 72.0s
Peak spill 0 B

File an issue against this benchmark runner

@Dandandan Dandandan changed the title perf(parquet): vectorise dict-index bounds check in RleDecoder::get_batch_with_dict (-2-6%) perf(parquet): Vectorize dict-index bounds check in RleDecoder::get_batch_with_dict (-2-6%) Apr 17, 2026
Follow-up to ab6e019. Two changes on the same RLE dict-gather loop:

- `CHUNK = 16` (was 8): lets LLVM widen the `umax.4s` + `umaxv.4s`
  reduction to cover the whole chunk with one vector max per pair of
  loads, keeping the ratio of (cheap) bounds check to (cheap) gather
  in the loop's favour.
- `#[cold] #[inline(never)] fn oob` replaces `assert!`: `max_idx` no
  longer has to stay live on the hot path for the panic format
  string, removing a per-chunk stack spill. Panic behaviour on
  out-of-bounds indices is preserved.

Measured on aarch64 (Apple Silicon) with
`cargo bench -p parquet --bench arrow_reader -- \
  "dictionary encoded, mandatory, no NULLs"`:

| bench                    | chunk 8 | chunk 16 + cold oob |       Δ |
| ------------------------ | ------- | ------------------- | ------- |
| BinaryViewArray          | 101 µs  | 88 µs               | -13.0% |
| StringViewArray          | 101 µs  | 88 µs               | -12.6% |
| INT64 Decimal128         |  98 µs  | 94 µs               |  -3.5% |
| INT32 Decimal128         |  87 µs  | 84 µs               |  -2.9% |
| UInt8Array               |  52 µs  | 51 µs               |  -1.8% |

View arrays see the biggest win because the inner copy is cheaper, so
the bounds check is a larger share of the loop.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Dandandan Dandandan changed the title perf(parquet): Vectorize dict-index bounds check in RleDecoder::get_batch_with_dict (-2-6%) perf(parquet): Vectorize dict-index bounds check in RleDecoder::get_batch_with_dict (up to 7.9%) Apr 17, 2026
@Dandandan Dandandan changed the title perf(parquet): Vectorize dict-index bounds check in RleDecoder::get_batch_with_dict (up to 7.9%) perf(parquet): Vectorize dict-index bounds check in RleDecoder::get_batch_with_dict (up to -7.9%) Apr 17, 2026
@Dandandan
Copy link
Copy Markdown
Contributor Author

run benchmarks

@adriangbot
Copy link
Copy Markdown

🤖 Benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c4266013757-1406-v4lfd 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 rle-dict-max-reduction (0ca4c50) to 89b1497 (merge-base) diff using:
Results will be posted here when complete


File an issue against this benchmark runner

@adriangbot
Copy link
Copy Markdown

Benchmark for this request failed.

Last 20 lines of output:

Click to expand
Cloning into '/workspace/datafusion-branch'...
rle-dict-max-reduction
From https://github.com/apache/arrow-rs
 * [new ref]         refs/pull/9746/head -> rle-dict-max-reduction
 * branch            main                -> FETCH_HEAD
Switched to branch 'rle-dict-max-reduction'
89b1497484115eeffe2daaf6be11193aa1054153
Cloning into '/workspace/datafusion-base'...
HEAD is now at 89b1497 Improve take performance on List arrays (#9643)
rustc 1.94.1 (e408947bf 2026-03-25)
0ca4c50121d761fbe7ae2115f55ef90aa4696413
89b1497484115eeffe2daaf6be11193aa1054153

File an issue against this benchmark runner

idx_chunk.iter().all(|&i| (i as usize) < dict_len),
"dictionary index out of bounds"
);
// u32 max-reduction instead of `.all(|&i| ..)`: `.all`
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.

Hm, this sounds familiar, I opened an issue about this missed optimization a while ago (rust-lang/rust#113789). The issue seems to still exist.

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.

Oof :)

I compared it now as well to .fold(true, |a, &i| a & ((i as u32) < dict_len_u32)), looks like computing the max-then-compare does also generate better code (and benchmarks) than compare-against-max:

  max-reduce:                                                                                                                                                                                                    
  ldp  q1, q0, [x13, #32]                                              
  ldp  q3, q2, [x13]                                                                                                                                                                                                                         
  umax.4s  v4, v2, v0                                                  
  umax.4s  v3, v3, v1                                                                                                                                                                                                                        
  umax.4s  v3, v3, v4
  umaxv.4s s3, v3                                                                                                                                                                                                                            
  fmov     w8, s3                                                      
  cmp      x21, x8                                                                                                                                                                                                                           
  b.ls     LBB2735_48
                                                                                                                                                                                                                                             
  AND-reduce : 
  ldp  q1, q0, [x8, #32]                                                                                                                                                                                                                     
  ldp  q3, q2, [x8]     
  cmhs.4s  v4, v2, v6                                                                                                                                                                                                                        
  cmhs.4s  v3, v3, v6                                                                                                                                                                                                                        
  uzp1.8h  v3, v3, v4
  cmhs.4s  v4, v1, v6                                                                                                                                                                                                                        
  cmhs.4s  v5, v0, v6                                                                                                                                                                                                                        
  uzp1.8h  v4, v4, v5
  uzp1.16b v3, v3, v4                                                                                                                                                                                                                        
  umaxv.16b b3, v3                                                     
  fmov     w14, s3                                                                                                                                                                                                                           
  tbnz     w14, #0, LBB2735_48

// check still rejects it.
let max_idx = idx_chunk.iter().fold(0u32, |acc, &i| acc.max(i as u32));
if (max_idx as usize) >= dict_len {
oob(max_idx, dict_len);
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.

We should probably also return an error here instead of panicking, since the panic can be triggered by input provided by a user.

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.

Now I remember there was a draft pr about improving the error handling (#9365), so this could also be done separately.

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.

Ah yeah we could just as well return an error, I agree :)

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.

If you do, please also check the rle dict_value around line 487 and link #9434, otherwise I can do that afterwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parquet Changes to the parquet crate performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vectorise dict-index bounds check

3 participants