Skip to content

Commit c0956ff

Browse files
committed
Auto merge of #45319 - michaelwoerister:use-128bit-siphash, r=nikomatsakis
incr.comp.: Use 128bit SipHash for fingerprinting This PR switches incr. comp. result fingerprinting from 128 bit BLAKE2 to 128 bit SipHash. When we started using BLAKE2 for fingerprinting, the 128 bit version of SipHash was still experimental. Now that it isn't anymore we should be able to get a nice performance boost without significantly increasing collision probability. ~~I'm going to start a try-build for this, so we can gauge the performance impact before merging (hence the `WIP` in the title).~~ EDIT: Performance improvements look as expected. Tests seem to be passing. Fixes #41215.
2 parents c0e0a38 + 27b6c91 commit c0956ff

File tree

9 files changed

+591
-83
lines changed

9 files changed

+591
-83
lines changed

src/libcore/hash/sip.rs

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ struct Hasher<S: Sip> {
7272
}
7373

7474
#[derive(Debug, Clone, Copy)]
75+
#[repr(C)]
7576
struct State {
7677
// v0, v2 and v1, v3 show up in pairs in the algorithm,
7778
// and simd implementations of SipHash will use vectors

src/librustc/ich/fingerprint.rs

+3-12
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
// except according to those terms.
1010

1111
use rustc_data_structures::stable_hasher;
12-
use std::mem;
13-
use std::slice;
1412

1513
#[derive(Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Clone, Copy, RustcEncodable, RustcDecodable)]
1614
pub struct Fingerprint(u64, u64);
@@ -54,16 +52,9 @@ impl ::std::fmt::Display for Fingerprint {
5452
}
5553

5654
impl stable_hasher::StableHasherResult for Fingerprint {
57-
fn finish(mut hasher: stable_hasher::StableHasher<Self>) -> Self {
58-
let hash_bytes: &[u8] = hasher.finalize();
59-
60-
assert!(hash_bytes.len() >= mem::size_of::<u64>() * 2);
61-
let hash_bytes: &[u64] = unsafe {
62-
slice::from_raw_parts(hash_bytes.as_ptr() as *const u64, 2)
63-
};
64-
65-
// The bytes returned bytes the Blake2B hasher are always little-endian.
66-
Fingerprint(u64::from_le(hash_bytes[0]), u64::from_le(hash_bytes[1]))
55+
fn finish(hasher: stable_hasher::StableHasher<Self>) -> Self {
56+
let (_0, _1) = hasher.finalize();
57+
Fingerprint(_0, _1)
6758
}
6859
}
6960

src/librustc_data_structures/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#![feature(fn_traits)]
2929
#![feature(unsize)]
3030
#![feature(i128_type)]
31+
#![feature(i128)]
3132
#![feature(conservative_impl_trait)]
3233
#![feature(specialization)]
3334

@@ -54,6 +55,7 @@ pub mod graph;
5455
pub mod indexed_set;
5556
pub mod indexed_vec;
5657
pub mod obligation_forest;
58+
pub mod sip128;
5759
pub mod snapshot_map;
5860
pub mod snapshot_vec;
5961
pub mod stable_hasher;

0 commit comments

Comments
 (0)