Repository navigation
perf(interleave): reuse shared dictionary values - #12059
Rich-T-kid wants to merge 5 commits into
Conversation
|
run benchmark interleave_kernels |
2 similar comments
|
run benchmark interleave_kernels |
|
run benchmark interleave_kernels |
|
🤖 Benchmark starting (GKE) | trigger Target: interleave_kernels Sharding factor: 1 (1 workers). Comparing rich-T-kid/interleave-shared-dictionary-values (042914e) to 8e9eec3 (merge-base) diff Run configurationrun benchmark interleave_kernels
env:
BENCH_FILTER: interleave dict
shards: 1
Results will be posted when all workers finish. File an issue against this benchmark runner |
|
🤖 Benchmark starting (GKE) | trigger Target: interleave_kernels Sharding factor: 1 (1 workers). Comparing rich-T-kid/interleave-shared-dictionary-values (042914e) to 8e9eec3 (merge-base) diff Run configurationrun benchmark interleave_kernels
env:
BENCH_FILTER: interleave dict
shards: 1
Results will be posted when all workers finish. File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Target: interleave_kernels Comparing rich-T-kid/interleave-shared-dictionary-values (042914e) to 8e9eec3 (merge-base) diff Run configurationrun benchmark interleave_kernels
env:
BENCH_FILTER: interleave dict
shards: 1
DetailsPer-runner informationinterleave_kernels — shard 1/1Node: gk3-benchmark-cluster-nap-r578ggp2-e53cf964-kmcq Instance: c4a-highmem-16 (12 vCPU / 65 GiB) uname: BENCH_COMMAND: cargo bench --features=arrow,async,test_common,experimental,object_store --bench interleave_kernelsCPU Details (lscpu)Resource Usagebase (merge-base)
branch
File an issue against this benchmark runner |
|
🤖 Benchmark starting (GKE) | trigger Target: interleave_kernels Sharding factor: 1 (1 workers). Comparing rich-T-kid/interleave-shared-dictionary-values (042914e) to 8e9eec3 (merge-base) diff Run configurationrun benchmark interleave_kernels
env:
BENCH_FILTER: interleave dict
shards: 1
Results will be posted when all workers finish. File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Target: interleave_kernels Comparing rich-T-kid/interleave-shared-dictionary-values (042914e) to 8e9eec3 (merge-base) diff Run configurationrun benchmark interleave_kernels
env:
BENCH_FILTER: interleave dict
shards: 1
DetailsPer-runner informationinterleave_kernels — shard 1/1Node: gk3-benchmark-cluster-nap-r578ggp2-e53cf964-dhgd Instance: c4a-highmem-16 (12 vCPU / 65 GiB) uname: BENCH_COMMAND: cargo bench --features=arrow,async,test_common,experimental,object_store --bench interleave_kernelsCPU Details (lscpu)Resource Usagebase (merge-base)
branch
File an issue against this benchmark runner |
|
run benchmark interleave_kernels |
|
🤖 Benchmark starting (GKE) | trigger Target: interleave_kernels Sharding factor: 1 (1 workers). Comparing rich-T-kid/interleave-shared-dictionary-values (042914e) to 8e9eec3 (merge-base) diff Run configurationrun benchmark interleave_kernels
env:
BENCH_FILTER: interleave dict
shards: 1
Results will be posted when all workers finish. File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Target: interleave_kernels Comparing rich-T-kid/interleave-shared-dictionary-values (042914e) to 8e9eec3 (merge-base) diff Run configurationrun benchmark interleave_kernels
env:
BENCH_FILTER: interleave dict
shards: 1
DetailsPer-runner informationinterleave_kernels — shard 1/1Node: gk3-benchmark-cluster-nap-r578ggp2-e53cf964-kmcq Instance: c4a-highmem-16 (12 vCPU / 65 GiB) uname: BENCH_COMMAND: cargo bench --features=arrow,async,test_common,experimental,object_store --bench interleave_kernelsCPU Details (lscpu)Resource Usagebase (merge-base)
branch
File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Target: interleave_kernels Comparing rich-T-kid/interleave-shared-dictionary-values (042914e) to 8e9eec3 (merge-base) diff Run configurationrun benchmark interleave_kernels
env:
BENCH_FILTER: interleave dict
shards: 1
DetailsPer-runner informationinterleave_kernels — shard 1/1Node: gk3-benchmark-cluster-nap-r578ggp2-e53cf964-sc8v Instance: c4a-highmem-16 (12 vCPU / 65 GiB) uname: BENCH_COMMAND: cargo bench --features=arrow,async,test_common,experimental,object_store --bench interleave_kernelsCPU Details (lscpu)Resource Usagebase (merge-base)
branch
File an issue against this benchmark runner |
|
run benchmark interleave_kernels |
|
🤖 Benchmark starting (GKE) | trigger Target: interleave_kernels Sharding factor: 1 (1 workers). Comparing rich-T-kid/interleave-shared-dictionary-values (fb8c26d) to 8e9eec3 (merge-base) diff Run configurationrun benchmark interleave_kernels
env:
BENCH_FILTER: interleave dict
shards: 1
Results will be posted when all workers finish. File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Target: interleave_kernels Comparing rich-T-kid/interleave-shared-dictionary-values (fb8c26d) to 8e9eec3 (merge-base) diff Run configurationrun benchmark interleave_kernels
env:
BENCH_FILTER: interleave dict
shards: 1
DetailsPer-runner informationinterleave_kernels — shard 1/1Node: gk3-benchmark-cluster-nap-1uq9xv30-f6f148e3-8kvx Instance: c4a-highmem-16 (12 vCPU / 65 GiB) uname: BENCH_COMMAND: cargo bench --features=arrow,async,test_common,experimental,object_store --bench interleave_kernelsCPU Details (lscpu)Resource Usagebase (merge-base)
branch
File an issue against this benchmark runner |
|
run benchmark interleave_kernels |
|
🤖 Benchmark starting (GKE) | trigger Target: interleave_kernels Sharding factor: 1 (1 workers). Comparing rich-T-kid/interleave-shared-dictionary-values (fb8c26d) to 8e9eec3 (merge-base) diff Run configurationrun benchmark interleave_kernels
env:
BENCH_FILTER: interleave dict
shards: 1
Results will be posted when all workers finish. File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Target: interleave_kernels Comparing rich-T-kid/interleave-shared-dictionary-values (fb8c26d) to 8e9eec3 (merge-base) diff Run configurationrun benchmark interleave_kernels
env:
BENCH_FILTER: interleave dict
shards: 1
DetailsPer-runner informationinterleave_kernels — shard 1/1Node: gk3-benchmark-cluster-nap-ho9aygeh-38c2db3b-mkpc Instance: c4a-highmem-16 (12 vCPU / 65 GiB) uname: BENCH_COMMAND: cargo bench --features=arrow,async,test_common,experimental,object_store --bench interleave_kernelsCPU Details (lscpu)Resource Usagebase (merge-base)
branch
File an issue against this benchmark runner |
fb8c26d to
491c626
Compare
|
run benchmark interleave_kernels |
|
🤖 Benchmark starting (GKE) | trigger Target: interleave_kernels Sharding factor: 1 (1 workers). Comparing rich-T-kid/interleave-shared-dictionary-values (491c626) to 8e9eec3 (merge-base) diff Run configurationrun benchmark interleave_kernels
env:
BENCH_FILTER: interleave dict
shards: 1
Results will be posted when all workers finish. File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Target: interleave_kernels Comparing rich-T-kid/interleave-shared-dictionary-values (491c626) to 8e9eec3 (merge-base) diff Run configurationrun benchmark interleave_kernels
env:
BENCH_FILTER: interleave dict
shards: 1
DetailsPer-runner informationinterleave_kernels — shard 1/1Node: gk3-benchmark-cluster-nap-1kq6y1fb-9a2249d4-x8n8 Instance: c4a-highmem-16 (12 vCPU / 65 GiB) uname: BENCH_COMMAND: cargo bench --features=arrow,async,test_common,experimental,object_store --bench interleave_kernelsCPU Details (lscpu)Resource Usagebase (merge-base)
branch
File an issue against this benchmark runner |
491c626 to
65a3b88
Compare
|
run benchmark interleave_kernels |
|
🤖 Benchmark starting (GKE) | trigger Target: interleave_kernels Sharding factor: 1 (1 workers). Comparing rich-T-kid/interleave-shared-dictionary-values (65a3b88) to 8e9eec3 (merge-base) diff Run configurationrun benchmark interleave_kernels
env:
BENCH_FILTER: interleave dict
shards: 1
Results will be posted when all workers finish. File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Target: interleave_kernels Comparing rich-T-kid/interleave-shared-dictionary-values (65a3b88) to 8e9eec3 (merge-base) diff Run configurationrun benchmark interleave_kernels
env:
BENCH_FILTER: interleave dict
shards: 1
DetailsPer-runner informationinterleave_kernels — shard 1/1Node: gk3-benchmark-cluster-nap-46uk5hbn-407a41b6-55rv Instance: c4a-highmem-16 (12 vCPU / 65 GiB) uname: BENCH_COMMAND: cargo bench --features=arrow,async,test_common,experimental,object_store --bench interleave_kernelsCPU Details (lscpu)Resource Usagebase (merge-base)
branch
File an issue against this benchmark runner |
65a3b88 to
ee94246
Compare
jayzhan211
left a comment
There was a problem hiding this comment.
@Rich-T-kid thanks for this. Reusing the values Arc when every input shares it is a clear win (2.04 → 1.08 µs for two slices locally, matching the bot runs). I'd like the referenced-input scan dropped from this PR, since it slows down inputs with distinct mappings (details in the thread on referenced_shared_dictionary_values), plus one missing test.
Once the scan is gone, could you update the description to match? Its "What changes" paragraph and test list still describe ignoring unused and all-null inputs.
20a68ff to
ff3010e
Compare
|
run benchmark interleave_kernels |
|
🤖 Benchmark starting (GKE) | trigger Target: interleave_kernels Sharding factor: 1 (1 workers). Comparing ff3010e (ff3010e) to 4661ae7 diff Run configurationrun benchmark interleave_kernels
baseline:
ref: 4661ae77c184d470f5c6fe65ecf5a373f73f8c98
changed:
ref: ff3010e071d7a6aa3e8a829e01c1dae7c64f1715
env:
BENCH_FILTER: interleave dict
shards: 1
Results will be posted when all workers finish. File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Target: interleave_kernels Comparing ff3010e (ff3010e) to 4661ae7 diff Run configurationrun benchmark interleave_kernels
baseline:
ref: 4661ae77c184d470f5c6fe65ecf5a373f73f8c98
changed:
ref: ff3010e071d7a6aa3e8a829e01c1dae7c64f1715
env:
BENCH_FILTER: interleave dict
shards: 1
DetailsPer-runner informationinterleave_kernels — shard 1/1Node: gk3-benchmark-cluster-nap-145kr8p5-4d3e9c1b-p6ql Instance: c4a-highmem-16 (12 vCPU / 65 GiB) uname: BENCH_COMMAND: cargo bench --features=arrow,async,test_common,experimental,object_store --bench interleave_kernelsCPU Details (lscpu)Resource Usagebase (merge-base)
branch
File an issue against this benchmark runner |
|
thanks for the review @alamb & @jayzhan211, Ive addressed all your comments. as for downstream affects of this change, ill try to open a datafusion PR that exercises this code path and share any results I find. |
There was a problem hiding this comment.
🟡 Changes recommended
The implementation still checks all input dictionaries rather than only the referenced valid mappings, causing unrelated retained inputs to disable the intended shared-dictionary optimization.
1 open issue
Review effort: Lite
alamb
left a comment
There was a problem hiding this comment.
Thank you @Rich-T-kid -- this now looks good to me
jayzhan211
left a comment
There was a problem hiding this comment.
@Rich-T-kid thanks for the update. One change before merge: the shared-values check only matches values in the same Arc, so dictionaries from arrow's own zip (and concat outputs) still get their values concatenated.
Optional: since the referenced-input scan was dropped, Part of #12056 instead of Closes #12056 would keep the issue's unreferenced and all-null input case tracked.
|
run benchmark interleave_kernels |
|
🤖 Benchmark starting (GKE) | trigger Target: interleave_kernels Sharding factor: 1 (1 workers). Comparing 37b9ed7 (37b9ed7) to 4661ae7 diff Run configurationrun benchmark interleave_kernels
baseline:
ref: 4661ae77c184d470f5c6fe65ecf5a373f73f8c98
changed:
ref: 37b9ed7207984c59284f80ce8e1bf404c5e51a0d
env:
BENCH_FILTER: interleave dict
shards: 1
Trigger commentResults will be posted when all workers finish. File an issue against this benchmark runner |
|
🤖 Benchmark completed (GKE) | trigger Target: interleave_kernels Comparing 37b9ed7 (37b9ed7) to 4661ae7 diff Run configurationrun benchmark interleave_kernels
baseline:
ref: 4661ae77c184d470f5c6fe65ecf5a373f73f8c98
changed:
ref: 37b9ed7207984c59284f80ce8e1bf404c5e51a0d
env:
BENCH_FILTER: interleave dict
shards: 1
Trigger commentDetailsPer-runner informationinterleave_kernels — shard 1/1Node: gk3-benchmark-cluster-nap-10ma44s8-7e908d43-2czx Instance: c4a-highmem-16 (12 vCPU / 65 GiB) uname: BENCH_COMMAND: cargo bench --features=arrow,async,test_common,experimental,object_store --bench interleave_kernelsCPU Details (lscpu)Resource Usagebase (merge-base)
branch
File an issue against this benchmark runner |
|
@jayzhan211 PTAL 🙇 |
jayzhan211
left a comment
There was a problem hiding this comment.
@Rich-T-kid thanks for the update. The buffer check works: zip of two dictionaries that share 10 string values now keeps 10 values instead of 20, and Miri passes on the dictionary interleave tests. One ask before merge: a test for values that share buffers but not nulls (inline on dictionary.rs).
Optional: the description still covers only the shared-Arc case. Could you update it to match the last commit?
- Rationale, first sentence: "
interleavecurrently concatenates dictionary values even when every input uses the same values: the sameArc, or the same buffers in differentArcs, aszipandArrayDataround trips produce." - What changes: "When every input's values array is the same
Arcor, for byte and primitive values, has the same buffers and null buffer,interleavekeeps the first input's values and interleaves the keys directly." - Tests: add the
ArrayDataround-trip (Utf8, Int64) andUtf8Viewreuse tests. - Benchmark row: the latest run shows shared mappings 1.6–4.1x faster and the distinct cases between 1% slower and 5% faster.

