Repository navigation
Distributed query plan: deserialize exchange data on every stream of the receive - #119236
Conversation
The source of an exchange stream hands its packets on as one-row `String` chunks, and a deserializing transform behind a resize to `max_threads` turns them into data on every stream. Before, each source deserialized its sender's whole stream alone. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Workflow [PR], commit [8478cee] Summary: ❌
AI ReviewSummaryThis PR moves streaming-exchange deserialization out of Tests
Final Verdict
LLVM Coverage ReportMeasured on commit 8478cee.
Changed lines: Changed C/C++ lines covered: 420/435 (96.55%) · Uncovered code |
Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ops it Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Build profile diff (arm_release)Comparing commit See the job log for details. |
The merge of partial aggregation results behind a gather expects every sender's buckets on one input stream, in order. Spreading the received packets over `max_threads` streams made `GroupingAggregatedTransform` see a bucket twice. Co-Authored-By: Claude Fable 5.1 <[email protected]>
A real server, sink and source in all four serialize/deserialize pairings, the sender stalling at its pending cap, and a source facing malformed packets from a fake peer. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
📊 Cloud Performance Report ✅ AI verdict: The one flagged query (ClickBench Q16, +10.1%, median 557 -> 613.5 ms) was already suppressed deterministically as within master's current variance band, and that call holds up: the query has a noisy history, and this PR only reworks the distributed-query exchange receive path (new receiveExchangeStreams helper, per-stream deserializer transforms, end-of-stream packet handling) plus Docker version bumps and backport changelogs. A single-node ClickBench SELECT does not run any of that code, so the small consistent delta is run-to-run variance, not a PR effect. No regression is attributable to this change. clickbenchFlagged queries (1 of 43)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_official🟢 No significant changes Debug info
|
A real server, sink and source in all four serialize/deserialize pairings, the sender stalling at its pending cap, and a source facing malformed packets from a fake peer. Co-Authored-By: Claude Fable 5.1 <[email protected]> (cherry picked from commit c0247ec)
…rialization-deserialization # Conflicts: # src/Server/DistributedQuery/tests/gtest_streaming_exchange_transport.cpp
…rialization-deserialization # Conflicts: # src/Server/DistributedQuery/StreamingExchangeProtocol.cpp # src/Server/DistributedQuery/StreamingExchangeSource.cpp # src/Server/DistributedQuery/tests/gtest_streaming_exchange_transport.cpp
…rialization-deserialization # Conflicts: # src/Processors/QueryPlan/tests/gtest_shuffle_exchange_parallelism.cpp
…rialization-deserialization
…rialization-deserialization # Conflicts: # src/Processors/QueryPlan/tests/gtest_shuffle_exchange_parallelism.cpp
…rialization-deserialization # Conflicts: # tests/queries/0_stateless/05176_distributed_plan_exchange_layout.reference # tests/queries/0_stateless/05176_distributed_plan_exchange_layout.sql
Co-Authored-By: Claude Fable 5.1 <[email protected]>
…rialization-deserialization
Co-Authored-By: Claude Fable 5.1 <[email protected]>
…rialization-deserialization
…rialization-deserialization
| UNION ALL SELECT 3, 'scatter: serializers = scatters * sinks', min(serializers = scatters * sinks) FROM v_exchange_layout WHERE scatters > 0 | ||
| UNION ALL SELECT 4, 'scatter: max rows into one serializer <= max rows into one scatter', min(max_rows_into_serializer <= max_rows_into_scatter) FROM v_exchange_layout WHERE scatters > 0 | ||
| UNION ALL SELECT 5, 'broadcast: serializers = read streams and serialized rows = read rows', min(serializers = reads AND rows_serialized = rows_read) FROM v_exchange_layout WHERE sinks > 1 AND scatters = 0 | ||
| UNION ALL SELECT 6, 'receive: deserializers >= sources in every task', min(deserializers >= sources) FROM v_exchange_layout WHERE sources > 0 |
There was a problem hiding this comment.
These receive-side checks only prove that extra StreamingExchangeDeserializingTransform processors exist. They still pass if receiveExchangeStreams/resize(max_threads) instantiates idle deserializers while one source/deserializer pair keeps doing all of the row work, because nothing here checks input_rows on the deserializers or any before/after runtime.
The PR contract is receiver-side scaling on a few-sender / many-core task, so please add focused evidence that rows actually flow through more than one deserializer (or a small benchmark on that shape showing the old bottleneck is gone).
…rialization-deserialization
…rt test Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ge-parallel-serialization-deserialization
…e it Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ge-parallel-serialization-deserialization
When a distributed query plan receives data from other nodes, each sender has one exchange source, and that source decompressed and deserialized the sender's whole stream on one thread. With few senders this becomes the bottleneck of the receiving task: a task fed by 3 senders deserializes on 3 threads no matter how many cores it has, and the senders wait on it.
Now the source only receives the packets and hands them on as they are, and a deserializing transform turns the packets back into data. For the shuffle and the broadcast the packets are spread over
max_threadsstreams first, so the deserialization and the steps after it run on all threads of the task. The gather keeps one stream per source, with the deserializer behind it: a sorted gather merges its streams in order, and the merge of partial aggregation results needs the buckets of every sender on one input, in order. The initiator reads the final result the same way, on one stream, so anORDER BYresult arrives in order. The bytes on the wire are unchanged. In-memory and file-based exchanges keep working with plain chunks.The receiving side of the change in #119067; the diff includes that pull request until it is merged.
Related: #119067
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Distributed query plans (
make_distributed_plan) now deserialize the data received through shuffle and broadcast exchanges on all threads of the receiving task instead of one thread per sender. Gather exchanges keep one stream per sender, so ordered results and merged aggregation states stay in order. This removes a bottleneck when a query runs on a small number of workers.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/119236]