hex_deflate (hex_core v0.20.0)

View Source

Pure-Erlang raw DEFLATE (RFC 1951) encoder. The output only depends on the input bytes and the options, not on the zlib library the VM links or the number of schedulers.

The input is split into chunks of chunk bytes (default 112 KiB, at most 448 KiB) that are compressed independently, each with the preceding 32 KiB as history, and joined in order. Chunks run in up to workers processes in parallel (default: the number of online schedulers); each needs a heap of about 4 MiB with the default chunk size.

Matching is zlib's deflate_slow (or deflate_fast when lazy is false) with level 6's parameters chain, nice, good, max_lazy and too_far, and hash_bits bits of hash (default 16). Searches spend at most budget chain steps per input byte on average (default 12), which bounds the time spent on inputs with long, useless hash chains. Lazy matching searches only positions at multiples of stride (a power of two, default 4; 1 searches every position) from skip bytes (default 256) after the end of the last match until it finds one, which saves time on incompressible input. Blocks hold at most block_syms symbols.

Summary

Functions

compress(Data)

compress(Data, Opts)