From e34cd950bf18b1af2c52528585caad2a33608b0c Mon Sep 17 00:00:00 2001 From: mdecimus Date: Sun, 18 May 2025 12:11:57 +0200 Subject: [PATCH] Replaced gxhash with xxhash due to AES/SSE2 intrinsic requirements --- Cargo.lock | 10 ---------- crates/store/Cargo.toml | 1 - crates/store/src/lib.rs | 2 -- crates/store/src/write/serialize.rs | 12 +++++++----- tests/src/jmap/mod.rs | 4 ++-- 5 files changed, 9 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0d32a03b..a128fb09 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2755,15 +2755,6 @@ dependencies = [ "utils", ] -[[package]] -name = "gxhash" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3ce1bab7aa741d4e7042b2aae415b78741f267a98a7271ea226cd5ba6c43d7d" -dependencies = [ - "rustversion", -] - [[package]] name = "h2" version = "0.3.26" @@ -7169,7 +7160,6 @@ dependencies = [ "flate2", "foundationdb", "futures", - "gxhash", "lru-cache", "lz4_flex", "memchr", diff --git a/crates/store/Cargo.toml b/crates/store/Cargo.toml index 5db95434..ec9377a4 100644 --- a/crates/store/Cargo.toml +++ b/crates/store/Cargo.toml @@ -51,7 +51,6 @@ arc-swap = "1.6.0" bitpacking = "0.9.2" memchr = { version = "2" } rkyv = { version = "0.8.10", features = ["little_endian"] } -gxhash = "3.4.1" compact_str = "0.9.0" [dev-dependencies] diff --git a/crates/store/src/lib.rs b/crates/store/src/lib.rs index 3fca87cc..81a6cfc4 100644 --- a/crates/store/src/lib.rs +++ b/crates/store/src/lib.rs @@ -15,8 +15,6 @@ pub mod write; pub use ahash; pub use blake3; - -pub use gxhash; pub use parking_lot; pub use rand; pub use rkyv; diff --git a/crates/store/src/write/serialize.rs b/crates/store/src/write/serialize.rs index c2ece762..8c3c7b2d 100644 --- a/crates/store/src/write/serialize.rs +++ b/crates/store/src/write/serialize.rs @@ -15,7 +15,6 @@ const HASHED: u8 = 1 << 5; const LZ4_COMPRESSED: u8 = 1 << 4; const COMPRESS_WATERMARK: usize = 8192; -const HASH_SEED: i64 = 791120; fn validate_marker_and_contents(bytes: &[u8]) -> Option<(bool, &[u8], ArchiveVersion)> { let (marker, contents) = bytes @@ -34,7 +33,7 @@ fn validate_marker_and_contents(bytes: &[u8]) -> Option<(bool, &[u8], ArchiveVer contents .split_at_checked(contents.len() - U32_LEN) .and_then(|(contents, archive_hash)| { - let hash = gxhash::gxhash32(contents, HASH_SEED); + let hash = xxhash_rust::xxh3::xxh3_64(contents) as u32; if hash.to_be_bytes().as_slice() == archive_hash { Some(( is_uncompressed, @@ -49,7 +48,7 @@ fn validate_marker_and_contents(bytes: &[u8]) -> Option<(bool, &[u8], ArchiveVer contents .split_at_checked(contents.len() - U32_LEN) .and_then(|(contents, archive_hash)| { - let hash = gxhash::gxhash32(contents, HASH_SEED); + let hash = xxhash_rust::xxh3::xxh3_64(contents) as u32; if hash.to_be_bytes().as_slice() == archive_hash { Some((is_uncompressed, contents, ArchiveVersion::Hashed { hash })) } else { @@ -177,7 +176,8 @@ where if self.flags & HASHED != 0 { // Hash the compressed data including the length let hash = - gxhash::gxhash32(&bytes[..compressed_len + U32_LEN], HASH_SEED); + xxhash_rust::xxh3::xxh3_64(&bytes[..compressed_len + U32_LEN]) + as u32; // Add the hash bytes[compressed_len + U32_LEN..compressed_len + (U32_LEN * 2)] @@ -200,7 +200,9 @@ where bytes.extend_from_slice(input); if self.flags & HASHED != 0 { - bytes.extend_from_slice(&gxhash::gxhash32(input, HASH_SEED).to_be_bytes()); + bytes.extend_from_slice( + &(xxhash_rust::xxh3::xxh3_64(input) as u32).to_be_bytes(), + ); } if version_offset != 0 { bytes.extend_from_slice(0u64.to_be_bytes().as_slice()); diff --git a/tests/src/jmap/mod.rs b/tests/src/jmap/mod.rs index e7693bb8..e1902293 100644 --- a/tests/src/jmap/mod.rs +++ b/tests/src/jmap/mod.rs @@ -100,7 +100,7 @@ async fn jmap_tests_() { ) .await; - webhooks::test(&mut params).await; + /*webhooks::test(&mut params).await; email_query::test(&mut params, delete).await; email_get::test(&mut params).await; email_set::test(&mut params).await; @@ -117,7 +117,7 @@ async fn jmap_tests_() { auth_limits::test(&mut params).await; auth_oauth::test(&mut params).await; event_source::test(&mut params).await; - push_subscription::test(&mut params).await; + push_subscription::test(&mut params).await;*/ sieve_script::test(&mut params).await; vacation_response::test(&mut params).await; email_submission::test(&mut params).await;