Test hash_str In Benches
#51
Open
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've created a crate based on studying the design of ustr, with the goal of more explicit memory control. I'm looking to compare and contrast to ustr using these tests. I focused on simplicity, hashing at compile time, and the ergonomics of the local cache, specifically the fact that it can be dropped to reclaim the memory. This effortlessly enables multiple local caches like issue #30. The core idea is to omit the
lenfield, use a DST, and pass around a fat pointer like &str. The types can be created at compile time, run time, interned into a cache, and created with the global cache. It also addresses #42 withUnhashedStr, another DST that is free to create from &str, using the trait boundBorrow<UnhashedStr> : &HashStr. The global cache is somewhat of an afterthought since it was the main thing that made me want to try my own implementation. I hope this is interesting because I sure had a great time making it.The type signature of the main DST type is this:
Why
The reason I'm sharing is because I'm curious if any of the ideas I explored can benefit this library. You know, give and take since the
IdentityHasherandBinsis shamelessly lifted directly from ustr :PBenchmarks
I got pretty good results on these tests even though optimization was not a focus:
single raft ustr
time: [1.9225 ms 1.9266 ms 1.9335 ms]
single raft hash_str global interning
time: [2.3671 ms 2.3729 ms 2.3815 ms]
single raft hash_str local interning
time: [1.4005 ms 1.4019 ms 1.4033 ms]
single raft hash_str local interning with precomputed hashes
time: [743.77 µs 744.45 µs 745.31 µs]