Commit 7fe6c1a
committed
perf: root BatchEqual in the existence bitmap and share plane work across values
Follow-up addressing review findings on the vectorized implementation.
Correctness: the per-value path built results from bitplane clones and
never intersected eBM, so columns present in a plane but absent from
the existence bitmap leaked into results. The checked-in testdata/age
fixture contains exactly this state (plane 4 holds 33.3M bits against
28.0M in eBM): BatchEqual(0, {16}) returned 454,521 columns, all of
them outside eBM, where the pre-optimization implementation returned
none. GetValue, CompareValue, Sum, and the original BatchEqual all
treat eBM as authoritative; the new implementation is rooted in eBM by
construction, and a regression test pins the invariant.
Scaling: the maxVectorizedBatchSize=128 crossover was inverted on large
datasets. Measured on the age fixture, the vectorized path at M=128
cost 3.6s / 2.1GB while the scalar fallback it guarded cost 0.59s: the
guard fired on list size when the real variable is data size. Both
thresholds and the scalar fallback path are deleted.
BatchEqual now descends the bitplanes from the most significant bit as
a binary trie over the sorted, deduplicated query values: each shared
value prefix is intersected once, subtrees whose every bit pattern is
queried collapse to a single operation, and empty intermediates prune
the recursion. Work is bounded by the size of the values' bit trie and
the data actually present rather than len(values) x BitCount().
testdata/age fixture (28M columns, 8 planes), 16 threads, -benchmem,
previous commit -> this commit:
M=2 {55,57} ~56ms / 33.5MB / 10.3k allocs -> ~50ms / 26.7MB / 8.2k
M=128 contiguous 3.6s / 2.1GB -> 1.2ms / 9.3MB
M=128 scattered 3.3s / 2.2GB -> 440ms / 283MB
M=200 (fallback) 590ms / 155MB -> 3.3ms / 9.5MB
The M=2 delta is within run-to-run noise; allocation counts are exact.
New benchmarks cover both sides of the deleted thresholds and both
contiguous and scattered value shapes.1 parent da86289 commit 7fe6c1a
2 files changed
Lines changed: 135 additions & 108 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
271 | 272 | | |
272 | 273 | | |
273 | 274 | | |
274 | | - | |
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
| |||
743 | 743 | | |
744 | 744 | | |
745 | 745 | | |
746 | | - | |
747 | | - | |
748 | | - | |
749 | | - | |
750 | | - | |
751 | | - | |
752 | | - | |
753 | | - | |
754 | | - | |
755 | | - | |
756 | | - | |
757 | | - | |
758 | | - | |
759 | | - | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
760 | 749 | | |
761 | 750 | | |
762 | 751 | | |
763 | 752 | | |
764 | 753 | | |
765 | | - | |
766 | | - | |
767 | | - | |
| 754 | + | |
768 | 755 | | |
769 | | - | |
770 | | - | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
771 | 760 | | |
772 | | - | |
773 | | - | |
774 | | - | |
775 | | - | |
776 | | - | |
777 | | - | |
778 | | - | |
779 | | - | |
780 | | - | |
781 | | - | |
782 | | - | |
783 | | - | |
784 | | - | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
785 | 767 | | |
| 768 | + | |
| 769 | + | |
786 | 770 | | |
787 | | - | |
788 | | - | |
| 771 | + | |
789 | 772 | | |
790 | 773 | | |
| 774 | + | |
791 | 775 | | |
792 | | - | |
793 | | - | |
794 | | - | |
795 | | - | |
796 | | - | |
797 | | - | |
798 | | - | |
799 | | - | |
800 | | - | |
801 | | - | |
802 | | - | |
803 | | - | |
804 | | - | |
805 | | - | |
806 | | - | |
807 | | - | |
808 | | - | |
809 | | - | |
810 | | - | |
811 | | - | |
812 | | - | |
813 | | - | |
814 | | - | |
| 776 | + | |
815 | 777 | | |
816 | | - | |
| 778 | + | |
817 | 779 | | |
818 | | - | |
| 780 | + | |
819 | 781 | | |
820 | 782 | | |
821 | | - | |
822 | | - | |
823 | | - | |
824 | | - | |
825 | | - | |
826 | | - | |
827 | | - | |
828 | | - | |
829 | | - | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
830 | 795 | | |
| 796 | + | |
831 | 797 | | |
832 | | - | |
833 | | - | |
834 | | - | |
835 | | - | |
836 | | - | |
837 | | - | |
838 | | - | |
839 | | - | |
840 | | - | |
841 | | - | |
842 | | - | |
843 | | - | |
844 | | - | |
845 | | - | |
846 | | - | |
847 | | - | |
848 | | - | |
849 | | - | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
850 | 833 | | |
| 834 | + | |
851 | 835 | | |
852 | | - | |
853 | | - | |
854 | | - | |
855 | | - | |
856 | | - | |
857 | | - | |
858 | | - | |
859 | | - | |
860 | | - | |
861 | | - | |
862 | | - | |
| 836 | + | |
| 837 | + | |
863 | 838 | | |
864 | | - | |
865 | | - | |
866 | | - | |
867 | | - | |
868 | | - | |
869 | | - | |
870 | | - | |
871 | | - | |
872 | | - | |
873 | | - | |
| 839 | + | |
874 | 840 | | |
875 | 841 | | |
876 | 842 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
0 commit comments