New fastest portable hash: wyhash
github.com
github.com
This is the code: https://github.com/rurban/smhasher/blob/master/wyhash.h
I would love for this to be true, but I'd love to see a more thorough explanation of how it manages to be both smaller and faster than other competing hashes.
How so? It's much slower than AES based hashes. It's about the throughput same as xxHash64. It uses fewer cycles/hash than xxHash64.
I must have misinterpreted the following:
> So the fastest hash functions on x86_64 without quality problems are: > > - wyhash > - t1ha > - [...]
I interpreted that to be an ordered list, saying that wyhash was the fastest.
But looking at the actual table I am confused. There are MB/s numbers and cycles/hash numbers. In cycles/hash wyhash appears to beat all FarmHash variants, but in MiB/s it is slower than some of them. I don't understand why these two performance measures would not track perfectly, since the CPUs should be running a constant number of cycles/second.
x86 isn't RISC and not all operations take the same number of cycles. Also, the code might have different levels of possible parallelism and might impact the pipeline differently.
Comp Sci education for the low level basics is often completely neglected nowadays. This should be freshman year stuff. I'm certainly not an expert, myself, just familiar with the issues. (Know enough to know what you don't know.)
Yes but it doesn't say instructions per hash, it says cycles per hash. Unless some kind of frequency scaling is going on, the number of cycles per second should be very consistent. If bytes/hash is held constant and cycles/second is constant, then MiB/second and cycles/hash should be exact inverses. I don't understand why this is not the case in these tables.
> Also, the code might have different levels of possible parallelism and might impact the pipeline differently.
Again this can affect the number of instructions being retired, but not the number of cycles. A cycle is a cycle, regardless of how much work is actually being accomplished.
> Comp Sci education for the low level basics is often completely neglected nowadays. This should be freshman year stuff.
I'm a low-level junkie who lives in godbolt.org and Agner Fog's tables, writes JIT compilers, and does FPGA design for fun on the side. It's possible that I'm mistaken here, but I do have a fair amount of background in this.
Those would be the useful numbers.
There's been nothing published to that effect, even though he has claimed for years that he can recover bits from the seed.
[0] https://github.com/jandrewrogers/AquaHash [1] https://github.com/cmuratori/meow_hash
That doesn’t seem like much.
This hash function looks like it will do unaligned reads if you're hashing an unaligned string. This doesn't matter on x86, but portable code should avoid this. It would be helpful to have a wrapper function that could handle unaligned strings by special-casing the begin and end of buffer.
I beg your pardon? The author seems very confused.
To expand on this, SipHash is designed to mitigate a certain kind of DOS attack. It’s not a cryptographic hash. SipHash will still be a top choice for general purpose hashing with inputs that can be chosen by an adversary.
and i made another one too: https://github.com/switch33/sha29893
and a third one: https://github.com/switch33/sha5987
and an even better one: https://github.com/switch33/sha2999999
and maybe the best for quite some time: https://github.com/switch33/sha130000000-
Do people really try to optimize file hashing this way?
>> Even if [...] worse hash functions will lead to more collisions, the overall speed advantage beats the slightly worse quality.
Maybe a more experienced dev can comment on this? Still learning here, and haven't spent time in a lot of large codebases.
There will always be collisions on dynamic workloads. Otherwise you would choose perfect hashes. In the usual programming language case SPOOKY32 has the least collisions, and is pretty fast too. But it has no chance against the small hash functions.
The smhasher speed test doesn't tell you which hash will be the fastest in a hash table with small key lengths, only when used as digest. e.g. for bigger files, db or network blobs. The icache footprint in comparison to all the hash table code is very important.
Can you explain why? Like what use cases are there where you don't actually care how likely something is to collide, you just want it to be fast?
I've always thought being able to predict the chance of collision to be the most important factor on a hasher. When is it not?
Second, assume very large hash tables...assume that with noncollision using the data structure takes time T1(H) and with collission it takes T2(H) for hash function H, and that the probability of collision is P(H).
So your total cost is then
P(H) T2(H) + (1 - P(H)) T1(H)
Which is approximately
P(H) T2(H) + T1(H)
Easy to play with numbers so that a worse but cheaper hash has a lower total cost. In fact this will usually be the case I would expect... T2 is multiplied with P and disappears for all but the very worst hashes/extremely expensive T2
This would delay rainbow tables
They are not meant for cryptographically strong fingerprinting.
For password hashing, you generally want a work function to increase the resource usage, or some alternative way of making cracking harder. That’s the case you’re thinking of, and it’s a very specific application, not what this new hash function is designed for.