You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Optimize CometBroadcastHashJoin: use CollectLeft partition mode and cache deserialized broadcast batches #3692
CometBroadcastHashJoin has two significant performance bottlenecks:
1. Native side always uses PartitionMode::Partitioned for broadcast joins
In planner.rs:1673, all hash joins are hardcoded to PartitionMode::Partitioned. DataFusion supports PartitionMode::CollectLeft which is specifically designed for broadcast joins — it skips repartitioning and builds the hash table directly from the collected (broadcast) side. The protobuf schema (operator.proto:331-337) also has no field to distinguish broadcast from shuffled joins.
2. Per-task deserialization of broadcast data with no caching
In CometBroadcastExchangeExec.scala:312-315, every task independently deserializes the entire broadcast payload via Utils.decodeBatches(). There is no executor-level caching of deserialized Arrow batches between tasks on the same executor. With N partitions, the same broadcast data is deserialized N times per executor.
Additional context
The broadcast data also goes through a triple serialization cycle:
Child output → serialized to ChunkedByteBuffer
Broadcast to executors
Deserialized per task back to Arrow batches
Then fed through JNI/Arrow FFI to native code
Proposed changes
Add an is_broadcast field to the HashJoin protobuf message and use PartitionMode::CollectLeft on the native side for broadcast joins
Cache deserialized broadcast batches at the executor level to avoid re-decoding the same data for every task
Thanks for writing this up, @andygrove! I'm not sure the CollectLeft is going to affect the join execution much since I think it's mostly related to DataFusion's optimizer, but it is more correct to set it, I suppose.
The second optimization will hopefully be a win though.
Also I think issue two only discusses the deserialization issue. There is still the serialization issue of per-partition creating IPC writers, writing a batch, etc. Ideally we want to
only use one IPC writer
(optional) concatenate the batches on the driver side using Arrow Java.
I had a brief look at this with Claude yesterday, but did not make any meaningful progress. I am going to focus on fixing the remaining native_datafusion failures for now.
Activity
mbutrovich commentedon Mar 13, 2026
Thanks for writing this up, @andygrove! I'm not sure the
CollectLeftis going to affect the join execution much since I think it's mostly related to DataFusion's optimizer, but it is more correct to set it, I suppose.The second optimization will hopefully be a win though.
mbutrovich commentedon Mar 13, 2026
Also I think issue two only discusses the deserialization issue. There is still the serialization issue of per-partition creating IPC writers, writing a batch, etc. Ideally we want to
andygrove commentedon Mar 14, 2026
I had a brief look at this with Claude yesterday, but did not make any meaningful progress. I am going to focus on fixing the remaining
native_datafusionfailures for now.mbutrovich commentedon Mar 14, 2026
No worries. I can take a look next week as well. Thanks for chipping away at the native_DataFusion tasks!