Which issue does this PR close?
Part of #12056.
Rationale for this change
interleavecurrently concatenates dictionary values even when every input uses the same values: the sameArc, or the same buffers in differentArcs, aszipandArrayDataround trips produce. Slices of one dictionary therefore duplicate an unchanged mapping and offset keys that can be reused directly.One way this reaches Arrow is a DataFusion aggregation over a dictionary-encoded column:
A typical multi-partition physical plan is:
DictionaryArray::sliceslices the keys but clones the valuesArc. The dictionaryfilterandtakepaths behave the same way:In the partial
AggregateExec, DataFusion'sArrayAggGroupsAccumulatorfollows this path:When several input batches were sliced or filtered from the same dictionary, the partial aggregate therefore passes their different key buffers backed by the same
Arc Vdirectly tointerleave. The final aggregate can call the same accumulator path again when it merges the partial list states, although whether those mappings still share anArcdepends on the inputs.DataFusion's sort merge path also calls
interleavefor each output column. With RLE-to-dictionary decoding enabled, the best query-level candidates are ClickBench Q23-Q26, TPC-H Q2/Q10/Q16, and TPC-DS Q10/Q12/Q18/Q20/Q43/Q62/Q91/Q98/Q99. These queries sort or merge filtered, joined, or grouped rows while carrying dictionary-friendly string columns, so their batches can have different key buffers backed by the same valuesArc. These are expected candidates rather than measured suite results.What changes are included in this PR?
When every input's values array is the same
Arcor, for byte and primitive values, has the same buffers and null buffer,interleavekeeps the first input's values and interleaves the keys directly. Key nulls are preserved. This check includes inputs that contribute no selected valid key, so an unused or all-null input with a different values mapping keeps the existing fallback. The merge path now builds its value masks in one pass over the selected indices.Are these changes tested?
The tests cover shared-values reuse through the same
Arc,ArrayDataround trips for UTF-8 and Int64 values, andUtf8Viewreuse. They also cover original key and null preservation, empty values arrays, and artificial key overflow, and verify that distinct mappings still report key overflow.interleave dictAre there any significant user-facing changes?
No.