Fast CRC32 based hash for hash_bytes and hash_int #91
Comments
After lots of experimenting, I've created a CRC32-hardware based hash_bytes algorithm that is quite a bit faster than any other hash algorithms that I know of: The hash implementation favors speed over hash quality, so it is definitely quite a bit worse than any of the contender. The only quality criteria is to be good enough for hashmap. |
you need a full test on different os/compiler/cpu. on my cpu AMD 1700, _mm_crc32_u64 is just a liitle fast than FNV-A. |
I have do some bench your newest hash function with rand string and rand size(4-64). clang 9.0.0 (tags/RELEASE_900/final) on llvm/gcc 4.2.1 __cplusplus = 201402 arm64 OS = linux, cpu = Kunpeng 920stdhash time use = 419 ms stdhash time use = 623 ms stdhash time use = 591 ms stdhash time use = 624 ms clang 8.0.0 (tags/RELEASE_800/final) on llvm/gcc 4.2.1 __cplusplus = 201703 x86-64 OS = linux, cpu = Intel(R) Xeon(R) CPU E5620 @ 2.40GHzstdhash time use = 676 ms stdhash time use = 486 ms stdhash time use = 424 ms stdhash time use = 480 ms clang 10.0.0 on llvm/ms vc++ 1927 __cplusplus = 201703 x86-64 OS = Win, cpu = AMD Ryzen 7 1700 Eight-Core Processorstdhash time use = 632 ms stdhash time use = 634 ms stdhash time use = 637 ms stdhash time use = 634 ms gcc 9.3.0 __cplusplus = 201703 x86-64 OS = linux, cpu = Intel(R) Xeon(R) CPU E5620 @ 2.40GHzstdhash time use = 497 ms stdhash time use = 498 ms stdhash time use = 484 ms stdhash time use = 464 ms gcc 7.5.0 __cplusplus = 201402 arm64 OS = linux, cpu = Kunpeng 920stdhash time use = 624 ms stdhash time use = 665 ms stdhash time use = 622 ms stdhash time use = 613 ms gcc 10.2.0 __cplusplus = 201703 x86-64 OS = Win, cpu = AMD Ryzen 7 1700 Eight-Core Processorstdhash time use = 339 ms stdhash time use = 336 ms stdhash time use = 338 ms stdhash time use = 339 ms ms vc++ 1927 x86-64 OS = Win, cpu = AMD Ryzen 7 1700 Eight-Core Processorstdhash time use = 635 ms stdhash time use = 652 ms stdhash time use = 651 ms stdhash time use = 625 ms |
Thanks a lot for the benchmarks! I only have access to an Intel i7-8700, so this is very appreciated. What are the 4 benchmark results, is these from 4 different evaluations? |
//bench code like this. static void buildRandString(int size, std::vectorstd::string& rndstring, int str_min, int str_max) static void testHashString(int size, int str_min, int str_max)
} testHashString(12345678, 4, 64); |
won't do, I don't want to fix intrinsics and compatibility bugs any more. |
hash_bytes
that makes use of CRC32 instructionThe text was updated successfully, but these errors were encountered: