Skip to main content

hash_file

Function hash_file 

Source
pub fn hash_file(algo: HashAlgorithm, path: &Path) -> Result<String>
Expand description

Hash a file by path. Single open + fstat to minimize syscalls. Uses zero-copy mmap for regular files: the hash function reads directly from the page cache without any kernel→user memcpy or read() syscalls. MAP_POPULATE prefaults all pages before hashing starts. MADV_HUGEPAGE uses 2MB pages to reduce TLB misses by ~500x.