-
-
Notifications
You must be signed in to change notification settings - Fork 180
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
Add fxhash (Rust) #69
Comments
Sure. Accidently I looked at this just yesterday, and saw that it's very similar to my new FNV improvement. I don't care about Rust, just that gcc-9.1.0 is blacklisted |
It would be nice if someone does a pull request for rust based hashes like this. I'm too rusty for rust. I recently added ASM support (for clang and gcc only, no masm), but it's not yet merged. See the aesni-sha1-x86_64 branch. |
Is it acceptable to use a C++ port of the Rust implementation? This hash is quite small and I recently implemented a similar hash in Zig that differs only in that it does fewer rounds for non-multiple-of-8 input sizes and assumes it can read up to 7 bytes past the end. const Hasher = struct {
const K: u64 = 0x517cc1b727220a95;
hash: u64 = 0,
pub inline fn add(self: *Hasher, i: u64) void {
self.hash = (((self.hash << 5) | (self.hash >> 59)) ^ i) *% K;
}
pub inline fn write(self: *Hasher, start: [*]u8, len: u64) void {
const end = start + len;
var p = start;
while (@ptrToInt(p + 8) <= @ptrToInt(end)) {
self.add(std.mem.readIntLittle(u64, p[0..8]));
p += 8;
}
if (@ptrToInt(p) < @ptrToInt(end)) {
// for this last read,
// the low bytes are our string and the high bytes are garbage
const garbage_bytes = @intCast(u6, 8 - (@ptrToInt(end) - @ptrToInt(p)));
self.add(std.mem.readIntLittle(u64, p[0..8]) << garbage_bytes * 8);
}
}
}; This obviously isn't useful, but I can make a more faithful C++ port if that would help. |
Sure it is. |
@rurban do you just need the following API, exposed in a staticlib? void somehash_test(const void *key, uint32_t len, uint32_t seed, void *out); Looking at I can add tests for a handful of popular Rust hashers if you can give me some pointers on what to expose |
Yes, just this is fine, as C or C++. All hash test functions need to set out, some just do the memcpy in its finalizers, or write directly to it. It's the dest buffer we are writing to |
Thank you for the quick response, I submitted a PR to add this and others in #276. A lot of hash libraries use a common trait interface so it was pretty easy to add quite a few implementations. |
https://github.com/cbreeden/fxhash (yeah, it's Rust, but at some point there will anyway be a need to test other Rust hashes as they seem to be quite unique)
The text was updated successfully, but these errors were encountered: