#chunking #hash #gear #cdc #performance

gearhash

内容定义分块的高速SIMD加速哈希函数

4个版本

0.1.3 2020年4月12日
0.1.2 2019年12月13日
0.1.1 2019年12月13日
0.1.0 2019年12月9日

#1645 in 算法

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 每月下载量

MIT/Apache

24KB
593

gearhash

GEAR哈希函数是一个快速、滚动哈希函数,非常适合内容定义分块。

特别是,这个函数被用作FastCDC算法的构建块。

此crate中提供的实现包括一个简单的标量变体以及针对SSE4.2和AVX2指令集的优化版本。

用法

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

为确保此crate中unsafe SIMD代码的内存安全性,我们使用cargo-fuzz

您可以在fuzz/fuzz_targets下找到模糊测试目标,可以使用cargo fuzz run <target>运行。

许可证

该项目受以下任一许可证的许可:

任选其一。

贡献

除非您明确表示,否则根据Apache-2.0许可证定义的任何有意提交以包含在此项目中的贡献,将如上所述双重许可,无需任何额外的条款或条件。

依赖关系

~8KB