tree: ad2edab56fc6d8262aa1c6ee5a7affd40f17c071 [path history] [tgz]
  1. src/
  2. .android-checksum.json
  3. .cargo-checksum.json
  4. Android.bp
  5. Cargo.toml
  6. cargo_embargo.json
  7. CHANGELOG.md
  8. LICENSE.md
  9. METADATA
  10. MODULE_LICENSE_MIT
  11. README.md
crates/simd-adler32/README.md

A SIMD-accelerated Adler-32 hash algorithm implementation.

Features

  • No dependencies
  • Support no_std (with default-features = false)
  • Runtime CPU feature detection (when std enabled)
  • Blazing fast performance on as many targets as possible (currently only x86 and x86_64)
  • Default to scalar implementation when simd not available

Quick start

Cargo.toml

[dependencies]
simd-adler32 = "*"

example.rs

use simd_adler32::Adler32;

let mut adler = Adler32::new();
adler.write(b"rust is pretty cool, man");
let hash = adler.finish();

println!("{}", hash);
// 1921255656

Support

CPU Features

implarchfeature
x86, x86_64avx512
x86, x86_64avx2
x86, x86_64ssse3
x86, x86_64sse2
🚧arm, aarch64neon
wasm32simd128

MSRV 1.36.0**

Minimum supported rust version is tested before a new version is published. [**] Feature const-generics needs to disabled to build on rustc versions <1.51 which can be done by updating your dependency definition to the following.

Cargo.toml

[dependencies]
simd-adler32 = { version "*", default-features = false, features = ["std"] }

Performance

Benchmarks listed display number of randomly generated bytes (10k / 100k) and library name. Benchmarks sources can be found under the bench directory. Crates used for comparison are adler and adler32.

Windows 10 Pro - Intel i5-8300H @ 2.30GHz

nameavg. timeavg. thrpt
10k/simd-adler32212.61 ns43.805 GiB/s
10k/wuffs3843 ns2.63 GiB/s*
10k/adler324.8084 us1.9369 GiB/s
10k/adler17.979 us530.43 MiB/s
--------------------------------------------------------
100k/simd-adler322.7951 us33.320 GiB/s
100k/wuffs34733 ns2.6814 GiB/s*
100k/adler3248.488 us1.9207 GiB/s
100k/adler178.36 us534.69 MiB/s

* wuffs ran using mingw64/gcc, ran with wuffs bench -ccompilers=gcc -reps=1 -iterscale=300 std/adler32.

MacBookPro16,1 - Intel i9-9880H CPU @ 2.30GHz

nameavg. timeavg. thrpt
10k/simd-adler32200.37 ns46.480 GiB/s
10k/adler324.1516 us2.2433 GiB/s
10k/adler10.220 us933.15 MiB/s
--------------------------------------------------------
100k/simd-adler322.3282 us40.003 GiB/s
100k/adler3241.130 us2.2643 GiB/s
100k/adler83.776 us534.69 MiB/s

Safety

This crate contains a significant amount of unsafe code due to the requirement of unsafe for simd intrinsics. Fuzzing is done on release and debug builds prior to publishing via afl. Fuzzy tests can be found under fuzz the directory.

Resources

Credits

Thank you to the contributors of the following projects.

Contributing

Feel free to submit a issue or pull request. :smile: