Skip to main content

Module compression

Module compression 

Source
Available on crate feature std only.
Expand description

Production Adaptive Compression

Real compression using LZ4 (lz4_flex) and Zstd:

  • Performance tier: LZ4 frame compression (~4 GB/s decompress, ~2 GB/s compress)
  • Standard tier: Zstd level 1 (~500 MB/s compress, ratio ~2.5x)
  • Constrained tier: off (CPU > bandwidth)

Auto-probe: if the compression ratio stays below probe_threshold after the first probe_samples packets, compression self-disables (CPU not worth it). Minimum payload worth compressing = 64 bytes (below that the overhead dominates).

Structs§

AdaptiveCompressor
Adaptive compressor with auto-probe.
CompressionStats
Compression statistics for auto-probe

Enums§

CompressionAlgo
Compression algorithm
CompressionError
Compression errors

Constants§

MAX_DECOMPRESSED_LEN
Default upper bound on decompressed output (16 MiB). A conservative ceiling on the largest plaintext a single frame may expand to; the established-session TcpSessionTransport frame cap is tighter still (4 MiB), so this never gates legitimate traffic. Decompression is an asymmetric operation: a few KiB of crafted LZ4/Zstd can expand to gigabytes (a “decompression bomb”). AdaptiveCompressor::decompress enforces this cap unconditionally; callers that need a different bound use AdaptiveCompressor::decompress_with_limit.