Improve short-string performance by helping inlining#35
Merged
Conversation
hoxxep
reviewed
Aug 6, 2025
| } | ||
|
|
||
| impl FoldHasher { | ||
| impl<'a> FoldHasher<'a> { |
Contributor
There was a problem hiding this comment.
I quite like how adding the lifetime parameter turned out, I expected it to be more of a pain in various ways. Slightly regret not taking this option in rapidhash now!
Contributor
LGTM! |
knl
reviewed
Aug 7, 2025
|
|
||
| /// Hashes strings >= 16 bytes, has unspecified behavior when bytes.len() < 16. | ||
| fn hash_bytes_medium(bytes: &[u8], mut s0: u64, mut s1: u64, fold_seed: u64) -> u64 { | ||
| /// Hashes strings <= 16 bytes, has unspecified behavior when bytes.len() < 16. |
There was a problem hiding this comment.
Shouldn't the comment be:
Hashes strings <= 16 bytes, has unspecified behavior when bytes.len() > 16.
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.
Credit to @hoxxep for identifying and bringing my attention to this issue. The body of
Hasher::writewas too large which could (depending on linker /codegen-units) prevent proper inlining of the sponge construction. By passing the seeds by reference and not inlining the longer string path thewritebody is now sufficiently small to consistently inline. All-in-all on my machine this resulted in a 4x improvement for short strings. This is an improvement over the original benchmarks (which had since benchmarking regressed).