PSeitz / lz4_flex

Fastest pure Rust implementation of LZ4 compression/decompression.
MIT License
461 stars 31 forks source link

Expand Sink abstraction to handle/hide uninitialized data #22

Closed arthurprs closed 3 years ago

arthurprs commented 3 years ago

In order to safe guard against UB (Undefined Behavior) and safety issues (exposing uninitialized data) the Sink abstraction is expanded to handle uninitialized data safely.

Sink changes

New VecSink

Unsafe Compression changes

Safe compression changes

Safe Decompression changes

Unsafe FrameDecoder changes

Fixes #19

codecov-commenter commented 3 years ago

Codecov Report

Merging #22 (4871c04) into master (08a5dcc) will increase coverage by 26.05%. The diff coverage is 88.97%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master      #22       +/-   ##
===========================================
+ Coverage   65.04%   91.10%   +26.05%     
===========================================
  Files          14       11        -3     
  Lines        2054     2180      +126     
===========================================
+ Hits         1336     1986      +650     
+ Misses        718      194      -524     
Impacted Files Coverage Δ
src/block/mod.rs 20.58% <ø> (-40.53%) :arrow_down:
src/frame/mod.rs 53.33% <ø> (+27.24%) :arrow_up:
src/lib.rs 100.00% <ø> (ø)
src/sink.rs 87.24% <87.24%> (ø)
src/block/decompress.rs 92.41% <88.00%> (+17.69%) :arrow_up:
src/block/compress.rs 97.34% <89.00%> (+10.35%) :arrow_up:
src/block/decompress_safe.rs 94.02% <92.50%> (+6.98%) :arrow_up:
src/frame/compress.rs 95.36% <100.00%> (+17.19%) :arrow_up:
src/frame/decompress.rs 95.28% <100.00%> (+25.28%) :arrow_up:
... and 15 more

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 08a5dcc...4871c04. Read the comment docs.

PSeitz commented 3 years ago

Released with v0.9 https://crates.io/crates/lz4_flex

Btw: "safe" performance seems to be incredible on newer hardware