Commit 8cc8c11
authored
Optimize muti-column grouping with StringView/ByteView (option 2) - 25% faster (#19413)
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closes #123` indicates that this PR will close issue #123.
-->
- Part of #18411
- Closes #19344
- Closes #19364
Note this is an alternate to
#19364
## Rationale for this change
@camuel found a query where DuckDB's raw grouping is is faster.
I looked into it and much of the difference can be explained by better
vectorization in the comparisons and short string optimizations
## What changes are included in this PR?
Optimize (will comment inline)
## Are these changes tested?
By CI. See also benchmark results below. I tested manually as well
Create Data:
```shell
nice tpchgen-cli --tables=lineitem --format=parquet --scale-factor 100
```
Run query:
```shell
hyperfine --warmup 3 " datafusion-cli -c \"select l_returnflag,l_linestatus, count(*) as count_order from 'lineitem.parquet' group by l_returnflag, l_linestatus;\" "
```
Before (main): 1.368s
```shell
Benchmark 1: datafusion-cli -c "select l_returnflag,l_linestatus, count(*) as count_order from 'lineitem.parquet' group by l_returnflag, l_linestatus;"
Time (mean ± σ): 1.393 s ± 0.020 s [User: 16.778 s, System: 0.688 s]
Range (min … max): 1.368 s … 1.438 s 10 runs
```
After (this PR) 1.022s
```shell
Benchmark 1: ./datafusion-cli-multi-gby-try2 -c "select l_returnflag,l_linestatus, count(*) as count_order from 'lineitem.parquet' group by l_returnflag, l_linestatus;"
Time (mean ± σ): 1.022 s ± 0.015 s [User: 11.685 s, System: 0.644 s]
Range (min … max): 1.005 s … 1.052 s 10 runs
```
I have a PR that improves string view hashing performance too, see
- #19374
## Are there any user-facing changes?
Faster performance1 parent 5419ff5 commit 8cc8c11
File tree
1 file changed
+78
-43
lines changed- datafusion/physical-plan/src/aggregates/group_values/multi_group_by
1 file changed
+78
-43
lines changedLines changed: 78 additions & 43 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
| 103 | + | |
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
| |||
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
120 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
121 | 125 | | |
122 | 126 | | |
123 | | - | |
| 127 | + | |
124 | 128 | | |
125 | 129 | | |
126 | 130 | | |
127 | | - | |
128 | | - | |
129 | 131 | | |
130 | 132 | | |
131 | 133 | | |
| |||
138 | 140 | | |
139 | 141 | | |
140 | 142 | | |
141 | | - | |
| 143 | + | |
| 144 | + | |
142 | 145 | | |
143 | 146 | | |
144 | 147 | | |
| |||
216 | 219 | | |
217 | 220 | | |
218 | 221 | | |
219 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
220 | 229 | | |
221 | 230 | | |
222 | 231 | | |
223 | 232 | | |
224 | 233 | | |
225 | 234 | | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
230 | 241 | | |
231 | 242 | | |
232 | 243 | | |
233 | | - | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
234 | 247 | | |
235 | 248 | | |
236 | | - | |
| 249 | + | |
237 | 250 | | |
238 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
239 | 258 | | |
240 | 259 | | |
241 | 260 | | |
| |||
246 | 265 | | |
247 | 266 | | |
248 | 267 | | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
| 268 | + | |
| 269 | + | |
262 | 270 | | |
263 | 271 | | |
264 | 272 | | |
| |||
269 | 277 | | |
270 | 278 | | |
271 | 279 | | |
| 280 | + | |
272 | 281 | | |
273 | 282 | | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
279 | 296 | | |
280 | 297 | | |
281 | 298 | | |
282 | 299 | | |
283 | 300 | | |
284 | 301 | | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | 302 | | |
297 | 303 | | |
298 | 304 | | |
| |||
507 | 513 | | |
508 | 514 | | |
509 | 515 | | |
510 | | - | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
511 | 546 | | |
512 | 547 | | |
513 | 548 | | |
| |||
0 commit comments