Skip to content

optimize(concat): concat map implementation#10048

Open
mapleFU wants to merge 3 commits into
apache:mainfrom
mapleFU:concat-map
Open

optimize(concat): concat map implementation#10048
mapleFU wants to merge 3 commits into
apache:mainfrom
mapleFU:concat-map

Conversation

@mapleFU

@mapleFU mapleFU commented Jun 2, 2026

Copy link
Copy Markdown
Member

Which issue does this PR close?

Rationale for this change

Implement concat for map

What changes are included in this PR?

Implement concat for map

Are these changes tested?

Yes

Are there any user-facing changes?

No

@github-actions github-actions Bot added the arrow Changes to the arrow crate label Jun 2, 2026
Ok(Arc::new(array))
}

fn concat_maps(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This copy the logic for List, I don't know can we share a offset based template impl here

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.

👍

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a native concat implementation for Arrow MapArray in arrow-select, avoiding the generic concat_fallback path and bringing Map in line with the existing optimized handling for List and Struct.

Changes:

  • Added concat_maps to efficiently concatenate MapArray instances, including correct handling of sliced inputs and null buffers.
  • Updated concat dispatch to route DataType::Map to the new implementation.
  • Added unit tests covering basic concatenation, sliced maps, null maps, and empty maps.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@alamb

alamb commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

run benchmark concatenate_kernels

@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c4663337102-521-n2l2j 6.12.68+ #1 SMP Sat May 2 07:49:07 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 concat-map (9a066dc) to 481223f (merge-base) diff
BENCH_NAME=concatenate_kernels
BENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental,object_store --bench concatenate_kernels
BENCH_FILTER=
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
  Downloaded darling_macro v0.23.0
  Downloaded crypto-common v0.1.7
  Downloaded crc v3.4.0
  Downloaded cast v0.3.0
  Downloaded bon v3.9.1
  Downloaded clap_lex v1.1.0
  Downloaded ciborium-ll v0.2.2
  Downloaded cfg_aliases v0.2.1
  Downloaded async-stream-impl v0.3.6
  Downloaded bitflags v2.13.0
    Blocking waiting for file lock on package cache
error: no bench target named `concatenate_kernels` in default-run packages

help: a target with a similar name exists: `concatenate_kernel`
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
error: no bench target named `concatenate_kernels` in default-run packages

help: a target with a similar name exists: `concatenate_kernel`

File an issue against this benchmark runner

@alamb

alamb commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

run benchmark concatenate_kernel

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @mapleFU -- makes sense to me.

I also merged up from main and resolved a clippy issue

@adriangbot

Copy link
Copy Markdown

🤖 Arrow criterion benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c4663387267-522-5lzvm 6.12.68+ #1 SMP Sat May 2 07:49:07 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 concat-map (9a066dc) to 481223f (merge-base) diff
BENCH_NAME=concatenate_kernel
BENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental,object_store --bench concatenate_kernel
BENCH_FILTER=
Results will be posted here when complete


File an issue against this benchmark runner

@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                                                          concat-map                             main
-----                                                          ----------                             ----
concat 1024 arrays boolean 4                                   1.00     12.7±0.12µs        ? ?/sec    1.00     12.7±0.06µs        ? ?/sec
concat 1024 arrays i32 4                                       1.00      7.1±0.03µs        ? ?/sec    1.01      7.2±0.06µs        ? ?/sec
concat 1024 arrays str 4                                       1.04     24.2±0.07µs        ? ?/sec    1.00     23.2±0.07µs        ? ?/sec
concat boolean 1024                                            1.02    238.5±3.97ns        ? ?/sec    1.00    232.9±4.51ns        ? ?/sec
concat boolean 8192 over 100 arrays                            1.00      3.6±0.16µs        ? ?/sec    1.00      3.6±0.16µs        ? ?/sec
concat boolean nulls 1024                                      1.00    370.4±8.87ns        ? ?/sec    1.01   375.7±15.26ns        ? ?/sec
concat boolean nulls 8192 over 100 arrays                      1.00      9.7±0.17µs        ? ?/sec    1.00      9.7±0.16µs        ? ?/sec
concat fixed size lists                                        1.02    231.0±1.86µs        ? ?/sec    1.00    227.2±1.20µs        ? ?/sec
concat i32 1024                                                1.06    329.6±8.29ns        ? ?/sec    1.00    312.3±2.05ns        ? ?/sec
concat i32 8192 over 100 arrays                                1.01     93.6±1.05µs        ? ?/sec    1.00     92.6±0.90µs        ? ?/sec
concat i32 nulls 1024                                          1.00    512.7±6.56ns        ? ?/sec    1.01    517.1±4.61ns        ? ?/sec
concat i32 nulls 8192 over 100 arrays                          1.00    100.3±0.49µs        ? ?/sec    1.00    100.6±0.42µs        ? ?/sec
concat str 1024                                                1.10      6.6±0.01µs        ? ?/sec    1.00      6.0±0.00µs        ? ?/sec
concat str 8192 over 100 arrays                                1.00     48.8±0.39ms        ? ?/sec    1.04     50.8±0.52ms        ? ?/sec
concat str nulls 1024                                          1.00      3.2±0.00µs        ? ?/sec    1.00      3.2±0.00µs        ? ?/sec
concat str nulls 8192 over 100 arrays                          1.04     25.6±0.34ms        ? ?/sec    1.00     24.7±0.56ms        ? ?/sec
concat str_dict 1024                                           1.00      2.1±0.00µs        ? ?/sec    1.01      2.1±0.00µs        ? ?/sec
concat str_dict_sparse 1024                                    1.00      8.6±0.04µs        ? ?/sec    1.01      8.7±0.07µs        ? ?/sec
concat struct with int32 and dicts size=1024 count=2           1.00      4.8±0.06µs        ? ?/sec    1.02      4.9±0.02µs        ? ?/sec
concat utf8_view  max_str_len=128 null_density=0               1.01     59.4±0.96µs        ? ?/sec    1.00     58.7±0.75µs        ? ?/sec
concat utf8_view  max_str_len=128 null_density=0.2             1.01     59.4±0.09µs        ? ?/sec    1.00     58.9±0.30µs        ? ?/sec
concat utf8_view  max_str_len=20 null_density=0                1.00     58.0±0.03µs        ? ?/sec    1.01     58.3±0.04µs        ? ?/sec
concat utf8_view  max_str_len=20 null_density=0.2              1.00     59.4±0.18µs        ? ?/sec    1.00     59.2±0.06µs        ? ?/sec
concat utf8_view all_inline max_str_len=12 null_density=0      1.01     17.5±0.02µs        ? ?/sec    1.00     17.3±0.03µs        ? ?/sec
concat utf8_view all_inline max_str_len=12 null_density=0.2    1.01     18.1±0.19µs        ? ?/sec    1.00     17.9±0.13µs        ? ?/sec

Resource Usage

base (merge-base)

Metric Value
Wall time 240.1s
Peak memory 318.8 MiB
Avg memory 58.6 MiB
CPU user 217.0s
CPU sys 16.8s
Peak spill 0 B

branch

Metric Value
Wall time 240.1s
Peak memory 327.1 MiB
Avg memory 61.9 MiB
CPU user 217.5s
CPU sys 18.8s
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 performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: native concat for map type

4 participants