From e1fb0afa41c1972ff7f7e5372b878d722bd4236c Mon Sep 17 00:00:00 2001 From: Olivier Giniaux Date: Fri, 7 Jun 2024 16:05:44 +0200 Subject: [PATCH 1/3] Add FxHash to bench --- Cargo.toml | 1 + benches/throughput/main.rs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index e410fa6..ee7e111 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,6 +38,7 @@ highway = "1.1.0" seahash = "4.1.0" metrohash = "1.0.6" fnv = "1.0.3" +rustc-hash = "1.1.0" [dev-dependencies.plotters] version = "0.3.5" diff --git a/benches/throughput/main.rs b/benches/throughput/main.rs index 3a48963..ceab0ae 100644 --- a/benches/throughput/main.rs +++ b/benches/throughput/main.rs @@ -48,6 +48,14 @@ fn main() { twox_hash::xxh3::hash64_with_seed(data, seed) }); + // FxHash (rustc-hash) + benchmark(processor.as_mut(), slice, "fxhash", |data: &[u8], seed: u64| -> u64 { + let mut fxhasher = rustc_hash::FxHasher::default(); + fxhasher.write_u64(seed); // Better way to seed? + fxhasher.write(data); + fxhasher.finish() + }); + // AHash let ahash_hasher = ahash::RandomState::with_seeds(0, 0, 0, 0); benchmark(processor.as_mut(), slice, "ahash", |data: &[u8], _: i32| -> u64 { From 0eaa0c79550ef6a685c09830382f7eab96537e70 Mon Sep 17 00:00:00 2001 From: Olivier Giniaux Date: Mon, 10 Jun 2024 17:31:36 +0200 Subject: [PATCH 2/3] Add fxhash to quality bench --- README.md | 50 +++++++++++++ benches/quality/main.rs | 5 +- benches/throughput/aarch64.svg | 133 ++++++++++++++++++--------------- 3 files changed, 125 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index 3aabacb..e692531 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,56 @@ Throughput is measured as the number of bytes hashed per second. ![x86_64](./benches/throughput/x86_64.svg) ![x86_64-hybrid](./benches/throughput/x86_64-hybrid.svg) +### Quality + +
+See quality benchmark results + + #### GxHash + + ``` + ✅ avalanche::() + ✅ avalanche::() + ✅ avalanche::() + ✅ avalanche::() + ✅ avalanche::() + ✅ distribution_values::(128*128) + ✅ distribution_values::(128*128) + ✅ distribution_values::(128*128) + ✅ distribution_values::(128*128) + ✅ distribution_bits::() + ✅ distribution_bits::() + ✅ distribution_bits::() + ✅ distribution_bits::() + ✅ collisions_padded_zeroes::(128*128) + ✅ collisions_flipped_bits::(9) + ✅ collisions_flipped_bits::(9) + ✅ collisions_flipped_bits::(7) + ✅ collisions_flipped_bits::(6) + ✅ collisions_flipped_bits::(5) + ✅ collisions_flipped_bits::(5) + ✅ collisions_flipped_bits::(4) + ✅ collisions_flipped_bits::(4) + ✅ collisions_flipped_bits::(3) + ✅ collisions_flipped_bits::(3) + ✅ collisions_flipped_bits::(2) + ✅ collisions_permute::(4,&Vec::from_iter(0..16)) + ✅ collisions_permute::(42,&Vec::from_iter(0..64)) + ✅ collisions_permute::(42,&Vec::from_iter(0..64)) + ✅ collisions_permute::(42,&Vec::from_iter(0..64)) + ✅ collisions_permute::(42,&Vec::from_iter(0..64)) + ✅ collisions_permute::(4,&Vec::from_iter(0..16)) + ✅ collisions_permute::(42,&Vec::from_iter(0..64)) + ✅ collisions_powerset_bytes::(&[0,1,2,3,4,5,6,7,8,9]) + ✅ collisions_powerset_bytes::(&[0,1,2,4,8,16,32,64,128]) + ✅ hasher_collisions_permute::(&[0,1,2,3,4,5,6,7,8,9]) + ✅ hasher_collisions_permute::(&[0,1,2,3,4,5,6,7,8,9]) + ✅ hasher_collisions_permute::(&[0,1,2,4,8,16,32,64,128,256]) + ✅ hasher_collisions_powerset::(&[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]) + ✅ hasher_collisions_powerset::(&[0,1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384]) + ``` +
+ ## Security ### DOS Resistance diff --git a/benches/quality/main.rs b/benches/quality/main.rs index 1c75e86..7a675c8 100644 --- a/benches/quality/main.rs +++ b/benches/quality/main.rs @@ -1,4 +1,4 @@ -use std::{hash::{Hash, Hasher, BuildHasher}, collections::HashSet, slice}; +use std::{collections::HashSet, hash::{BuildHasher, BuildHasherDefault, Hash, Hasher}, slice}; use rand::Rng; use criterion::black_box; @@ -6,8 +6,9 @@ fn main() { bench_hasher_quality::("GxHash"); bench_hasher_quality::("AHash"); bench_hasher_quality::("T1ha"); - bench_hasher_quality::("XxHash3"); + bench_hasher_quality::("XxHash3 (twox_hash)"); bench_hasher_quality::("Default"); + bench_hasher_quality::>("FxHasher (rustc_hash)"); bench_hasher_quality::("FNV-1a"); } diff --git a/benches/throughput/aarch64.svg b/benches/throughput/aarch64.svg index 81629ea..72e080d 100644 --- a/benches/throughput/aarch64.svg +++ b/benches/throughput/aarch64.svg @@ -4,13 +4,14 @@ Throughput (aarch64) - - - - - - - + + + + + + + + Throughput (MiB/s) @@ -32,46 +33,51 @@ Input Size (bytes) - - - - - - - + + + + + + + + 0 - -5000 - - - + 10000 - - -15000 - - - + + 20000 - - -25000 - - - + + 30000 - - -35000 + + +40000 + + + +50000 - + + +60000 + + + +70000 + + + +80000 + + 4 @@ -129,46 +135,51 @@ Input Size (bytes) 32768 - - - - - - - - - - - + + + + + + + + + + + + gxhash - + xxhash - + +fxhash + + ahash - + t1ha0 - + seahash - + metrohash - + highwayhash - + fnv-1a - - - - - - - - + + + + + + + + + From 946ebb8d90fbba7c5a9d6606065fde3507a1c09f Mon Sep 17 00:00:00 2001 From: Olivier Giniaux Date: Fri, 28 Jun 2024 01:14:01 +0200 Subject: [PATCH 3/3] Update rustc-hash to 2.0.0 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index ee7e111..488b973 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ highway = "1.1.0" seahash = "4.1.0" metrohash = "1.0.6" fnv = "1.0.3" -rustc-hash = "1.1.0" +rustc-hash = "2.0.0" [dev-dependencies.plotters] version = "0.3.5"