Skip to content

perf(joins): zero-copy probe column clone/slice for contiguous join indices - #27661

Closed
bvolpato wants to merge 1 commit into
apache:mainfrom
bvolpato:bvolpato/perf-zero-copy-join-slice
Closed

bvolpato wants to merge 1 commit into
apache:mainfrom
bvolpato:bvolpato/perf-zero-copy-join-slice

Conversation

@bvolpato

Copy link
Copy Markdown
Contributor

Important

Fork CI setup: For pull requests from a fork to main, enable workflows in your fork's Actions tab before you push.
See the fork CI setup guide.

Which issue does this PR close?

No linked issue.

Rationale for this change

In PK-FK and star-schema joins where most or all probe rows match 1:1 (or where a clustered probe batch matches a contiguous range), build_batch_from_indices still calls arrow::compute::take on every projected probe column. Because arrow_select::take has no identity or contiguous-slice fast path, DataFusion allocates and copies every probe payload column across each join stage even when the output column matches the input probe batch.

What changes are included in this PR?

  • Add a contiguous_range_u32 helper in joins::utils that rejects non-contiguous index arrays in O(1) (checking nulls, endpoints, and midpoint) and verifies contiguous runs in 8-element XOR-OR chunks once per batch across all probe columns.
  • When probe_indices is an exact identity (0..probe_len), reuse the probe column via Arc::clone.
  • When probe_indices is a contiguous sub-slice retaining at least half of the streaming probe batch (len * 2 >= array.len()), return array.slice(start, len) instead of copying through take.
  • Keep build-side columns on take so output batches never retain build-side or PreparedHashJoinBuild buffers.

Benchmarks

Measured on AMD Ryzen 9 9950X3D (Linux x86_64, release-nonlto against main 77611de53):

Benchmark Before (main) After Delta / Speedup
join_materialize/pk_fk_100pct_wide_probe 2.006 ms 455.5 us -77.2% (4.41x)
join_materialize/contiguous_slice_75pct 1.473 ms 381.9 us -75.1% (3.86x)
join_materialize/random_selective_50pct 1.846 ms 1.872 ms +1.3% (no change, p = 0.51)
join_materialize/fanout_2x_untouched_control 3.668 ms 3.685 ms +1.3% (no change, p = 0.23)
TPC-DS SF1 Q72 HashJoin(i_item_sk) join_time 869.49 ms 304.56 ms -65.0% (2.85x)
TPC-DS SF1 Q72 HashJoin(w_warehouse_sk) join_time 769.86 ms 260.17 ms -66.2% (2.96x)
TPC-H SF10 Q10 (avg of 4) 907.48 ms 764.79 ms -15.7% (1.19x)
TPC-H SF10 Q7 (avg of 4) 898.65 ms 807.28 ms -10.2% (1.11x)
TPC-H SF10 Q8 (avg of 4) 391.16 ms 351.58 ms -10.1% (1.11x)
dfbench hj SF10 Q9 (32T, warm median) 435.4 ms 377.9 ms -13.2% (1.15x)

Note: AI assistance was used during profiling, implementation, and benchmark verification; I reviewed the full diff and verified the invariants and benchmark results directly.

What is the testing strategy for this PR?

Added unit tests in joins::utils covering contiguous_range_u32 across chunk boundaries, interior perturbations, null indices, and u32::MAX overflow, plus build_batch_from_indices verification for exact identity (Arc::ptr_eq), >= 50% zero-copy slices (including nullable and Utf8View columns), < 50% fallback to take, build-side non-sharing, and non-contiguous/nullable fallback parity. Verified the existing joins unit test suite (including prepared-build ownership and symmetric hash join reservation tests), confirmed identical row counts across TPC-H SF1, and added the join_materialize Criterion benchmark.

Are there any user-facing changes?

No public API or SQL behavior changes.

