Skip to content

Commit 581cc4a

Browse files
committed
SipHasher128: use specific struct layout
1 parent b86161a commit 581cc4a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

compiler/rustc_data_structures/src/sip128.rs

+6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ const BUFFER_SIZE_BYTES_SPILL: usize = BUFFER_SIZE_ELEMS_SPILL * ELEM_SIZE;
1515
const BUFFER_SPILL_INDEX: usize = BUFFER_SIZE_ELEMS_SPILL - 1;
1616

1717
#[derive(Debug, Clone)]
18+
#[repr(C)]
1819
pub struct SipHasher128 {
20+
// The access pattern during hashing consists of accesses to `nbuf` and
21+
// `buf` until the buffer is full, followed by accesses to `state` and
22+
// `processed`, and then repetition of that pattern until hashing is done.
23+
// This is the basis for the ordering of fields below. However, in practice
24+
// the cache miss-rate for data access is extremely low regardless of order.
1925
nbuf: usize, // how many bytes in buf are valid
2026
buf: [MaybeUninit<u64>; BUFFER_SIZE_ELEMS_SPILL], // unprocessed bytes le
2127
state: State, // hash State

0 commit comments

Comments
 (0)