Commit eaf0a41
authored
perf: Optimize NULL handling in
## Which issue does this PR close?
- Closes #21470.
## Rationale for this change
`array_has` uses `BooleanArray::builder` to construct its results. This
updates the NULL buffer in an incremental fashion (row-by-row). It is
more efficient to use `BooleanBufferBuilder` to construct the results
and separately construct the output NULL buffer via `NullBuffer::union`
or similar.
Benchmarks (AR64):
```
array_has_i64 (scalar needle path)
- found/10: 51.7 µs -> 49.2 µs, -4.7%
- not_found/10: 43.2 µs -> 40.0 µs, -7.2%
- found/100: 162.0 µs -> 152.3 µs, -6.3%
- not_found/100: 143.1 µs -> 135.8 µs, -5.2%
- found/500: 623.4 µs -> 572.5 µs, -8.4%
- not_found/500: 593.4 µs -> 560.5 µs, -5.5%
array_has_all (row-converter path)
- all_found_small_needle/10: 699.4 µs -> 641.1 µs, -8.1%
- not_all_found/10: 533.3 µs -> 470.7 µs, -9.5%
- all_found_small_needle/100: 5.94 ms -> 4.49 ms, -24.4%
- not_all_found/100: 4.60 ms -> 3.83 ms, -16.7%
- all_found_small_needle/500: 34.6 ms -> 31.7 ms, -8.3%
- not_all_found/500: 30.4 ms -> 28.4 ms, -6.7%
array_has_any (row-converter path)
- some_match/10: 619.7 µs -> 563.2 µs, -9.5%
- no_match/10: 1.11 ms -> 1.04 ms, -0.1%
- scalar_some_match/10: 467.4 µs -> 444.6 µs, -4.2%
- scalar_no_match/10: 1.15 ms -> 994.5 µs, -14.5%
- some_match/100: 4.98 ms -> 4.35 ms, -12.6%
- no_match/100: 10.47 ms -> 8.90 ms, -15.0%
- scalar_some_match/100: 4.63 ms -> 4.19 ms, -9.4%
- scalar_no_match/100: 10.40 ms -> 9.98 ms, -4.1%
- some_match/500: 31.8 ms -> 28.9 ms, -9.1%
- no_match/500: 66.1 ms -> 58.3 ms, -11.8%
- scalar_some_match/500: 25.6 ms -> 23.5 ms, -8.3%
- scalar_no_match/500: 58.8 ms -> 54.1 ms, -8.0%
array_has_strings (scalar needle path)
- found/10: 396.3 µs -> 364.7 µs, -8.5%
- not_found/10: 69.9 µs -> 67.5 µs, -3.6%
- found/100: 1.34 ms -> 1.25 ms, -7.0%
- not_found/100: 2.53 ms -> 2.37 ms, -6.1%
- found/500: 3.36 ms -> 3.11 ms, -7.5%
- not_found/500: 8.59 ms -> 8.12 ms, -5.5%
array_has_all_strings (string fast path)
- all_found/10: 1.08 ms -> 1.01 ms, -7.7%
- not_all_found/10: 659.0 µs -> 632.5 µs, -3.9%
- all_found/100: 5.50 ms -> 5.24 ms, -4.6%
- not_all_found/100: 4.77 ms -> 4.58 ms, -4.0%
- all_found/500: 27.4 ms -> 26.2 ms, -4.6%
- not_all_found/500: 30.0 ms -> 28.8 ms, -3.9%
array_has_any_strings (string fast path)
- some_match/10: 946.5 µs -> 872.9 µs, -6.7%
- no_match/10: 1.20 ms -> 1.12 ms, -6.0%
- scalar_some_match/10: 420.4 µs -> 375.7 µs, -8.7%
- scalar_no_match/10: 344.0 µs -> 309.5 µs, -10.1%
- some_match/100: 4.93 ms -> 4.76 ms, -3.4%
- no_match/100: 8.76 ms -> 8.50 ms, -2.9%
- scalar_some_match/100: 1.49 ms -> 1.40 ms, -6.0%
- scalar_no_match/100: 2.94 ms -> 2.72 ms, -7.8%
- some_match/500: 24.0 ms -> 23.4 ms, -2.7%
- no_match/500: 57.0 ms -> 55.8 ms, -2.1%
- scalar_some_match/500: 5.45 ms -> 5.07 ms, -7.0%
- scalar_no_match/500: 34.5 ms -> 32.9 ms, -4.5%
array_has_any_scalar (varying scalar size)
- i64_no_match/1: 173.7 µs -> 162.6 µs, -4.3%
- i64_no_match/10: 139.8 µs -> 125.7 µs, -9.5%
- i64_no_match/100: 264.8 µs -> 253.7 µs, -4.6%
- i64_no_match/1000: 155.4 µs -> 142.4 µs, -8.0%
- string_no_match/1: 125.1 µs -> 107.5 µs, -14.3%
- string_no_match/10: 164.8 µs -> 147.0 µs, -10.1%
- string_no_match/100: 257.8 µs -> 243.4 µs, -5.8%
- string_no_match/1000: 180.9 µs -> 164.5 µs, -8.9%
```
## What changes are included in this PR?
* Implement optimization, minor code cleanup
## Are these changes tested?
Yes.
## Are there any user-facing changes?
No.array_has (#21471)1 parent 1929d71 commit eaf0a41
1 file changed
+34
-38
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
314 | 314 | | |
315 | 315 | | |
316 | 316 | | |
317 | | - | |
| 317 | + | |
318 | 318 | | |
319 | 319 | | |
320 | 320 | | |
| |||
327 | 327 | | |
328 | 328 | | |
329 | 329 | | |
330 | | - | |
| 330 | + | |
| 331 | + | |
331 | 332 | | |
332 | | - | |
333 | | - | |
| 333 | + | |
| 334 | + | |
334 | 335 | | |
335 | 336 | | |
336 | 337 | | |
337 | 338 | | |
338 | 339 | | |
339 | 340 | | |
340 | | - | |
| 341 | + | |
341 | 342 | | |
342 | 343 | | |
343 | | - | |
| 344 | + | |
344 | 345 | | |
345 | 346 | | |
346 | 347 | | |
| |||
435 | 436 | | |
436 | 437 | | |
437 | 438 | | |
438 | | - | |
439 | | - | |
440 | | - | |
| 439 | + | |
| 440 | + | |
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
| |||
460 | 460 | | |
461 | 461 | | |
462 | 462 | | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
| 463 | + | |
| 464 | + | |
467 | 465 | | |
468 | 466 | | |
469 | | - | |
| 467 | + | |
470 | 468 | | |
471 | 469 | | |
472 | 470 | | |
| |||
476 | 474 | | |
477 | 475 | | |
478 | 476 | | |
479 | | - | |
| 477 | + | |
480 | 478 | | |
481 | 479 | | |
482 | 480 | | |
| |||
490 | 488 | | |
491 | 489 | | |
492 | 490 | | |
493 | | - | |
494 | | - | |
495 | | - | |
| 491 | + | |
| 492 | + | |
496 | 493 | | |
497 | 494 | | |
498 | 495 | | |
| |||
513 | 510 | | |
514 | 511 | | |
515 | 512 | | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
| 513 | + | |
| 514 | + | |
520 | 515 | | |
521 | 516 | | |
522 | 517 | | |
523 | 518 | | |
524 | 519 | | |
525 | 520 | | |
526 | | - | |
| 521 | + | |
527 | 522 | | |
528 | 523 | | |
529 | 524 | | |
530 | 525 | | |
531 | 526 | | |
532 | 527 | | |
533 | 528 | | |
534 | | - | |
| 529 | + | |
535 | 530 | | |
536 | 531 | | |
537 | 532 | | |
| |||
687 | 682 | | |
688 | 683 | | |
689 | 684 | | |
690 | | - | |
| 685 | + | |
691 | 686 | | |
692 | 687 | | |
693 | 688 | | |
694 | 689 | | |
695 | | - | |
| 690 | + | |
696 | 691 | | |
697 | 692 | | |
698 | 693 | | |
699 | | - | |
| 694 | + | |
700 | 695 | | |
701 | 696 | | |
702 | 697 | | |
| |||
708 | 703 | | |
709 | 704 | | |
710 | 705 | | |
711 | | - | |
| 706 | + | |
712 | 707 | | |
713 | 708 | | |
714 | | - | |
| 709 | + | |
715 | 710 | | |
716 | 711 | | |
717 | 712 | | |
| |||
734 | 729 | | |
735 | 730 | | |
736 | 731 | | |
737 | | - | |
| 732 | + | |
738 | 733 | | |
739 | 734 | | |
740 | 735 | | |
| |||
745 | 740 | | |
746 | 741 | | |
747 | 742 | | |
748 | | - | |
| 743 | + | |
749 | 744 | | |
750 | 745 | | |
751 | 746 | | |
752 | 747 | | |
753 | 748 | | |
754 | 749 | | |
755 | | - | |
| 750 | + | |
756 | 751 | | |
757 | 752 | | |
758 | 753 | | |
759 | 754 | | |
760 | 755 | | |
761 | | - | |
| 756 | + | |
762 | 757 | | |
763 | 758 | | |
764 | 759 | | |
765 | 760 | | |
766 | 761 | | |
767 | 762 | | |
768 | | - | |
| 763 | + | |
769 | 764 | | |
770 | 765 | | |
771 | 766 | | |
772 | | - | |
| 767 | + | |
| 768 | + | |
773 | 769 | | |
774 | 770 | | |
775 | 771 | | |
776 | | - | |
| 772 | + | |
777 | 773 | | |
778 | 774 | | |
779 | | - | |
| 775 | + | |
780 | 776 | | |
781 | 777 | | |
782 | 778 | | |
| |||
0 commit comments