Commit d61be49
authored
perf: Optimize NULL handling in
## Which issue does this PR close?
- Closes #21463.
## Rationale for this change
`find_in_set` uses `PrimitiveArray::<T>::builder` to construct its
results, which means building the internal null buffer in an iterative
fashion (via repeated `append_null` calls). It is more efficient to
construct the null buffer directly, via `NullBuffer::union` (when
multiple arguments might be NULL) or just cloning the input null buffer
(when passed a single argument).
Benchmarks (ARM64):
```
- find_in_set/string_len_8: 589.0 µs → 529.0 µs (-10.2%)
- find_in_set/string_len_32: 736.2 µs → 660.5 µs (-10.3%)
- find_in_set/string_len_1024: 7.5 ms → 7.4 ms (-1.3%)
- find_in_set/string_view_len_8: 616.0 µs → 579.9 µs (-5.9%)
- find_in_set/string_view_len_32: 748.0 µs → 701.9 µs (-6.2%)
- find_in_set/string_view_len_1024: 7.6 ms → 7.6 ms (0.0%)
- find_in_set_scalar/string_len_8: 76.7 µs → 48.0 µs (-37.4%)
- find_in_set_scalar/string_len_32: 76.5 µs → 47.6 µs (-37.8%)
- find_in_set_scalar/string_len_1024: 76.2 µs → 48.0 µs (-37.0%)
- find_in_set_scalar/string_view_len_8: 81.9 µs → 55.7 µs (-32.0%)
- find_in_set_scalar/string_view_len_32: 85.5 µs → 56.8 µs (-33.6%)
- find_in_set_scalar/string_view_len_1024: 85.2 µs → 57.4 µs (-32.6%)
```
The change should be an improvement for both scalar and array cases. The
relative improvement is larger in the scalar case because the scalar
case is doing less work and so NULL handling was a larger fraction of
the total runtime.
## What changes are included in this PR?
* Optimize NULL handling for both scalar and array arg cases
## Are these changes tested?
Yes.
## Are there any user-facing changes?
No.find_in_set (#21464)1 parent b46634c commit d61be49
1 file changed
+52
-47
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
| 21 | + | |
23 | 22 | | |
24 | 23 | | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
268 | | - | |
| 268 | + | |
269 | 269 | | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
289 | 288 | | |
290 | | - | |
| 289 | + | |
291 | 290 | | |
292 | 291 | | |
293 | 292 | | |
294 | 293 | | |
295 | 294 | | |
296 | 295 | | |
297 | | - | |
| 296 | + | |
298 | 297 | | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
305 | 308 | | |
306 | 309 | | |
307 | 310 | | |
308 | 311 | | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
313 | 315 | | |
314 | | - | |
| 316 | + | |
315 | 317 | | |
316 | 318 | | |
317 | 319 | | |
| |||
321 | 323 | | |
322 | 324 | | |
323 | 325 | | |
324 | | - | |
| 326 | + | |
325 | 327 | | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
332 | 338 | | |
333 | 339 | | |
334 | 340 | | |
335 | 341 | | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
340 | 345 | | |
341 | | - | |
| 346 | + | |
342 | 347 | | |
343 | 348 | | |
344 | 349 | | |
| |||
0 commit comments