Rust Docs Crates.io

lz4_flex

lz4<em>flex</em>logo

Configurable, pure rust, high performance implementation of LZ4 compression with fast compile times. Originally based on redox-os' lz4 compression, but now a complete rewrite.

| Compressor | Compression | Decompression | |------------------|-------------|---------------| | lz4flexx unsafe | 594 MiB/s | 3733 MiB/s | | lz4flexx safe | 546 MiB/s | 1433 MiB/s | | lz4cpp | 914 MiB/s | 3793 MiB/s | | lz4fear | 433 MiB/s | 836 MiB/s |

Features

Usage:

Compression and decompression uses no usafe via the default feature flags "safe-encode" and "safe-decode". If you need more performance you can disable them (e.g. with no-default-features).

```rust use lz4flex::{compressprependsize, decompresssize_prepended};

fn main(){ let input: &[u8] = b"Hello people, what's up?"; let compressed = compressprependsize(input); let uncompressed = decompresssizeprepended(&compressed).unwrap(); assert_eq!(input, uncompressed); } ```

Benchmarks

The benchmark is run with criterion, the test files are in the benches folder.

Currently 3 implementations are compared, this one, the redox-version, lz-fear and the c++ version via rust bindings. The lz4-flex version is tested with the feature flags safe-decode and safe-encode switched on and off.

Results v0.4.1 10-12-2020 (safe-decode and safe-encode off)

cargo bench --no-default-features

Executed on Core i7-6700 Win10 WSL.

Compress

Decompress

Results v0.4 04-12-2020 (safe-decode and safe-encode on)

cargo bench

Executed on Core i7-6700 Win10 WSL.

Compress

Decompress

Fuzzer

This fuzz target fuzzes, and asserts compression and decompression returns the original input. cargo fuzz run fuzz_roundtrip

This fuzz target fuzzes, and asserts compression with cpp and decompression returns the original input. cargo fuzz run fuzz_roundtrip_cpp_compress

TODO