sile / libflate

A Rust implementation of DEFLATE algorithm and related formats (ZLIB, GZIP)
https://docs.rs/libflate
MIT License
178 stars 35 forks source link

Switch to rle_decode_fast crate #38

Closed Shnatsel closed 5 years ago

Shnatsel commented 5 years ago

Use rle_decode_fast crate created by @WanzenBug and me instead of a bespoke unsafe block relying on non-local invariants.

This change improves performance by about 10% as measured with hyperfine -m 25 --warmup=3 'target/release/examples/flate -i enwiki-latest-all-titles-in-ns0.gz -o /dev/null gzip-decode'

Before:

  Time (mean ± σ):      2.295 s ±  0.016 s    [User: 2.275 s, System: 0.013 s]
  Range (min … max):    2.268 s …  2.320 s    25 runs

After:

  Time (mean ± σ):      2.079 s ±  0.022 s    [User: 2.069 s, System: 0.010 s]
  Range (min … max):    2.046 s …  2.132 s    25 runs

We're created the crate to solve recurring safety problems in RLE decoding. It contains a single unsafe block, which is a copy of append_from_within() function from this Rust RFC. We're reasonably confident it is sound because it's mostly a copy of a pre-exisitng stdlib function, and I cannot find anything wrong with its logic.

codecov-io commented 5 years ago

Codecov Report

Merging #38 into master will decrease coverage by 0.09%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master      #38     +/-   ##
=========================================
- Coverage   91.46%   91.36%   -0.1%     
=========================================
  Files          14       14             
  Lines        1300     1285     -15     
=========================================
- Hits         1189     1174     -15     
  Misses        111      111
Impacted Files Coverage Δ
src/lib.rs 100% <ø> (ø) :arrow_up:
src/util.rs 91.17% <ø> (-1.33%) :arrow_down:
src/non_blocking/deflate/decode.rs 86.14% <100%> (-0.72%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update bf3c6c3...912fabd. Read the comment docs.