Skip to content
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

Switching hash function to xxh3 #3

Open
SaveTheRbtz opened this issue Nov 16, 2022 · 2 comments
Open

Switching hash function to xxh3 #3

SaveTheRbtz opened this issue Nov 16, 2022 · 2 comments

Comments

@SaveTheRbtz
Copy link

SaveTheRbtz commented Nov 16, 2022

xxh3 is faster than murmur (x86_64):

name          time/op
Murmur/1-8      2.68ns ± 1%
Murmur/4-8      3.45ns ± 1%
Murmur/8-8      4.70ns ± 0%
Murmur/16-8     6.19ns ± 0%
Murmur/32-8     10.6ns ± 0%
Murmur/50-8     16.3ns ± 2%
Murmur/500-8     202ns ± 0%
XXH3/1-8        2.53ns ± 2%
XXH3/4-8        2.51ns ± 2%
XXH3/8-8        2.45ns ± 1%
XXH3/16-8       2.35ns ± 1%
XXH3/32-8       3.16ns ± 0%
XXH3/50-8       4.87ns ± 5%
XXH3/500-8      38.6ns ± 1%

Using it makes mph slightly faster (Intel(R) Xeon(R) CPU @ 2.80GHz, 348454 words):

name      old time/op    new time/op    delta
Table       35.4ns ± 2%    28.4ns ± 3%  -19.70%  (p=0.000 n=10+10)
TableMap    67.8ns ±10%    66.9ns ± 6%     ~     (p=0.481 n=10+10)

Also while here you can consider switching to a generic slices.SortFunc to speed up build. Combined w/ hashing change it amounts for ~13% improvement:

name   old time/op    new time/op    delta
Build     126ms ± 6%     109ms ± 3%  -13.23%  (p=0.000 n=10+10)

I can create pull requests if you are interested: main...SaveTheRbtz:mph:main^

PS. It would be possible to switch to https://github.com/cespare/xxhash if it had an ability to customize seed. That said, zeebo version would likely be faster due to AVX/AVX512 support.

@kamikazechaser
Copy link

Looks good.

@cespare
Copy link
Owner

cespare commented Dec 1, 2022

Sure, feel free to send a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants