Skip to main content

Module compression

Module compression 

Source
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: если compression ratio < threshold на первых N пакетах → отключить. Минимальный размер для сжатия = 64 байт (overhead не оправдан).

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 — matches the established-session frame cap in TcpSessionTransport). 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.