Closed wangqiim closed 1 year ago
I think your benchmark numbers are bogus. It optimizes to the same code: https://godbolt.org/z/bevvonoKf
And the more important issue is that on some architectures it is not allowed to do an unaligned load with something like *(int64_t *)s
. That will cause a SEGFAULT.
I think your benchmark numbers are bogus. It optimizes to the same code: https://godbolt.org/z/bevvonoKf
And the more important issue is that on some architectures it is not allowed to do an unaligned load with something like
*(int64_t *)s
. That will cause a SEGFAULT.
yes, you are right. I make a mistake. I ignored the impact of the CPU cache.:joy:
In for (int i = 0; i < 4000000; i++)
the numbers should be 8000000 instead of 4000000. (warm up cpu cache). Thanks for your code example in the tool (Compiler Explorer) , This tool is awesome.
https://github.com/martinus/robin-hood-hashing/blob/fb1483621fda28d4afb31c0097c1a4a457fdd35b/src/include/robin_hood.h#L354-L361
I find template parameter T is only used as
uint16_t
,uint32_t
anduint64_t
, so I thinkunaligned_load<int64_t>((int64_t *)s + i);
can be optimezer through*((int64_t *)s + i)
.test.cpp
output