Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

count the number of collisions in densh_hash_map #43

Open
liuzqt opened this issue Oct 28, 2020 · 0 comments
Open

count the number of collisions in densh_hash_map #43

liuzqt opened this issue Oct 28, 2020 · 0 comments

Comments

@liuzqt
Copy link

liuzqt commented Oct 28, 2020

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant