Skip to content

count the number of collisions in densh_hash_map #43

Description

@liuzqt

I want to find out how 'bad' the collision happened in a dense_hash_map.

I found my dense_hash_map performance drop dramatically in some continuous key range (it's almost 10-15x slower) so I suppose there're bad collision happened in these key ranges. So I want to know how bad it's, as a hint to determine whether I need to rehash, or choose a better hash func.

in std::unordered_map I can do

std::unordered_map<int, int> m;
// insert some data into m
int max_collision = 0;
for (int i = 0; i < m.bucket_count(); ++i) {
  max_collision = std::max(int(m.bucket_size(i)), max_collision);
}

but dense_hash_map.bucket_size() only return 1 or 0, I guess it's closed addressing hash map implementation. So is there a way to count the number of collisions in densh_hash_map?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions