RFC: Optimize for small strings to close gap with FNV #30
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.
Over at Tantivy, I proposed standardizing on
rustc-hash
by replacing the remaining usages of FNV. However, it appears FNV still beatsrustc-hash
for very short strings.Hence I added a microbenchmark here exploring this which showcase this:
I also made two changes. First using only safe code but changing the output values which does close the gap. And then using a bit of unsafe (but still passing Miri) to polyfill for
slice::as_chunks
. After that, we do beat FNV in the two above cases but regress in one other even we generally improve:So, first I wanted to ask if upstream is interested in optimizing for small strings to make rustc-hash more generally useful at all. And then if breaking value stability is possible at all or whether such a change cannot be done even as a breaking change.