Is the use case arbitrary length data? If you’re always hashing, e.g., 4 byte data then surely you can just use the data itself. For arbitrary length data seems you could wrap the hash function with something that branches elsewhere on small length. Too naive?
-
-
-
Actual value is fine in many cases. If you look at pointer and integer hashes in some STL implementations, they just return the value iirc. I have done this in directed mapped caches. One may need a shift depending on how the address is calculated.
- 1 more reply
New conversation -
-
-
Been saying this to everyone who will listen for years.
-
I think it’s likely that DoS resistance is effectively impossible for small keys, so it’s not worth doing. The best hash function might be one that scales up number of rounds as the key size increases (and that the compiler can specialize if it knows an upper bound on key size).
- 2 more replies
New conversation -
-
-
Perl uses two hash functions these days: one for short (<32 bytes) keys, and a different one for longer ones. Google's farmhash takes this to an extreme splitting the ranges to with different hash functions for 0-16, 17-32, 33-64, 65-96, 97-256, and 257+ bytes.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Didn’t
@cmuratori recently claim to have created the fastest non crypto hash fn evar? https://mollyrocket.com/meowhash -
Meow Hash is for large data. If you want fast non-crypto hashing of 16 bytes or less, you can just do a few AESDEC's (or ENC's) and it's effectively instant. Take a look at Go's internal hash for an example. Meow is still reasonable on small keys, but why pay for the setup?
- 1 more reply
New conversation -
-
-
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
I tested some hashes sometime ago, I recall that xxhash had good performance. Alternatively, __crc32w loads 32 bits and uses a instruction on ARMv8-1.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.