-
Notifications
You must be signed in to change notification settings - Fork 1
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
Rust port #2
Comments
Thanks. I've added your repo the list of ports: #4 |
Upon further look, I see there's an error depending on the size: https://github.com/thevilledev/ChibiHash-rs/blob/624b44991ba2ee8639b7e3de6e6acc4fbfe6fac3/src/lib.rs#L41-L46 Hash functions should never error. The trend in certain languages (especially those that have specific error types) to create unnecessary 'errors' is, IMO, a bad one. All it does is make the api cumbersome to use. As for streaming api, you can do it with 0 allocations, keep a 32 byte buffer and append to it. See the newly pushed stream branch for reference. With fixed buffer, and allocation gone, the streaming api also cannot fail. (In fact, I mixed the length into the state late in the hashing process instead of at the start specifically so that 0 allocation streaming apis are possible). |
Thanks for the feedback! I was contemplating on removing the error type after implementing support for the Hasher trait. It doesn't do errors either and the output is always I'll have a look at the streaming API! |
Just a short follow-up. Streaming support added in v0.2.0. I'll keep an eye on the repo for any improvements/changes and incorporate them into my project as well. I'm looking into some Rust-specific optimisations too. |
Good to know. I've made some local changes to improve short string performance which will be part of v2 (I will make a new branch for it when things are more polished).
Do you have any numbers on how the rust port compares to the C version? I'd assume they're on the same league since rust is backed by llvm (which is more or less on par with gcc). |
I went ahead and implemented a small test suite, which calls the original C implementation of the hash function through Rust's FFI (Foreign Function Interface). I ran both implementations through the benchmarks on various input sizes. I included a few screenshots and thoughts in thevilledev/ChibiHash-rs#9 (comment). Despite the results of Rust being faster on smaller input sizes, I'd consider both more or less the same. If I'd have to guess there is some overhead of FFI which makes those smaller input size runs seem slower on the C implementation. |
Kudos - super interesting project! Thank you for the great work.
I've created a Rust port of it at thevilledev/ChibiHash-rs. I've tagged the first release as
v0.1.0
and published it as a chibihash crate.I took your example key/seed combinations from your comment at #1 (comment) and created a test for it, to ensure we're on the right track.
Happy to keep maintaining the project and support anyone using this with Rust.
The text was updated successfully, but these errors were encountered: