Commit dc6d28a
authored
[improvement](be) Eliminate redundant MultiCast block copies (#63580)
Related PR: #60386
Problem Summary: MultiCastDataStreamer already shares pulled blocks
through the column copy-on-write contract. The previous pull path still
cloned every column for each consumer through _copy_block(), which added
unnecessary per-consumer allocation and copy work. The copy-on-write
assertion changes and regression coverage from the original attempt are
already present on current master, so this change keeps the pull
completion accounting in _finish_pull() and returns the shared block
directly.
test performance with:
```sql
SET enable_profile = true;
SET profile_level = 2;
SET inline_cte_referenced_threshold = 0;
SET parallel_pipeline_task_num = 16;
WITH base AS (
SELECT id, k1, ..., k8, v01, ..., v24, s1, s2, s3, s4
FROM bench_cte_multicast_wide
WHERE id >= 0
)
SELECT 0 AS branch, COUNT(*),
SUM(id + k1 + ... + k8 + v01 + ... + v24),
SUM(LENGTH(s1) + LENGTH(s2) + LENGTH(s3) + LENGTH(s4))
FROM base WHERE k1 % 16 = 0
UNION ALL
...
UNION ALL
SELECT 15 AS branch, COUNT(*),
SUM(id + k1 + ... + k8 + v01 + ... + v24),
SUM(LENGTH(s1) + LENGTH(s2) + LENGTH(s3) + LENGTH(s4))
FROM base WHERE k1 % 16 = 15
ORDER BY branch;
```
result:
| version | min | median | avg | max |
|---|---:|---:|---:|---:|
| before | 1.450s | 1.470s | 1.472s | 1.500s |
| after | 0.720s | 0.735s | 0.737s | 0.760s |1 parent 5966c2e commit dc6d28a
2 files changed
Lines changed: 5 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | | - | |
| 154 | + | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
| 157 | + | |
164 | 158 | | |
165 | 159 | | |
166 | 160 | | |
| |||
402 | 396 | | |
403 | 397 | | |
404 | 398 | | |
405 | | - | |
| 399 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
101 | | - | |
| 100 | + | |
102 | 101 | | |
103 | 102 | | |
104 | 103 | | |
| |||
128 | 127 | | |
129 | 128 | | |
130 | 129 | | |
131 | | - | |
| 130 | + | |
0 commit comments