#chunking #hash #gear #cdc #performance

gearhash

Fast, SIMD-accelerated hash function for content-defined chunking

4 releases

0.1.3 Apr 12, 2020
0.1.2 Dec 13, 2019
0.1.1 Dec 13, 2019
0.1.0 Dec 9, 2019

#1645 in Algorithms

Download history 358/week @ 2024-03-13 196/week @ 2024-03-20 178/week @ 2024-03-27 245/week @ 2024-04-03 138/week @ 2024-04-10 256/week @ 2024-04-17 392/week @ 2024-04-24 428/week @ 2024-05-01 345/week @ 2024-05-08 441/week @ 2024-05-15 139/week @ 2024-05-22 130/week @ 2024-05-29 289/week @ 2024-06-05 324/week @ 2024-06-12 232/week @ 2024-06-19 348/week @ 2024-06-26

1,218 downloads per month

MIT/Apache

24KB
593 lines

gearhash

The GEAR hashing function is a fast, rolling hash function that is well suited for content defined chunking.

In particular, this function is used as a building block for the FastCDC algorithm.

The implementation provided in this crate consists of both a simple, scalar variant, as well as optimized versions for the SSE4.2 and AVX2 instruction sets.

Usage

use gearhash::Hasher;

// set up initial state
let mut chunks = vec![];
let mut offset = 0;

// create new hasher
let mut hasher = Hasher::default();

// loop through all matches, and push the corresponding chunks
while let Some(boundary) = hasher.next_match(&buf[offset..], MASK) {
    chunks.push(&buf[offset..offset + boundary]);
    offset += boundary;
}

// push final chunk
chunks.push(&buf[offset..]);

Fuzzing

To ensure memory safety of the unsafe SIMD code in this crate, we use cargo-fuzz.

You can find the fuzzing targets under fuzz/fuzz_targets, which can be run using cargo fuzz run <target>.

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~8KB