[ENHANCEMENT]: Test a naive approx count in multimap/multiset
Is your feature request related to a problem? Please describe.
Related to https://github.com/rapidsai/cudf/issues/10652.
I'm willing to test a naive fast approx count algorithm in cuco to see if it can help cudf hash join.
Describe the solution you'd like
Imagine we have 8 slots and 3 rows 1, 2 and 3. In a very extreme case, the hash value of all 3 rows is 2 thus we get a map filled like:
x x 1 2 3 x x x
The initial slot for all 3 rows is 2 and the first empty slot is 5. So the max count for each row is the cluster size: 5 - 2 = 3 and the total approx count is
3 + 3 + 3 = 9
This is a very extreme case and normally with double hashing and a fairly good hash function, collisions are rare so the map can be filled like
1 x 2 x x x 3 x
so the approx count is 1 + 1 + 1 = 3
This method is really "naive" but we can always get an approximate count no smaller than the actual count.
Additional context
- Could use the current accurate count as a backup if the approx count exceeds a certain threshold.
- The eventual count can explode if lots of collisions are present, but we are using double hashing in cudf hash join and the map occupancy is about 50%. Collisions shouldn't be significant in this case.
No response