Skip to content

[WIP] Switch StableHasher from SipHash to HighwayHash #84229

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1578,6 +1578,12 @@ version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35"

[[package]]
name = "highway"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66920f2e905206a4aca271ae71f1638f10854e3739f162fc465fb8aecce44446"

[[package]]
name = "home"
version = "0.5.3"
Expand Down Expand Up @@ -3845,6 +3851,7 @@ dependencies = [
"cfg-if 0.1.10",
"crossbeam-utils 0.7.2",
"ena",
"highway",
"indexmap",
"jobserver",
"libc",
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_data_structures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ measureme = "9.1.0"
libc = "0.2"
stacker = "0.1.12"
tempfile = "3.0.5"
highway = "0.6.3"

[dependencies.parking_lot]
version = "0.11"
Expand Down
13 changes: 7 additions & 6 deletions compiler/rustc_data_structures/src/stable_hasher.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::sip128::SipHasher128;
use highway::{HighwayHash, HighwayHasher, Key};
use rustc_index::bit_set;
use rustc_index::vec;
use smallvec::SmallVec;
Expand All @@ -16,7 +16,7 @@ mod tests;
/// hashing and the architecture dependent `isize` and `usize` types are
/// extended to 64 bits if needed.
pub struct StableHasher {
state: SipHasher128,
state: HighwayHasher,
}

impl ::std::fmt::Debug for StableHasher {
Expand All @@ -32,7 +32,7 @@ pub trait StableHasherResult: Sized {
impl StableHasher {
#[inline]
pub fn new() -> Self {
StableHasher { state: SipHasher128::new_with_keys(0, 0) }
StableHasher { state: HighwayHasher::new(Key([0, 0, 0, 0])) }
}

#[inline]
Expand All @@ -50,14 +50,15 @@ impl StableHasherResult for u128 {

impl StableHasherResult for u64 {
fn finish(hasher: StableHasher) -> Self {
hasher.finalize().0
hasher.state.finalize64()
}
}

impl StableHasher {
#[inline]
pub fn finalize(self) -> (u64, u64) {
self.state.finish128()
let [first, second] = self.state.finalize128();
(first, second)
}
}

Expand All @@ -68,7 +69,7 @@ impl Hasher for StableHasher {

#[inline]
fn write(&mut self, bytes: &[u8]) {
self.state.write(bytes);
self.state.append(bytes);
}

#[inline]
Expand Down
1 change: 1 addition & 0 deletions src/tools/tidy/src/deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[
"gsgdt",
"hashbrown",
"hermit-abi",
"highway",
"humantime",
"indexmap",
"instant",
Expand Down