@github-actions github-actions Bot added the physical-plan Changes to the physical-plan crate label Nov 22, 2026
@bvolpato
bvolpato force-pushed the bvolpato/perf-zero-copy-join-slice branch from 2d997a4 to c183e9e Compare November 28, 2026 21:42
@bvolpato

Copy link
Copy Markdown
Contributor Author

@jayzhan211, would you mind taking a look at this? It adds a zero-copy clone/slice fast path in build_batch_from_indices for contiguous probe index ranges, along the same hash join probe path you have been working on. If someone else owns this path now, happy to redirect.

@2010YOUY01

Copy link
Copy Markdown
Member

run benchmark hj tpch10

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c7251952208-5830-pdqxz 6.12.105+ #1 SMP Sat Sep 19 07:55:25 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 bvolpato/perf-zero-copy-join-slice (c183e9e) to 9dfd461 (merge-base) diff

Run configuration
run benchmark hj
Trigger comment
run benchmark hj tpch10

Results will be posted here when complete


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c7251952208-5831-d966d 6.12.105+ #1 SMP Sat Sep 19 07:55:25 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 bvolpato/perf-zero-copy-join-slice (c183e9e) to 9dfd461 (merge-base) diff

Run configuration
run benchmark tpch10
Trigger comment
run benchmark hj tpch10

Results will be posted here when complete


File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

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

Comparing bvolpato/perf-zero-copy-join-slice (c183e9e) to 9dfd461 (merge-base) diff

Run configuration
run benchmark tpch10
Trigger comment
run benchmark hj tpch10
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

Comparing HEAD and bvolpato_perf-zero-copy-join-slice
--------------------
Benchmark tpch_sf10.json
--------------------
┏━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┓
┃ Query     ┃      HEAD ┃ bvolpato_perf-zero-copy-join-slice ┃       Change ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━┩
│ QQuery 1  │ 311.08 ms │                          308.72 ms │    no change │
│ QQuery 2  │  88.19 ms │                           86.49 ms │    no change │
│ QQuery 3  │ 216.17 ms │                          216.55 ms │    no change │
│ QQuery 4  │ 111.38 ms │                          113.19 ms │    no change │
│ QQuery 5  │ 344.70 ms │                          347.88 ms │    no change │
│ QQuery 6  │ 103.11 ms │                          103.38 ms │    no change │
│ QQuery 7  │ 456.05 ms │                          442.85 ms │    no change │
│ QQuery 8  │ 345.37 ms │                          349.17 ms │    no change │
│ QQuery 9  │ 508.96 ms │                          499.91 ms │    no change │
│ QQuery 10 │ 285.06 ms │                          286.33 ms │    no change │
│ QQuery 11 │  60.38 ms │                           61.04 ms │    no change │
│ QQuery 12 │ 117.47 ms │                          117.38 ms │    no change │
│ QQuery 13 │ 295.99 ms │                          304.68 ms │    no change │
│ QQuery 14 │ 172.68 ms │                          170.31 ms │    no change │
│ QQuery 15 │ 300.69 ms │                          301.38 ms │    no change │
│ QQuery 16 │  64.24 ms │                           63.47 ms │    no change │
│ QQuery 17 │ 593.27 ms │                          591.35 ms │    no change │
│ QQuery 18 │ 425.38 ms │                          430.51 ms │    no change │
│ QQuery 19 │ 238.38 ms │                          234.18 ms │    no change │
│ QQuery 20 │ 264.71 ms │                          262.64 ms │    no change │
│ QQuery 21 │ 648.42 ms │                          646.88 ms │    no change │
│ QQuery 22 │  59.24 ms │                           62.59 ms │ 1.06x slower │
└───────────┴───────────┴────────────────────────────────────┴──────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ Benchmark Summary                                 ┃           ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
│ Total Time (HEAD)                                 │ 6010.89ms │
│ Total Time (bvolpato_perf-zero-copy-join-slice)   │ 6000.89ms │
│ Average Time (HEAD)                               │  273.22ms │
│ Average Time (bvolpato_perf-zero-copy-join-slice) │  272.77ms │
│ Queries Faster                                    │         0 │
│ Queries Slower                                    │         1 │
│ Queries with No Change                            │        21 │
│ Queries with Failure                              │         0 │
└───────────────────────────────────────────────────┴───────────┘

Distribution per query (min / mean ±stddev / max):

Comparing HEAD and bvolpato_perf-zero-copy-join-slice
--------------------
Benchmark tpch_sf10.json
--------------------
┏━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┓
┃ Query     ┃                               HEAD ┃ bvolpato_perf-zero-copy-join-slice ┃       Change ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━┩
│ QQuery 1  │  311.08 / 312.65 ±1.45 / 315.15 ms │  308.72 / 310.23 ±1.21 / 311.97 ms │    no change │
│ QQuery 2  │     88.19 / 89.73 ±1.30 / 91.95 ms │     86.49 / 89.08 ±1.91 / 92.40 ms │    no change │
│ QQuery 3  │  216.17 / 219.64 ±3.70 / 226.25 ms │  216.55 / 219.68 ±2.23 / 223.48 ms │    no change │
│ QQuery 4  │  111.38 / 113.50 ±1.52 / 116.11 ms │  113.19 / 114.41 ±0.88 / 115.66 ms │    no change │
│ QQuery 5  │  344.70 / 352.29 ±5.79 / 360.03 ms │  347.88 / 354.37 ±6.03 / 361.98 ms │    no change │
│ QQuery 6  │  103.11 / 103.87 ±0.59 / 104.86 ms │  103.38 / 104.68 ±1.02 / 105.98 ms │    no change │
│ QQuery 7  │  456.05 / 463.19 ±7.04 / 471.89 ms │  442.85 / 445.67 ±2.39 / 449.40 ms │    no change │
│ QQuery 8  │  345.37 / 352.15 ±6.43 / 363.98 ms │  349.17 / 352.40 ±2.34 / 356.27 ms │    no change │
│ QQuery 9  │ 508.96 / 522.86 ±22.78 / 567.88 ms │ 499.91 / 513.25 ±11.66 / 527.94 ms │    no change │
│ QQuery 10 │  285.06 / 290.70 ±4.72 / 297.75 ms │  286.33 / 289.45 ±3.26 / 293.61 ms │    no change │
│ QQuery 11 │     60.38 / 62.57 ±1.23 / 63.89 ms │    61.04 / 68.92 ±14.54 / 97.97 ms │ 1.10x slower │
│ QQuery 12 │  117.47 / 119.68 ±2.05 / 123.55 ms │  117.38 / 119.96 ±2.08 / 122.92 ms │    no change │
│ QQuery 13 │ 295.99 / 315.08 ±13.59 / 335.87 ms │  304.68 / 316.16 ±6.62 / 324.26 ms │    no change │
│ QQuery 14 │  172.68 / 176.42 ±4.64 / 185.45 ms │  170.31 / 175.82 ±4.68 / 181.45 ms │    no change │
│ QQuery 15 │  300.69 / 304.72 ±3.44 / 309.70 ms │  301.38 / 304.15 ±2.20 / 307.17 ms │    no change │
│ QQuery 16 │     64.24 / 65.91 ±1.57 / 67.98 ms │     63.47 / 67.71 ±3.57 / 73.95 ms │    no change │
│ QQuery 17 │  593.27 / 601.21 ±5.82 / 607.49 ms │  591.35 / 599.55 ±5.67 / 606.05 ms │    no change │
│ QQuery 18 │  425.38 / 430.39 ±3.24 / 434.71 ms │  430.51 / 437.48 ±7.72 / 448.33 ms │    no change │
│ QQuery 19 │ 238.38 / 252.28 ±17.47 / 285.08 ms │  234.18 / 241.43 ±7.34 / 255.37 ms │    no change │
│ QQuery 20 │  264.71 / 278.81 ±9.79 / 291.74 ms │  262.64 / 272.48 ±8.87 / 287.69 ms │    no change │
│ QQuery 21 │  648.42 / 656.37 ±5.08 / 661.44 ms │  646.88 / 654.79 ±7.21 / 666.71 ms │    no change │
│ QQuery 22 │     59.24 / 63.20 ±2.97 / 66.69 ms │     62.59 / 65.33 ±2.20 / 68.56 ms │    no change │
└───────────┴────────────────────────────────────┴────────────────────────────────────┴──────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ Benchmark Summary                                 ┃           ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
│ Total Time (HEAD)                                 │ 6147.19ms │
│ Total Time (bvolpato_perf-zero-copy-join-slice)   │ 6116.99ms │
│ Average Time (HEAD)                               │  279.42ms │
│ Average Time (bvolpato_perf-zero-copy-join-slice) │  278.04ms │
│ Queries Faster                                    │         0 │
│ Queries Slower                                    │         1 │
│ Queries with No Change                            │        21 │
│ Queries with Failure                              │         0 │
└───────────────────────────────────────────────────┴───────────┘

Resource Usage

tpch10 — base (merge-base)

Metric Value
Wall time 35.0s
Peak memory 4.3 GiB
Avg memory 1.3 GiB
CPU user 310.9s
CPU sys 18.6s
Peak spill 0 B

tpch10 — branch

Metric Value
Wall time 35.0s
Peak memory 4.4 GiB
Avg memory 1.3 GiB
CPU user 310.4s
CPU sys 18.5s
Peak spill 0 B

File an issue against this benchmark runner

@adriangbot

Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

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

Comparing bvolpato/perf-zero-copy-join-slice (c183e9e) to 9dfd461 (merge-base) diff

Run configuration
run benchmark hj
Trigger comment
run benchmark hj tpch10
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

Comparing HEAD and bvolpato_perf-zero-copy-join-slice
--------------------
Benchmark hj.json
--------------------
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┓
┃ Query                                                                         ┃      HEAD ┃ bvolpato_perf-zero-copy-join-slice ┃       Change ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━┩
│ QQuery 1_density=1_prob_hit=1_25*1.5M                                         │   1.87 ms │                            1.90 ms │    no change │
│ QQuery 2_density=0.026_prob_hit=1_25*1.5M                                     │   4.35 ms │                            4.60 ms │ 1.06x slower │
│ QQuery 3_density=1_prob_hit=1_100K*60M                                        │  82.18 ms │                           83.01 ms │    no change │
│ QQuery 4_density=1_prob_hit=0.1_100K*60M                                      │ 186.26 ms │                          189.84 ms │    no change │
│ QQuery 5_density=0.75_prob_hit=1_100K*60M                                     │ 705.75 ms │                          737.03 ms │    no change │
│ QQuery 6_density=0.75_prob_hit=0.1_100K*60M                                   │ 252.06 ms │                          259.66 ms │    no change │
│ QQuery 7_density=0.5_prob_hit=1_100K*60M                                      │ 720.61 ms │                          757.30 ms │ 1.05x slower │
│ QQuery 8_density=0.5_prob_hit=0.1_100K*60M                                    │ 248.72 ms │                          254.77 ms │    no change │
│ QQuery 9_density=0.2_prob_hit=1_100K*60M                                      │ 717.49 ms │                          736.87 ms │    no change │
│ QQuery 10_density=0.2_prob_hit=0.1_100K*60M                                   │ 248.76 ms │                          251.48 ms │    no change │
│ QQuery 11_density=0.1_prob_hit=1_100K*60M                                     │ 705.91 ms │                          762.96 ms │ 1.08x slower │
│ QQuery 12_density=0.1_prob_hit=0.1_100K*60M                                   │ 253.40 ms │                          252.39 ms │    no change │
│ QQuery 13_density=0.01_prob_hit=1_100K*60M                                    │ 741.78 ms │                          739.09 ms │    no change │
│ QQuery 14_density=0.01_prob_hit=0.1_100K*60M                                  │ 300.00 ms │                          286.51 ms │    no change │
│ QQuery 15_density=0.2_prob_hit=0.1_100K_(20%_dups)*60M                        │ 241.56 ms │                          240.87 ms │    no change │
│ QQuery 16_density=1_prob_hit=1_25*1.5M_RightSemi                              │   2.37 ms │                            2.28 ms │    no change │
│ QQuery 17_density=1_prob_hit=1_100K*60M_RightSemi                             │  85.94 ms │                           83.35 ms │    no change │
│ QQuery 18_density=1_prob_hit=0.1_100K*60M_RightSemi                           │  91.10 ms │                           92.53 ms │    no change │
│ QQuery 19_density=1_prob_hit=1_25*1.5M_RightAnti                              │   1.97 ms │                            1.88 ms │    no change │
│ QQuery 20_density=1_prob_hit=1_100K*60M_RightAnti                             │  78.21 ms │                           78.09 ms │    no change │
│ QQuery 21_density=1_prob_hit=0.1_100K*60M_RightAnti                           │ 102.55 ms │                          103.25 ms │    no change │
│ QQuery 22_density=1_prob_hit=0.01_100K_(fanout_100)*60M_RightSemi             │  88.46 ms │                           88.00 ms │    no change │
│ QQuery 23_density=1_prob_hit=1_32K_(fanout~78)*2.3M_long_keys_count           │ 159.76 ms │                          161.14 ms │    no change │
│ QQuery 24_density=1_prob_hit=1_3K_(single_hot_bucket)*20K_long_keys_count     │ 510.68 ms │                          510.61 ms │    no change │
│ QQuery 25_density=1_prob_hit=1_20K_(fanout~78_multi_key)*240K_multi_key_count │ 211.44 ms │                          213.42 ms │    no change │
│ QQuery 26_density=1_prob_hit=0.027_270K_dense_keys*15M                        │  53.83 ms │                           53.29 ms │    no change │
│ QQuery 27_density=0.027_prob_hit=0.027_270K_sparse_keys*15M                   │  63.41 ms │                           61.94 ms │    no change │
│ QQuery 28_density=0.01_prob_hit=0.2_6M_(1.5M_one_key)*100K_count              │ 914.27 ms │                          926.53 ms │    no change │
└───────────────────────────────────────────────────────────────────────────────┴───────────┴────────────────────────────────────┴──────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ Benchmark Summary                                 ┃           ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
│ Total Time (HEAD)                                 │ 7774.69ms │
│ Total Time (bvolpato_perf-zero-copy-join-slice)   │ 7934.58ms │
│ Average Time (HEAD)                               │  277.67ms │
│ Average Time (bvolpato_perf-zero-copy-join-slice) │  283.38ms │
│ Queries Faster                                    │         0 │
│ Queries Slower                                    │         3 │
│ Queries with No Change                            │        25 │
│ Queries with Failure                              │         0 │
└───────────────────────────────────────────────────┴───────────┘

Distribution per query (min / mean ±stddev / max):

Comparing HEAD and bvolpato_perf-zero-copy-join-slice
--------------------
Benchmark hj.json
--------------------
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query                                                                         ┃                               HEAD ┃ bvolpato_perf-zero-copy-join-slice ┃        Change ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ QQuery 1_density=1_prob_hit=1_25*1.5M                                         │        1.87 / 2.25 ±0.44 / 3.03 ms │        1.90 / 2.22 ±0.53 / 3.26 ms │     no change │
│ QQuery 2_density=0.026_prob_hit=1_25*1.5M                                     │        4.35 / 4.55 ±0.14 / 4.76 ms │        4.60 / 4.66 ±0.06 / 4.77 ms │     no change │
│ QQuery 3_density=1_prob_hit=1_100K*60M                                        │     82.18 / 83.00 ±0.59 / 83.61 ms │     83.01 / 84.75 ±2.48 / 89.64 ms │     no change │
│ QQuery 4_density=1_prob_hit=0.1_100K*60M                                      │  186.26 / 196.27 ±9.80 / 213.42 ms │  189.84 / 198.83 ±9.47 / 215.45 ms │     no change │
│ QQuery 5_density=0.75_prob_hit=1_100K*60M                                     │ 705.75 / 724.07 ±13.08 / 738.63 ms │ 737.03 / 778.77 ±44.40 / 864.86 ms │  1.08x slower │
│ QQuery 6_density=0.75_prob_hit=0.1_100K*60M                                   │ 252.06 / 270.24 ±16.08 / 293.70 ms │ 259.66 / 276.93 ±11.50 / 293.85 ms │     no change │
│ QQuery 7_density=0.5_prob_hit=1_100K*60M                                      │  720.61 / 730.88 ±6.53 / 740.78 ms │ 757.30 / 774.67 ±14.71 / 799.70 ms │  1.06x slower │
│ QQuery 8_density=0.5_prob_hit=0.1_100K*60M                                    │ 248.72 / 268.28 ±16.36 / 293.52 ms │ 254.77 / 282.90 ±25.47 / 319.53 ms │  1.05x slower │
│ QQuery 9_density=0.2_prob_hit=1_100K*60M                                      │  717.49 / 731.76 ±8.61 / 742.27 ms │ 736.87 / 761.29 ±23.63 / 805.24 ms │     no change │
│ QQuery 10_density=0.2_prob_hit=0.1_100K*60M                                   │ 248.76 / 268.21 ±14.81 / 288.93 ms │ 251.48 / 276.78 ±24.87 / 315.06 ms │     no change │
│ QQuery 11_density=0.1_prob_hit=1_100K*60M                                     │ 705.91 / 723.06 ±19.49 / 759.62 ms │ 762.96 / 775.01 ±15.31 / 804.94 ms │  1.07x slower │
│ QQuery 12_density=0.1_prob_hit=0.1_100K*60M                                   │ 253.40 / 265.22 ±10.13 / 279.11 ms │ 252.39 / 276.14 ±27.29 / 320.02 ms │     no change │
│ QQuery 13_density=0.01_prob_hit=1_100K*60M                                    │ 741.78 / 778.12 ±18.59 / 790.52 ms │ 739.09 / 771.08 ±23.50 / 803.63 ms │     no change │
│ QQuery 14_density=0.01_prob_hit=0.1_100K*60M                                  │ 300.00 / 326.15 ±23.47 / 357.25 ms │ 286.51 / 323.31 ±24.08 / 358.99 ms │     no change │
│ QQuery 15_density=0.2_prob_hit=0.1_100K_(20%_dups)*60M                        │ 241.56 / 259.01 ±15.99 / 283.05 ms │ 240.87 / 258.41 ±23.56 / 303.93 ms │     no change │
│ QQuery 16_density=1_prob_hit=1_25*1.5M_RightSemi                              │        2.37 / 2.63 ±0.21 / 2.88 ms │        2.28 / 2.34 ±0.07 / 2.46 ms │ +1.13x faster │
│ QQuery 17_density=1_prob_hit=1_100K*60M_RightSemi                             │  85.94 / 106.34 ±17.42 / 131.21 ms │  83.35 / 104.66 ±28.15 / 157.92 ms │     no change │
│ QQuery 18_density=1_prob_hit=0.1_100K*60M_RightSemi                           │     91.10 / 92.30 ±0.74 / 93.29 ms │     92.53 / 94.54 ±2.27 / 98.96 ms │     no change │
│ QQuery 19_density=1_prob_hit=1_25*1.5M_RightAnti                              │        1.97 / 2.06 ±0.10 / 2.23 ms │        1.88 / 1.91 ±0.04 / 1.98 ms │ +1.08x faster │
│ QQuery 20_density=1_prob_hit=1_100K*60M_RightAnti                             │     78.21 / 78.69 ±0.48 / 79.52 ms │     78.09 / 78.48 ±0.30 / 78.88 ms │     no change │
│ QQuery 21_density=1_prob_hit=0.1_100K*60M_RightAnti                           │  102.55 / 104.35 ±1.82 / 106.94 ms │  103.25 / 104.97 ±1.29 / 107.25 ms │     no change │
│ QQuery 22_density=1_prob_hit=0.01_100K_(fanout_100)*60M_RightSemi             │     88.46 / 90.30 ±2.60 / 95.31 ms │     88.00 / 90.19 ±1.34 / 92.16 ms │     no change │
│ QQuery 23_density=1_prob_hit=1_32K_(fanout~78)*2.3M_long_keys_count           │  159.76 / 160.26 ±0.30 / 160.62 ms │  161.14 / 161.57 ±0.23 / 161.78 ms │     no change │
│ QQuery 24_density=1_prob_hit=1_3K_(single_hot_bucket)*20K_long_keys_count     │  510.68 / 514.05 ±2.78 / 518.71 ms │  510.61 / 513.96 ±3.08 / 519.62 ms │     no change │
│ QQuery 25_density=1_prob_hit=1_20K_(fanout~78_multi_key)*240K_multi_key_count │  211.44 / 211.79 ±0.36 / 212.44 ms │  213.42 / 214.28 ±1.19 / 216.59 ms │     no change │
│ QQuery 26_density=1_prob_hit=0.027_270K_dense_keys*15M                        │     53.83 / 55.32 ±1.03 / 57.05 ms │     53.29 / 55.04 ±0.96 / 56.05 ms │     no change │
│ QQuery 27_density=0.027_prob_hit=0.027_270K_sparse_keys*15M                   │     63.41 / 64.65 ±1.14 / 66.33 ms │     61.94 / 65.30 ±2.59 / 68.72 ms │     no change │
│ QQuery 28_density=0.01_prob_hit=0.2_6M_(1.5M_one_key)*100K_count              │ 914.27 / 940.62 ±15.46 / 957.16 ms │ 926.53 / 945.54 ±11.18 / 960.65 ms │     no change │
└───────────────────────────────────────────────────────────────────────────────┴────────────────────────────────────┴────────────────────────────────────┴───────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ Benchmark Summary                                 ┃           ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
│ Total Time (HEAD)                                 │ 8054.44ms │
│ Total Time (bvolpato_perf-zero-copy-join-slice)   │ 8278.51ms │
│ Average Time (HEAD)                               │  287.66ms │
│ Average Time (bvolpato_perf-zero-copy-join-slice) │  295.66ms │
│ Queries Faster                                    │         2 │
│ Queries Slower                                    │         4 │
│ Queries with No Change                            │        22 │
│ Queries with Failure                              │         0 │
└───────────────────────────────────────────────────┴───────────┘

Resource Usage

hj — base (merge-base)

Metric Value
Wall time 45.0s
Peak memory 2.7 GiB
Avg memory 1.1 GiB
CPU user 337.4s
CPU sys 13.2s
Peak spill 0 B

hj — branch

Metric Value
Wall time 45.0s
Peak memory 2.1 GiB
Avg memory 1.1 GiB
CPU user 346.0s
CPU sys 14.1s
Peak spill 0 B

File an issue against this benchmark runner

@2010YOUY01

Copy link
Copy Markdown
Member

Thank you for trying this idea!

The SQL benchmarks above show no clear improvement, and the gains in the local results are likely due to benchmark noise.

I'd prefer to keep things simple and only pursue this optimization if it improves e2e results. Currently it seems only improving microbenches on utility functions, that is not on the critical path.

@bvolpato

Copy link
Copy Markdown
Contributor Author

@2010YOUY01 Thanks. Agreed, will keep those benchmarks in mind and re-evaluate!

@bvolpato bvolpato closed this Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

physical-plan Changes to the physical-plan crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants