Support externally-hashed keys - #40
Open
vlovich wants to merge 4 commits into
Open
Conversation
vlovich
force-pushed
the
externally-hashed
branch
4 times, most recently
from
March 14, 2024 19:47
0b1c45c to
254f764
Compare
Contributor
|
Interesting... I'm trying to figure out if we could avoid switching from |
vlovich
force-pushed
the
externally-hashed
branch
2 times, most recently
from
April 6, 2024 02:45
5978e48 to
dab764c
Compare
This is ~10% faster for u64 lookups. For lookups and construction the time is constant regardless of the true length of the input (assuming you can amortize the hashing cost somehow externally to this library). For example, for a 128 byte string construction is ~2.5x faster and lookups are ~1.7x faster.
Latest rayon requires at least Rust 1.63, regex requires 1.65, and std::hint::black_box was stabilized in 1.66, so bump that. Also bump the current stable version to validate with a newer Rust since presumably that's the intention of the second version.
vlovich
force-pushed
the
externally-hashed
branch
from
August 25, 2026 19:52
dab764c to
a5e39fa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have a use-case where:
This provides savings so that the lookup within the hash function is basically the same cost as a u64 regardless of the true size of the key input. Obviously the hash still has to be done somewhere, so it's not totally free but as mentioned the savings grow the more hash functions I need to interrogate and it lets me use a faster xxh3 hash.
I tried to keep the identical hash results if you use anything other than the new ExternallyHashed type while simultaneously carving out a fast path for it to shine (I've also in theory fast-pathed construction/lookups for integer keys where we can skip constructing the WyHash state object but I didn't bother benchmarking the actual improvement there).