Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Added: Speed test for xxhash3_64 #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Sewer56
Copy link

@Sewer56 Sewer56 commented Nov 23, 2024

This PR adds a speed test for xxhash3, latest implementation from twox-hash, and renames the existing test to xxhash64.
Some results from my machine, AMD Ryzen 9 5900X, 32GB DDR4-3000 (16-17-17-35)

I feel like there should be some sort of disclaimer somewhere around the benchmark code that this measures the Hasher streaming interface, rather than pure throughput. The code is omitting the oneshot APIs, where certain algorithms like the xxh3 implementation benefit severely.

In any case, I did also benchmark xxh3 oneshot out of curiosity. xxh3 oneshot sits between wyhash and rapidhash for most inputs; before starting to run away from other stable algorithms at 512 bytes.

Short String Performance (2-64 characters)

Implementation str_2 str_8 str_16 str_64
fxhash 1.57ns 1.36ns 1.77ns 3.83ns
gxhash* 2.09ns 2.08ns 2.08ns 2.54ns
rustc-hash 2.24ns 2.03ns 1.99ns 3.46ns
rapidhash_raw 2.67ns 2.47ns 2.47ns 4.08ns
rapidhash 2.75ns 2.44ns 2.49ns 4.09ns
wyhash_raw 3.15ns 3.19ns 3.29ns 4.06ns
ahash 3.59ns 3.59ns 3.82ns 5.55ns
wyhash 3.60ns 3.58ns 3.81ns 4.78ns
metrohash* 4.02ns 3.61ns 4.49ns 8.01ns
t1ha* 4.70ns 4.67ns 4.47ns 7.87ns
default 5.56ns 6.34ns 7.37ns 13.81ns
xxhash64 8.71ns 8.02ns 8.63ns 12.55ns
farmhash* 12.24ns 15.10ns 15.40ns 34.21ns
seahash 13.23ns 8.91ns 9.65ns 13.69ns
xxhash3_64 21.88ns 21.78ns 21.53ns 23.28ns
highwayhash 33.98ns 32.63ns 29.31ns 31.60ns

Long String Performance (100+ characters)

Implementation str_100 str_177 str_256 str_1024 str_4096
rapidhash_raw 4.38ns 7.65ns 9.05ns 31.50ns 128.07ns
gxhash* 4.36ns 5.31ns 5.90ns 16.71ns 54.33ns
rapidhash 4.48ns 7.16ns 8.44ns 31.57ns 130.17ns
rustc-hash 4.67ns 7.42ns 9.62ns 39.64ns 175.03ns
fxhash 6.81ns 14.62ns 21.00ns 123.32ns 549.44ns
wyhash_raw 7.00ns 10.19ns 12.96ns 47.94ns 193.76ns
wyhash 7.34ns 11.47ns 13.90ns 52.58ns 204.68ns
t1ha* 9.50ns 12.20ns 15.92ns 51.76ns 206.03ns
metrohash* 10.87ns 16.75ns 18.10ns 54.97ns 202.29ns
ahash 12.71ns 16.25ns 20.44ns 87.60ns 357.70ns
xxhash64 14.31ns 19.91ns 22.28ns 66.61ns 235.66ns
seahash 16.92ns 25.39ns 31.93ns 114.53ns 427.51ns
default 18.54ns 31.04ns 40.10ns 150.11ns 577.65ns
xxhash3_64 27.80ns 33.27ns 28.49ns 48.89ns 96.06ns
highwayhash 39.86ns 44.03ns 41.78ns 84.37ns 251.55ns
farmhash* 45.33ns 58.66ns 61.79ns 103.12ns 275.50ns

Miscellaneous Types (u64 and object)

Implementation u64 object
fxhash 281ps 7.43ns
rustc-hash 404ps 4.36ns
gxhash* 539ps 6.31ns
wyhash 819ps 14.40ns
rapidhash 999ps 10.90ns
metrohash* 1.06ns 37.65ns
wyhash_raw 3.40ns -
seahash 8.53ns 68.82ns
xxhash64 8.58ns 40.99ns
default 8.71ns 35.28ns
farmhash* 10.09ns 101.06ns
highwayhash 34.85ns 52.22ns
xxhash3_64 21.24ns 46.27ns

@hoxxep
Copy link
Owner

hoxxep commented Nov 25, 2024

Thanks for this! We could probably remove the base XxHash tests and simply replace them all with XxHash3_64 if they're deemed superior to the old XxHash?

The upgraded twox-hash package is breaking the MSRV tests. I'll move the benchmarking into another crate (or behind a bench feature?) when I add a few more hash comparisons for recent crates such as foldhash.

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

Successfully merging this pull request may close these issues.

2 participants