Repository navigation
Conversation
2d997a4 to
c183e9e
Compare
|
@jayzhan211, would you mind taking a look at this? It adds a zero-copy clone/slice fast path in |
|
run benchmark hj tpch10 |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing bvolpato/perf-zero-copy-join-slice (c183e9e) to 9dfd461 (merge-base) diff Run configurationrun benchmark hjTrigger commentResults will be posted here when complete File an issue against this benchmark runner |
|
🤖 Benchmark running (GKE) | trigger CPU Details (lscpu)Comparing bvolpato/perf-zero-copy-join-slice (c183e9e) to 9dfd461 (merge-base) diff Run configurationrun benchmark tpch10Trigger commentResults will be posted here when complete File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Instance: Comparing bvolpato/perf-zero-copy-join-slice (c183e9e) to 9dfd461 (merge-base) diff Run configurationrun benchmark tpch10Trigger commentCPU Details (lscpu)Details
Resource Usagetpch10 — base (merge-base)
tpch10 — branch
File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Instance: Comparing bvolpato/perf-zero-copy-join-slice (c183e9e) to 9dfd461 (merge-base) diff Run configurationrun benchmark hjTrigger commentCPU Details (lscpu)Details
Resource Usagehj — base (merge-base)
hj — branch
File an issue against this benchmark runner |
|
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. |
|
@2010YOUY01 Thanks. Agreed, will keep those benchmarks in mind and re-evaluate! |
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_indicesstill callsarrow::compute::takeon every projected probe column. Becausearrow_select::takehas 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?
contiguous_range_u32helper injoins::utilsthat 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.probe_indicesis an exact identity (0..probe_len), reuse the probe column viaArc::clone.probe_indicesis a contiguous sub-slice retaining at least half of the streaming probe batch (len * 2 >= array.len()), returnarray.slice(start, len)instead of copying throughtake.takeso output batches never retain build-side orPreparedHashJoinBuildbuffers.Benchmarks
Measured on AMD Ryzen 9 9950X3D (Linux x86_64,
release-nonltoagainstmain77611de53):main)join_materialize/pk_fk_100pct_wide_probejoin_materialize/contiguous_slice_75pctjoin_materialize/random_selective_50pctp = 0.51)join_materialize/fanout_2x_untouched_controlp = 0.23)HashJoin(i_item_sk)join_timeHashJoin(w_warehouse_sk)join_timedfbench hjSF10 Q9 (32T, warm median)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::utilscoveringcontiguous_range_u32across chunk boundaries, interior perturbations, null indices, andu32::MAXoverflow, plusbuild_batch_from_indicesverification for exact identity (Arc::ptr_eq),>= 50%zero-copy slices (including nullable andUtf8Viewcolumns),< 50%fallback totake, build-side non-sharing, and non-contiguous/nullable fallback parity. Verified the existingjoinsunit test suite (including prepared-build ownership and symmetric hash join reservation tests), confirmed identical row counts across TPC-H SF1, and added thejoin_materializeCriterion benchmark.Are there any user-facing changes?
No public API or SQL behavior changes.