Skip to content

Optimize indexed copying for dictionary arrays - #12306

Merged
Rich-T-kid merged 7 commits into
apache:mainfrom
Rich-T-kid:codex/issue-11940
Nov 19, 2026
Merged

Rich-T-kid merged 7 commits into
apache:mainfrom
Rich-T-kid:codex/issue-11940

Conversation

@Rich-T-kid

@Rich-T-kid Rich-T-kid commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Sparse indexed copies of byte dictionaries currently materialize a new dictionary array before coalescing it. This adds avoidable work and prevents the coalescer from reusing the dictionary values array directly.

What changes are included in this PR?

Implement copy_rows_by_indices for dictionaries with Utf8, LargeUtf8, Binary, and LargeBinary values. Sparse selections gather keys directly and retain the source values arrays for remapping when the batch is finished; denser selections continue to use the existing take fallback.

Are these changes tested?

Yes. Unit tests cover sparse indexed copies with sliced and null keys, repeated and out-of-order indices, the dense fallback, values-array reuse, and remapping across multiple dictionaries with different value orderings.

The final implementation was benchmarked across shared and changing dictionary values, four selectivities, and nullable/non-null inputs:

Architecture Result
AMD64 All 16 cases improved or tied, with sparse cases up to 2.28x faster
ARM64 Sparse cases improved by up to 2.57x; changing-values dense cases were approximately 1-2% slower

Are there any significant user-facing changes?

No public API changes.

@boring-cyborg boring-cyborg Bot added the arrow-kernels Crates that transform arrow data (e.g. compute, cast) label Nov 17, 2026
@Rich-T-kid

Copy link
Copy Markdown
Contributor Author

run benchmark coalesce_kernels
env:
BENCH_FILTER: "filter: single_dict"
resources:
arch: arm64

@Rich-T-kid

Copy link
Copy Markdown
Contributor Author

run benchmark coalesce_kernels
env:
BENCH_FILTER: "filter: single_dict"
resources:
arch: amd64

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark starting (GKE) | trigger

Target: coalesce_kernels

Sharding factor: 1 (1 workers).

Comparing codex/issue-11940 (39dae89) to a6c6848 (merge-base) diff

Run configuration
run benchmark coalesce_kernels
env:
  BENCH_FILTER: 'filter: single_dict'
resources:
  arch: arm64
shards: 1

Results will be posted when all workers finish.


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark starting (GKE) | trigger

Target: coalesce_kernels

Sharding factor: 1 (1 workers).

Comparing codex/issue-11940 (39dae89) to a6c6848 (merge-base) diff

Run configuration
run benchmark coalesce_kernels
env:
  BENCH_FILTER: 'filter: single_dict'
resources:
  arch: amd64
shards: 1

Results will be posted when all workers finish.


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

Target: coalesce_kernels

Comparing codex/issue-11940 (39dae89) to a6c6848 (merge-base) diff

Run configuration
run benchmark coalesce_kernels
env:
  BENCH_FILTER: 'filter: single_dict'
resources:
  arch: arm64
shards: 1
Details
group                                                        base                                   changed
-----                                                        ----                                   -------
filter: single_dict, 8192, nulls: 0, selectivity: 0.001      1.00     23.8±0.17ms        ? ?/sec    1.00     23.8±0.21ms        ? ?/sec
filter: single_dict, 8192, nulls: 0, selectivity: 0.005      1.02      4.9±0.03ms        ? ?/sec    1.00      4.8±0.02ms        ? ?/sec
filter: single_dict, 8192, nulls: 0, selectivity: 0.01       1.03      2.8±0.01ms        ? ?/sec    1.00      2.7±0.01ms        ? ?/sec
filter: single_dict, 8192, nulls: 0, selectivity: 0.1        1.03      2.9±0.01ms        ? ?/sec    1.00      2.9±0.01ms        ? ?/sec
filter: single_dict, 8192, nulls: 0, selectivity: 0.8        1.00      2.0±0.02ms        ? ?/sec    1.01      2.0±0.03ms        ? ?/sec
filter: single_dict, 8192, nulls: 0.1, selectivity: 0.001    1.00     31.0±0.23ms        ? ?/sec    1.00     31.1±0.20ms        ? ?/sec
filter: single_dict, 8192, nulls: 0.1, selectivity: 0.005    1.00      6.6±0.03ms        ? ?/sec    1.01      6.6±0.03ms        ? ?/sec
filter: single_dict, 8192, nulls: 0.1, selectivity: 0.01     1.00      3.7±0.02ms        ? ?/sec    1.00      3.7±0.02ms        ? ?/sec
filter: single_dict, 8192, nulls: 0.1, selectivity: 0.1      1.02      3.1±0.02ms        ? ?/sec    1.00      3.0±0.01ms        ? ?/sec
filter: single_dict, 8192, nulls: 0.1, selectivity: 0.8      1.01      2.2±0.01ms        ? ?/sec    1.00      2.2±0.00ms        ? ?/sec

Per-runner information
coalesce_kernels — shard 1/1

Node: gk3-benchmark-cluster-nap-1qxqoun0-a299a55e-w76w

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

uname:

Linux bench-c6959399979-5370-v46xl 6.12.105+ #1 SMP Sat Sep 19 07:55:25 UTC 2026 aarch64 GNU/Linux

BENCH_COMMAND:

cargo bench --features=arrow,async,test_common,experimental,object_store --bench coalesce_kernels
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
Resource Usage

base (merge-base)

Metric Value
Wall time 110.0s
Peak memory 28.4 MiB
Avg memory 14.4 MiB
CPU user 107.6s
CPU sys 0.2s
Peak spill 0 B

branch

Metric Value
Wall time 110.0s
Peak memory 23.2 MiB
Avg memory 13.8 MiB
CPU user 105.9s
CPU sys 0.2s
Peak spill 0 B

File an issue against this benchmark runner

@Rich-T-kid
Rich-T-kid marked this pull request as draft November 17, 2026 20:11
@adriangbot

Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

Target: coalesce_kernels

Comparing codex/issue-11940 (39dae89) to a6c6848 (merge-base) diff

Run configuration
run benchmark coalesce_kernels
env:
  BENCH_FILTER: 'filter: single_dict'
resources:
  arch: amd64
shards: 1
Details
group                                                        base                                   changed
-----                                                        ----                                   -------
filter: single_dict, 8192, nulls: 0, selectivity: 0.001      1.00     20.3±0.73ms        ? ?/sec    1.00     20.4±0.68ms        ? ?/sec
filter: single_dict, 8192, nulls: 0, selectivity: 0.005      1.00      4.3±0.14ms        ? ?/sec    1.05      4.5±0.12ms        ? ?/sec
filter: single_dict, 8192, nulls: 0, selectivity: 0.01       1.00      2.5±0.07ms        ? ?/sec    1.03      2.6±0.06ms        ? ?/sec
filter: single_dict, 8192, nulls: 0, selectivity: 0.1        1.00      2.6±0.10ms        ? ?/sec    1.12      2.9±0.04ms        ? ?/sec
filter: single_dict, 8192, nulls: 0, selectivity: 0.8        1.04  1725.9±33.57µs        ? ?/sec    1.00  1661.1±39.90µs        ? ?/sec
filter: single_dict, 8192, nulls: 0.1, selectivity: 0.001    1.04     30.9±0.71ms        ? ?/sec    1.00     29.8±0.67ms        ? ?/sec
filter: single_dict, 8192, nulls: 0.1, selectivity: 0.005    1.02      6.7±0.19ms        ? ?/sec    1.00      6.5±0.20ms        ? ?/sec
filter: single_dict, 8192, nulls: 0.1, selectivity: 0.01     1.04      3.8±0.10ms        ? ?/sec    1.00      3.7±0.08ms        ? ?/sec
filter: single_dict, 8192, nulls: 0.1, selectivity: 0.1      1.01      2.8±0.09ms        ? ?/sec    1.00      2.8±0.05ms        ? ?/sec
filter: single_dict, 8192, nulls: 0.1, selectivity: 0.8      1.04      2.1±0.05ms        ? ?/sec    1.00  1971.3±36.18µs        ? ?/sec

Per-runner information
coalesce_kernels — shard 1/1

Node: gk3-benchmark-cluster-nap-1bscwilp-afd69fe1-4lr8

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

uname:

Linux bench-c6959400033-5371-4szcl 6.12.105+ #1 SMP Sat Sep 19 07:57:03 UTC 2026 x86_64 GNU/Linux

BENCH_COMMAND:

cargo bench --features=arrow,async,test_common,experimental,object_store --bench coalesce_kernels
CPU Details (lscpu)
Architecture:                            x86_64
CPU op-mode(s):                          32-bit, 64-bit
Address sizes:                           52 bits physical, 57 bits virtual
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               GenuineIntel
Model name:                              INTEL(R) XEON(R) PLATINUM 8581C CPU @ 2.30GHz
CPU family:                              6
Model:                                   207
Thread(s) per core:                      2
Core(s) per socket:                      8
Socket(s):                               1
Stepping:                                2
BogoMIPS:                                4600.00
Flags:                                   fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves avx_vnni avx512_bf16 wbnoinvd arat avx512vbmi umip avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid cldemote movdiri movdir64b fsrm md_clear serialize tsxldtrk amx_bf16 avx512_fp16 amx_tile amx_int8 arch_capabilities
Hypervisor vendor:                       KVM
Virtualization type:                     full
L1d cache:                               384 KiB (8 instances)
L1i cache:                               256 KiB (8 instances)
L2 cache:                                16 MiB (8 instances)
L3 cache:                                260 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; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; Enhanced / Automatic IBRS; IBPB conditional; PBRSB-eIBRS SW sequence; BHI BHI_DIS_S
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected
Resource Usage

base (merge-base)

Metric Value
Wall time 115.0s
Peak memory 20.7 MiB
Avg memory 14.4 MiB
CPU user 108.6s
CPU sys 0.3s
Peak spill 0 B

branch

Metric Value
Wall time 115.0s
Peak memory 23.1 MiB
Avg memory 15.1 MiB
CPU user 112.9s
CPU sys 0.3s
Peak spill 0 B

File an issue against this benchmark runner

@boring-cyborg boring-cyborg Bot added the arrow-core Core crates related to representing arrow data label Nov 17, 2026
@Rich-T-kid

Copy link
Copy Markdown
Contributor Author

run benchmark coalesce_kernels
baseline:
ref: cfd9dfae14c5143da3bd597ae3be0b637733f5a6
env:
BENCH_FILTER: "shared values"
resources:
arch: arm64

@Rich-T-kid

Copy link
Copy Markdown
Contributor Author

run benchmark coalesce_kernels
baseline:
ref: cfd9dfae14c5143da3bd597ae3be0b637733f5a6
env:
BENCH_FILTER: "shared values"
resources:
arch: amd64

@adriangbot

Copy link
Copy Markdown

Could not resolve immutable commits for sharding (#12306 (comment)): GitHub API GET error 422 Unprocessable Entity: {"message":"No commit found for SHA: cfd9dfae14c5143da3bd597ae3be0b637733f5a6","documentation_url":"https://docs.github.com/rest/commits/commits#get-a-commit","status":"422"}


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

Could not resolve immutable commits for sharding (#12306 (comment)): GitHub API GET error 422 Unprocessable Entity: {"message":"No commit found for SHA: cfd9dfae14c5143da3bd597ae3be0b637733f5a6","documentation_url":"https://docs.github.com/rest/commits/commits#get-a-commit","status":"422"}


File an issue against this benchmark runner

@Rich-T-kid

Copy link
Copy Markdown
Contributor Author

run benchmark coalesce_kernels
baseline:
ref: cfd9dfa
env:
BENCH_FILTER: "shared values"
resources:
arch: amd64

@Rich-T-kid

Copy link
Copy Markdown
Contributor Author

run benchmark coalesce_kernels
baseline:
ref: cfd9dfa
env:
BENCH_FILTER: "shared values"
resources:
arch: arm64

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark starting (GKE) | trigger

Target: coalesce_kernels

Sharding factor: 1 (1 workers).

Comparing codex/issue-11940 (43186b4) to cfd9dfa diff

Run configuration
run benchmark coalesce_kernels
baseline:
  ref: cfd9dfae144b2cd96ac9d3b0dc91294c23e6c1cb
env:
  BENCH_FILTER: shared values
resources:
  arch: amd64
shards: 1

Results will be posted when all workers finish.


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark starting (GKE) | trigger

Target: coalesce_kernels

Sharding factor: 1 (1 workers).

Comparing codex/issue-11940 (43186b4) to cfd9dfa diff

Run configuration
run benchmark coalesce_kernels
baseline:
  ref: cfd9dfae144b2cd96ac9d3b0dc91294c23e6c1cb
env:
  BENCH_FILTER: shared values
resources:
  arch: arm64
shards: 1

Results will be posted when all workers finish.


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

Target: coalesce_kernels

Comparing codex/issue-11940 (43186b4) to cfd9dfa diff

Run configuration
run benchmark coalesce_kernels
baseline:
  ref: cfd9dfae144b2cd96ac9d3b0dc91294c23e6c1cb
env:
  BENCH_FILTER: shared values
resources:
  arch: amd64
shards: 1
Details
group                                                                      base                                   changed
-----                                                                      ----                                   -------
take: single_dict (shared values), 8192, nulls: 0, selectivity: 0.001      2.26      9.0±0.23ms        ? ?/sec    1.00      4.0±0.08ms        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0, selectivity: 0.01       1.56  1275.9±40.38µs        ? ?/sec    1.00   816.7±26.00µs        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0, selectivity: 0.1        1.06   488.0±15.73µs        ? ?/sec    1.00    461.2±5.12µs        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0, selectivity: 0.8        1.06   374.1±10.68µs        ? ?/sec    1.00    353.3±4.98µs        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0.1, selectivity: 0.001    1.49     11.7±0.42ms        ? ?/sec    1.00      7.8±0.32ms        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0.1, selectivity: 0.01     1.12  1806.1±49.05µs        ? ?/sec    1.00  1614.7±50.66µs        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0.1, selectivity: 0.1      1.03    693.1±9.29µs        ? ?/sec    1.00   673.3±48.41µs        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0.1, selectivity: 0.8      1.00   502.2±12.59µs        ? ?/sec    1.01   506.3±31.53µs        ? ?/sec

Per-runner information
coalesce_kernels — shard 1/1

Node: gk3-benchmark-cluster-nap-1lxlxann-74a97450-rs7j

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

uname:

Linux bench-c6960042735-5372-rwxcs 6.12.105+ #1 SMP Sat Sep 19 07:57:03 UTC 2026 x86_64 GNU/Linux

BENCH_COMMAND:

cargo bench --features=arrow,async,test_common,experimental,object_store --bench coalesce_kernels
CPU Details (lscpu)
Architecture:                            x86_64
CPU op-mode(s):                          32-bit, 64-bit
Address sizes:                           52 bits physical, 57 bits virtual
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               GenuineIntel
Model name:                              INTEL(R) XEON(R) PLATINUM 8581C CPU @ 2.30GHz
CPU family:                              6
Model:                                   207
Thread(s) per core:                      2
Core(s) per socket:                      8
Socket(s):                               1
Stepping:                                2
BogoMIPS:                                4600.00
Flags:                                   fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves avx_vnni avx512_bf16 wbnoinvd arat avx512vbmi umip avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid cldemote movdiri movdir64b fsrm md_clear serialize tsxldtrk amx_bf16 avx512_fp16 amx_tile amx_int8 arch_capabilities
Hypervisor vendor:                       KVM
Virtualization type:                     full
L1d cache:                               384 KiB (8 instances)
L1i cache:                               256 KiB (8 instances)
L2 cache:                                16 MiB (8 instances)
L3 cache:                                260 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; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; Enhanced / Automatic IBRS; IBPB conditional; PBRSB-eIBRS SW sequence; BHI BHI_DIS_S
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected
Resource Usage

base (merge-base)

Metric Value
Wall time 105.0s
Peak memory 26.0 MiB
Avg memory 14.6 MiB
CPU user 98.6s
CPU sys 0.3s
Peak spill 0 B

branch

Metric Value
Wall time 95.0s
Peak memory 18.2 MiB
Avg memory 15.3 MiB
CPU user 92.9s
CPU sys 0.2s
Peak spill 0 B

File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

Target: coalesce_kernels

Comparing codex/issue-11940 (43186b4) to cfd9dfa diff

Run configuration
run benchmark coalesce_kernels
baseline:
  ref: cfd9dfae144b2cd96ac9d3b0dc91294c23e6c1cb
env:
  BENCH_FILTER: shared values
resources:
  arch: arm64
shards: 1
Details
group                                                                      base                                   changed
-----                                                                      ----                                   -------
take: single_dict (shared values), 8192, nulls: 0, selectivity: 0.001      2.60      9.6±0.04ms        ? ?/sec    1.00      3.7±0.01ms        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0, selectivity: 0.01       1.65   1327.5±2.08µs        ? ?/sec    1.00    803.4±1.68µs        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0, selectivity: 0.1        1.00    468.4±0.86µs        ? ?/sec    1.01    472.7±0.98µs        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0, selectivity: 0.8        1.00    361.9±1.36µs        ? ?/sec    1.02    367.9±2.96µs        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0.1, selectivity: 0.001    1.72     12.9±0.05ms        ? ?/sec    1.00      7.5±0.03ms        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0.1, selectivity: 0.01     1.22   1892.0±3.96µs        ? ?/sec    1.00   1550.9±7.23µs        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0.1, selectivity: 0.1      1.00    645.9±1.78µs        ? ?/sec    1.00    645.7±0.72µs        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0.1, selectivity: 0.8      1.00    478.4±1.14µs        ? ?/sec    1.01    485.5±2.26µs        ? ?/sec

Per-runner information
coalesce_kernels — shard 1/1

Node: gk3-benchmark-cluster-nap-1vtveftb-d03e7e67-jwgn

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

uname:

Linux bench-c6960042823-5373-6tlmz 6.12.105+ #1 SMP Sat Sep 19 07:55:25 UTC 2026 aarch64 GNU/Linux

BENCH_COMMAND:

cargo bench --features=arrow,async,test_common,experimental,object_store --bench coalesce_kernels
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
Resource Usage

base (merge-base)

Metric Value
Wall time 105.0s
Peak memory 30.6 MiB
Avg memory 19.9 MiB
CPU user 99.6s
CPU sys 0.1s
Peak spill 0 B

branch

Metric Value
Wall time 100.0s
Peak memory 27.0 MiB
Avg memory 19.8 MiB
CPU user 95.0s
CPU sys 0.1s
Peak spill 0 B

File an issue against this benchmark runner

@Rich-T-kid
Rich-T-kid marked this pull request as ready for review November 17, 2026 21:19
Comment thread arrow-select/src/coalesce/dictionary.rs Resolved
Comment thread arrow-select/src/coalesce/dictionary.rs Resolved
@Rich-T-kid

Copy link
Copy Markdown
Contributor Author

run benchmark coalesce_kernels
baseline:
ref: "cfd9dfae144b2cd96ac9d3b0dc91294c23e6c1cb"
changed:
ref: "15ce80f1d47531150269a42fe2a72994bc859aec"
env:
BENCH_FILTER: "take: single_dict"
resources:
arch: amd64

@Rich-T-kid

Copy link
Copy Markdown
Contributor Author

run benchmark coalesce_kernels
baseline:
ref: "cfd9dfae144b2cd96ac9d3b0dc91294c23e6c1cb"
changed:
ref: "15ce80f1d47531150269a42fe2a72994bc859aec"
env:
BENCH_FILTER: "take: single_dict"
resources:
arch: arm64

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark starting (GKE) | trigger

Target: coalesce_kernels

Sharding factor: 1 (1 workers).

Comparing 15ce80f (15ce80f) to cfd9dfa diff

Run configuration
run benchmark coalesce_kernels
baseline:
  ref: cfd9dfae144b2cd96ac9d3b0dc91294c23e6c1cb
changed:
  ref: 15ce80f1d47531150269a42fe2a72994bc859aec
env:
  BENCH_FILTER: 'take: single_dict'
resources:
  arch: amd64
shards: 1

Results will be posted when all workers finish.


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark starting (GKE) | trigger

Target: coalesce_kernels

Sharding factor: 1 (1 workers).

Comparing 15ce80f (15ce80f) to cfd9dfa diff

Run configuration
run benchmark coalesce_kernels
baseline:
  ref: cfd9dfae144b2cd96ac9d3b0dc91294c23e6c1cb
changed:
  ref: 15ce80f1d47531150269a42fe2a72994bc859aec
env:
  BENCH_FILTER: 'take: single_dict'
resources:
  arch: arm64
shards: 1

Results will be posted when all workers finish.


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

Target: coalesce_kernels

Comparing 15ce80f (15ce80f) to cfd9dfa diff

Run configuration
run benchmark coalesce_kernels
baseline:
  ref: cfd9dfae144b2cd96ac9d3b0dc91294c23e6c1cb
changed:
  ref: 15ce80f1d47531150269a42fe2a72994bc859aec
env:
  BENCH_FILTER: 'take: single_dict'
resources:
  arch: arm64
shards: 1
Details
group                                                                      base                                   changed
-----                                                                      ----                                   -------
take: single_dict (shared values), 8192, nulls: 0, selectivity: 0.001      2.57      9.6±0.04ms        ? ?/sec    1.00      3.7±0.02ms        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0, selectivity: 0.01       1.65   1364.6±5.37µs        ? ?/sec    1.00    825.1±2.31µs        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0, selectivity: 0.1        1.04    480.9±1.52µs        ? ?/sec    1.00    462.8±0.63µs        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0, selectivity: 0.8        1.02   372.0±13.95µs        ? ?/sec    1.00    363.4±0.62µs        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0.1, selectivity: 0.001    1.71     13.0±0.08ms        ? ?/sec    1.00      7.6±0.02ms        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0.1, selectivity: 0.01     1.23   1903.4±4.49µs        ? ?/sec    1.00   1545.7±5.04µs        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0.1, selectivity: 0.1      1.03    652.0±2.42µs        ? ?/sec    1.00    631.2±0.98µs        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0.1, selectivity: 0.8      1.00    483.7±1.12µs        ? ?/sec    1.00    484.1±1.80µs        ? ?/sec
take: single_dict, 8192, nulls: 0, selectivity: 0.001                      2.24     10.6±0.04ms        ? ?/sec    1.00      4.7±0.02ms        ? ?/sec
take: single_dict, 8192, nulls: 0, selectivity: 0.01                       1.12      4.2±0.04ms        ? ?/sec    1.00      3.7±0.03ms        ? ?/sec
take: single_dict, 8192, nulls: 0, selectivity: 0.1                        1.00      3.1±0.05ms        ? ?/sec    1.01      3.1±0.05ms        ? ?/sec
take: single_dict, 8192, nulls: 0, selectivity: 0.8                        1.00  1708.1±49.28µs        ? ?/sec    1.02  1743.8±42.36µs        ? ?/sec
take: single_dict, 8192, nulls: 0.1, selectivity: 0.001                    1.55     14.2±0.09ms        ? ?/sec    1.00      9.1±0.04ms        ? ?/sec
take: single_dict, 8192, nulls: 0.1, selectivity: 0.01                     1.06      4.8±0.05ms        ? ?/sec    1.00      4.5±0.04ms        ? ?/sec
take: single_dict, 8192, nulls: 0.1, selectivity: 0.1                      1.00      3.3±0.06ms        ? ?/sec    1.01      3.4±0.06ms        ? ?/sec
take: single_dict, 8192, nulls: 0.1, selectivity: 0.8                      1.00      2.0±0.04ms        ? ?/sec    1.01      2.1±0.03ms        ? ?/sec

Per-runner information
coalesce_kernels — shard 1/1

Node: gk3-benchmark-cluster-nap-16rfuggx-41b2c3ef-dcwq

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

uname:

Linux bench-c6972154652-5399-bbngk 6.12.105+ #1 SMP Sat Sep 19 07:55:25 UTC 2026 aarch64 GNU/Linux

BENCH_COMMAND:

cargo bench --features=arrow,async,test_common,experimental,object_store --bench coalesce_kernels
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
Resource Usage

base (merge-base)

Metric Value
Wall time 190.0s
Peak memory 24.3 MiB
Avg memory 15.7 MiB
CPU user 180.8s
CPU sys 0.3s
Peak spill 0 B

branch

Metric Value
Wall time 175.0s
Peak memory 22.8 MiB
Avg memory 16.2 MiB
CPU user 171.9s
CPU sys 0.3s
Peak spill 0 B

File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

Target: coalesce_kernels

Comparing 15ce80f (15ce80f) to cfd9dfa diff

Run configuration
run benchmark coalesce_kernels
baseline:
  ref: cfd9dfae144b2cd96ac9d3b0dc91294c23e6c1cb
changed:
  ref: 15ce80f1d47531150269a42fe2a72994bc859aec
env:
  BENCH_FILTER: 'take: single_dict'
resources:
  arch: amd64
shards: 1
Details
group                                                                      base                                   changed
-----                                                                      ----                                   -------
take: single_dict (shared values), 8192, nulls: 0, selectivity: 0.001      2.28      8.4±0.42ms        ? ?/sec    1.00      3.7±0.15ms        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0, selectivity: 0.01       1.65  1240.1±56.80µs        ? ?/sec    1.00   749.7±36.40µs        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0, selectivity: 0.1        1.28   521.1±24.95µs        ? ?/sec    1.00   406.4±16.68µs        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0, selectivity: 0.8        1.07   348.3±17.08µs        ? ?/sec    1.00   325.2±14.20µs        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0.1, selectivity: 0.001    1.53     10.9±0.46ms        ? ?/sec    1.00      7.1±0.31ms        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0.1, selectivity: 0.01     1.17  1739.6±67.48µs        ? ?/sec    1.00  1489.6±61.15µs        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0.1, selectivity: 0.1      1.12   685.2±31.04µs        ? ?/sec    1.00   610.7±21.60µs        ? ?/sec
take: single_dict (shared values), 8192, nulls: 0.1, selectivity: 0.8      1.00   448.2±17.39µs        ? ?/sec    1.00   448.3±15.89µs        ? ?/sec
take: single_dict, 8192, nulls: 0, selectivity: 0.001                      2.15      9.1±0.41ms        ? ?/sec    1.00      4.2±0.18ms        ? ?/sec
take: single_dict, 8192, nulls: 0, selectivity: 0.01                       1.18      3.8±0.10ms        ? ?/sec    1.00      3.2±0.12ms        ? ?/sec
take: single_dict, 8192, nulls: 0, selectivity: 0.1                        1.04      3.0±0.10ms        ? ?/sec    1.00      2.9±0.06ms        ? ?/sec
take: single_dict, 8192, nulls: 0, selectivity: 0.8                        1.02  1482.5±49.43µs        ? ?/sec    1.00  1452.0±52.30µs        ? ?/sec
take: single_dict, 8192, nulls: 0.1, selectivity: 0.001                    1.36     12.3±0.55ms        ? ?/sec    1.00      9.0±0.31ms        ? ?/sec
take: single_dict, 8192, nulls: 0.1, selectivity: 0.01                     1.04      4.2±0.13ms        ? ?/sec    1.00      4.0±0.17ms        ? ?/sec
take: single_dict, 8192, nulls: 0.1, selectivity: 0.1                      1.01      3.3±0.11ms        ? ?/sec    1.00      3.3±0.09ms        ? ?/sec
take: single_dict, 8192, nulls: 0.1, selectivity: 0.8                      1.01  1855.5±66.48µs        ? ?/sec    1.00  1844.8±62.71µs        ? ?/sec

Per-runner information
coalesce_kernels — shard 1/1

Node: gk3-benchmark-cluster-nap-11qqno8o-efc87962-n8lm

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

uname:

Linux bench-c6972154337-5398-8xn4w 6.12.105+ #1 SMP Sat Sep 19 07:57:03 UTC 2026 x86_64 GNU/Linux

BENCH_COMMAND:

cargo bench --features=arrow,async,test_common,experimental,object_store --bench coalesce_kernels
CPU Details (lscpu)
Architecture:                            x86_64
CPU op-mode(s):                          32-bit, 64-bit
Address sizes:                           52 bits physical, 57 bits virtual
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               GenuineIntel
Model name:                              INTEL(R) XEON(R) PLATINUM 8581C CPU @ 2.30GHz
CPU family:                              6
Model:                                   207
Thread(s) per core:                      2
Core(s) per socket:                      8
Socket(s):                               1
Stepping:                                2
BogoMIPS:                                4600.00
Flags:                                   fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves avx_vnni avx512_bf16 wbnoinvd arat avx512vbmi umip avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid cldemote movdiri movdir64b fsrm md_clear serialize tsxldtrk amx_bf16 avx512_fp16 amx_tile amx_int8 arch_capabilities
Hypervisor vendor:                       KVM
Virtualization type:                     full
L1d cache:                               384 KiB (8 instances)
L1i cache:                               256 KiB (8 instances)
L2 cache:                                16 MiB (8 instances)
L3 cache:                                260 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; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; Enhanced / Automatic IBRS; IBPB conditional; PBRSB-eIBRS SW sequence; BHI BHI_DIS_S
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected
Resource Usage

base (merge-base)

Metric Value
Wall time 180.0s
Peak memory 25.8 MiB
Avg memory 17.1 MiB
CPU user 174.7s
CPU sys 0.3s
Peak spill 0 B

branch

Metric Value
Wall time 180.0s
Peak memory 22.3 MiB
Avg memory 17.1 MiB
CPU user 174.0s
CPU sys 0.2s
Peak spill 0 B

File an issue against this benchmark runner

@Jefffrey Jefffrey added the performance Speed or memory optimizations label Nov 19, 2026
use std::mem::size_of;
use std::sync::Arc;

const INDEXED_COPY_MAX_SELECTIVITY_DENOMINATOR: usize = 16;

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.

what is this value based on

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.

local benchmarks on a macbook m4. did a binary search until we reached the best results

@Rich-T-kid

Copy link
Copy Markdown
Contributor Author

thanks @Jefffrey

@Rich-T-kid
Rich-T-kid added this pull request to the merge queue Nov 19, 2026
Merged via the queue into apache:main with commit 857b004 Nov 19, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow-core Core crates related to representing arrow data arrow-kernels Crates that transform arrow data (e.g. compute, cast) performance Speed or memory optimizations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[coalesce] Add specialized DictionaryArray path for push_batch_with_indices

3 participants