Skip to main content

hash_many_multithreaded

Function hash_many_multithreaded 

Source
pub fn hash_many_multithreaded(
    input: &[u8],
    message_len: usize,
    out: &mut [[u8; 32]],
)
Expand description

hash_many, using other CPU cores where that is faster: the same hashes, never slower.

let leaves = vec![7u8; 4096 * 256];
let mut hashes = vec![[0u8; 32]; 4096];
blake3_servil::hash_many_multithreaded(&leaves, 256, &mut hashes);
assert!(hashes.iter().all(|h| h == blake3_servil::hash(&[7u8; 256]).as_bytes()));

Speed: below 512 KiB in all it runs on the calling thread, at hash_many’s speed; larger batches use the other cores too (on an Apple M4 Max, 64-byte messages from about 10 down to 3 ns each). It shares the cores with other callers as hash_multithreaded does.