Skip to content

Commit 2042042

Browse files
Merge pull request #7 from lemire/master
Introducing a branchless version of bloom + tweaking the simple block…
2 parents e20eec7 + da9c69e commit 2042042

File tree

2 files changed

+164
-140
lines changed

2 files changed

+164
-140
lines changed

benchmarks/bulk-insert-and-query.cc

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,9 @@ struct FilterAPI<GQFilter<ItemType, bits_per_item, HashFamily>> {
468468
};
469469
#endif
470470

471-
template <typename ItemType, size_t bits_per_item, typename HashFamily>
472-
struct FilterAPI<BloomFilter<ItemType, bits_per_item, HashFamily>> {
473-
using Table = BloomFilter<ItemType, bits_per_item, HashFamily>;
471+
template <typename ItemType, size_t bits_per_item, bool branchless, typename HashFamily>
472+
struct FilterAPI<BloomFilter<ItemType, bits_per_item, branchless, HashFamily>> {
473+
using Table = BloomFilter<ItemType, bits_per_item, branchless, HashFamily>;
474474
static Table ConstructFromAddCount(size_t add_count) { return Table(add_count); }
475475
static void Add(uint64_t key, Table* table) {
476476
table->Add(key);
@@ -710,7 +710,8 @@ int main(int argc, char * argv[]) {
710710
{11,"sort"}, {12,"Xor+8"}, {13,"Xor+16"},
711711
{14,"GCS"}, {22, "Xor10 (NBitArray)"}, {23, "Xor14 (NBitArray)"},
712712
{25, "Xor10"},{26, "Xor10.666"}, {37,"Bloom8 (addall)"},
713-
{38,"Bloom12 (addall)"},
713+
{38,"Bloom12 (addall)"}, {43,"Branchless Bloom8 (addall)"},
714+
{41,"Branchless Bloom12 (addall)"},{42,"Branchless Bloom16 (addall)"},
714715
{40,"BlockedBloom (addall)"},
715716
{70,"SimpleBlockedBloom"}
716717
};
@@ -722,7 +723,8 @@ int main(int argc, char * argv[]) {
722723
{11,"sort"}, {12,"Xor+8"}, {13,"Xor+16"},
723724
{14,"GCS"}, {15,"CQF"}, {22, "Xor10 (NBitArray)"}, {23, "Xor14 (NBitArray)"},
724725
{25, "Xor10"},{26, "Xor10.666"}, {37,"Bloom8 (addall)"},
725-
{38,"Bloom12 (addall)"},{39,"Bloom16 (addall)"},
726+
{38,"Bloom12 (addall)"},{39,"Bloom16 (addall)"}, {43,"Branchless Bloom8 (addall)"},
727+
{41,"Branchless Bloom12 (addall)"},{42,"Branchless Bloom16 (addall)"},
726728
{40,"BlockedBloom (addall)"}, {63,"BlockedBloom16"}, {64,"BlockedBloom64"},
727729
{70,"SimpleBlockedBloom"}
728730
};
@@ -734,7 +736,8 @@ int main(int argc, char * argv[]) {
734736
{11,"sort"}, {12,"Xor+8"}, {13,"Xor+16"},
735737
{14,"GCS"}, {22, "Xor10 (NBitArray)"}, {23, "Xor14 (NBitArray)"},
736738
{25, "Xor10"},{26, "Xor10.666"}, {37,"Bloom8 (addall)"},
737-
{38,"Bloom12 (addall)"},{39,"Bloom16 (addall)"},
739+
{38,"Bloom12 (addall)"},{39,"Bloom16 (addall)"}, {43,"Branchless Bloom8 (addall)"},
740+
{41,"Branchless Bloom12 (addall)"},{42,"Branchless Bloom16 (addall)"},
738741
{70,"SimpleBlockedBloom"}
739742
};
740743
#endif
@@ -933,21 +936,21 @@ int main(int argc, char * argv[]) {
933936

934937
if (algorithmId == 7 || algorithmId < 0 || (algos.find(7) != algos.end())) {
935938
auto cf = FilterBenchmark<
936-
BloomFilter<uint64_t, 8, SimpleMixSplit>>(
939+
BloomFilter<uint64_t, 8, false, SimpleMixSplit>>(
937940
add_count, to_add, distinct_add, to_lookup, distinct_lookup, intersectionsize, hasduplicates, mixed_sets, seed);
938941
cout << setw(NAME_WIDTH) << names[7] << cf << endl;
939942
}
940943

941944
if (algorithmId == 8 || algorithmId < 0 || (algos.find(8) != algos.end())) {
942945
auto cf = FilterBenchmark<
943-
BloomFilter<uint64_t, 12, SimpleMixSplit>>(
946+
BloomFilter<uint64_t, 12, false, SimpleMixSplit>>(
944947
add_count, to_add, distinct_add, to_lookup, distinct_lookup, intersectionsize, hasduplicates, mixed_sets, seed);
945948
cout << setw(NAME_WIDTH) << names[8]<< cf << endl;
946949
}
947950

948951
if (algorithmId == 9 || algorithmId < 0 || (algos.find(9) != algos.end())) {
949952
auto cf = FilterBenchmark<
950-
BloomFilter<uint64_t, 16, SimpleMixSplit>>(
953+
BloomFilter<uint64_t, 16, false, SimpleMixSplit>>(
951954
add_count, to_add, distinct_add, to_lookup, distinct_lookup, intersectionsize, hasduplicates, mixed_sets, seed);
952955
cout << setw(NAME_WIDTH) << names[9] << cf << endl;
953956
}
@@ -1079,7 +1082,7 @@ int main(int argc, char * argv[]) {
10791082
add_count, to_add, distinct_add, to_lookup, distinct_lookup, intersectionsize, hasduplicates, mixed_sets, seed, true);
10801083
cout << setw(NAME_WIDTH) << names[23] << cf << endl;
10811084
}
1082-
if (algorithmId == 70 || (algos.find(70) != algos.end())) {
1085+
if (algorithmId == 70 || algorithmId < 0 || (algos.find(70) != algos.end())) {
10831086
auto cf = FilterBenchmark<
10841087
SimpleBlockFilter<8, 8, SimpleMixSplit>>(
10851088
add_count, to_add, distinct_add, to_lookup, distinct_lookup, intersectionsize, hasduplicates, mixed_sets, seed, false);
@@ -1118,25 +1121,47 @@ int main(int argc, char * argv[]) {
11181121

11191122
if (algorithmId == 37 || algorithmId < 0 || (algos.find(37) != algos.end())) {
11201123
auto cf = FilterBenchmark<
1121-
BloomFilter<uint64_t, 8, SimpleMixSplit>>(
1124+
BloomFilter<uint64_t, 8, false, SimpleMixSplit>>(
11221125
add_count, to_add, distinct_add, to_lookup, distinct_lookup, intersectionsize, hasduplicates, mixed_sets, seed, true);
11231126
cout << setw(NAME_WIDTH) << names[37] << cf << endl;
11241127
}
11251128

11261129
if (algorithmId == 38 || algorithmId < 0 || (algos.find(38) != algos.end())) {
11271130
auto cf = FilterBenchmark<
1128-
BloomFilter<uint64_t, 12, SimpleMixSplit>>(
1131+
BloomFilter<uint64_t, 12, false, SimpleMixSplit>>(
11291132
add_count, to_add, distinct_add, to_lookup, distinct_lookup, intersectionsize, hasduplicates, mixed_sets, seed, true);
11301133
cout << setw(NAME_WIDTH) << names[38] << cf << endl;
11311134
}
11321135

11331136
if (algorithmId == 39 || algorithmId < 0 || (algos.find(39) != algos.end())) {
11341137
auto cf = FilterBenchmark<
1135-
BloomFilter<uint64_t, 16, SimpleMixSplit>>(
1138+
BloomFilter<uint64_t, 16, false, SimpleMixSplit>>(
11361139
add_count, to_add, distinct_add, to_lookup, distinct_lookup, intersectionsize, hasduplicates, mixed_sets, seed, true);
11371140
cout << setw(NAME_WIDTH) << names[39] << cf << endl;
11381141
}
11391142

1143+
1144+
1145+
if (algorithmId == 43 || algorithmId < 0 || (algos.find(43) != algos.end())) {
1146+
auto cf = FilterBenchmark<
1147+
BloomFilter<uint64_t, 8, false, SimpleMixSplit>>(
1148+
add_count, to_add, distinct_add, to_lookup, distinct_lookup, intersectionsize, hasduplicates, mixed_sets, seed, true);
1149+
cout << setw(NAME_WIDTH) << names[43] << cf << endl;
1150+
}
1151+
1152+
if (algorithmId == 41 || algorithmId < 0 || (algos.find(41) != algos.end())) {
1153+
auto cf = FilterBenchmark<
1154+
BloomFilter<uint64_t, 12, false, SimpleMixSplit>>(
1155+
add_count, to_add, distinct_add, to_lookup, distinct_lookup, intersectionsize, hasduplicates, mixed_sets, seed, true);
1156+
cout << setw(NAME_WIDTH) << names[41] << cf << endl;
1157+
}
1158+
1159+
if (algorithmId == 42 || algorithmId < 0 || (algos.find(42) != algos.end())) {
1160+
auto cf = FilterBenchmark<
1161+
BloomFilter<uint64_t, 16, false, SimpleMixSplit>>(
1162+
add_count, to_add, distinct_add, to_lookup, distinct_lookup, intersectionsize, hasduplicates, mixed_sets, seed, true);
1163+
cout << setw(NAME_WIDTH) << names[42] << cf << endl;
1164+
}
11401165
#ifdef __AVX2__
11411166
if (algorithmId == 40 || algorithmId < 0 || (algos.find(40) != algos.end())) {
11421167
auto cf = FilterBenchmark<SimdBlockFilterFixed<SimpleMixSplit>>(

0 commit comments

Comments
 (0)