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

Update test.c to include a minimal hash function that returns 64 bits. #2

Merged
merged 1 commit into from
Jan 17, 2024

Conversation

JacksonAllan
Copy link
Contributor

Verstable essentially requires a hash function that returns a 64-bit unsigned integer with entropy in the high, as well as low, bits. This is because the four highest bits of each key are stored and used during lookups to skip most failed key comparisons (each of which requires not only calling the comparison function but also accessing the buckets array, i.e. a likely cache miss). Without this mechanism, Verstable can still function relatively well, but it will incur a significant performance hit. The proposed hash function is the same mixer that ankerl::unordered_dense applies internally to guard against weak hash functions.

Verstable essentially requires a hash function that returns a 64-bit unsigned integer with entropy in the high, as well as low, bits. This is because the four highest bits of each key are stored and used during lookups to skip most failed key comparisons (each of which requires not only calling the comparison function but also accessing the buckets array, i.e. a likely cache miss). Without this mechanism, Verstable can still function relatively well, but it will incur a significant performance hit. The proposed hash function is the same mixer that ankerl::unordered_dense applies internally to guard against weak hash functions.
@attractivechaos attractivechaos merged commit d09aad2 into attractivechaos:master Jan 17, 2024
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

Successfully merging this pull request may close these issues.

2 participants