Benchmarks

The library, in memory, measured by lzbench from @inikep, with other compressors, at their levels.

Command line pipelines

These benchmarks measure the command lines themselves, on the same system, in pipelines where a link of limited speed, a storage device or a network, separates stages running at the same time.

Reading static content

Static content, such as an OS kernel or video game assets, is compressed once, then read from storage, and decompressed while it is read.

Each bar measures, for instance for lz4 -9 :

lz4 -9 -c silesia.tar > f.lz4
LINK < f.lz4 | lz4 -d -c > /dev/null

where LINK limits the speed of the storage device (see bench-pipeline.sh).

Transferring dynamic content

Dynamic content, such as network packets, RPCs or database replication, is compressed, sent over the network, and decompressed, the three at the same time.

Default settings, or a single compression thread. A single thread : lz4 -T1, zstd -T1, pigz -p 1.

Each bar measures, for instance for lz4 -1 :

lz4 -1 -c < silesia.tar | LINK |
lz4 -d -c > /dev/null

where LINK limits the speed of the network (see bench-pipeline.sh).

Documentation

The LZ4 block compression format is detailed within lz4_Block_format.

To stream data of any size, or to compress files, use the frame format, detailed in lz4_Frame_format.


Interoperable LZ4 ports and bindings

The following versions are provided for languages beyond the C reference version. They are in conformance with the LZ4 block and frame specifications, and are therefore interoperable.

LanguageAuthorURL
C#Milosz Krajewskihttps://github.com/MiloszKrajewski/K4os.Compression.LZ4
DartInstantiationshttps://pub.dev/documentation/es_compression/latest/lz4/
Dart (port)jxoesneonhttps://pub.dev/packages/dart_lz4
DelphiHanno Hugenberghttps://github.com/Hugie/lz4-delphi
DelphiXelitanhttps://github.com/Xelitan/LZ4-Compression-Decompression-for-Delphi-Lazarus
Go (port)Pierre Curtohttps://github.com/pierrec/lz4
Go (cgo)Sean Cunninghamhttps://github.com/prequel-dev/plz4
HaskellNiklas Hambüchenhttps://hackage.haskell.org/package/lz4-frame-conduit
JavaJonas Konradhttps://github.com/yawkat/lz4-java
JavaApache Commonshttps://commons.apache.org/proper/commons-compress/apidocs/org/apache/commons/compress/compressors/lz4/package-summary.html
JavaScript (Node.js)Antonio Musolinohttps://github.com/antoniomuso/lz4-napi
JavaScript (port)Benzingahttps://github.com/Benzinga/lz4js
LuaWitchu Promjunyakulhttps://github.com/witchu/lua-lz4
PerlFelix Bytowhttps://metacpan.org/release/Compress-LZ4Frame
PythonJonathan Underwoodhttps://pypi.org/project/lz4/
Rust (port)Pascal Seitzhttps://github.com/PSeitz/lz4_flex
Rust (binding)10x Genomicshttps://github.com/10xGenomics/lz4-rs
Rust (binding)picoHzhttps://github.com/picoHz/lzzzz
VA SmalltalkInstantiationshttps://www.instantiations.com/vast-support/documentation/91/pr/compression2.html#pID0E0LB0FA


Compatible CLI versions

Here are a few compatible alternatives to lz4 command line utility :

NameAuthorURL
smalLZ4Stephan Brummehttps://create.stephan-brumme.com/smallz4/
briefLZ4Jørgen Ibsenhttps://github.com/jibsen/blz4
7Zip with LZ4Tino Reichardthttps://github.com/mcmilk/7-Zip-zstd
lz4ultraEmmanuel Martyhttps://github.com/emmanuel-marty/lz4ultra


Custom LZ4 implementations

The following versions compress data blocks with the LZ4 compression algorithm in various programming languages. They use the block compression format, and deal with metadata (like compressed_size) in various custom ways (or none at all, letting the caller deal with it). Consequently, they are not interoperable with LZ4 command line utility, nor (generally) between themselves.

LanguageAuthorURL
C# streamingPhill Djonovhttps://github.com/pdjonov/Lz4Stream
CudaNVIDIAhttps://docs.nvidia.com/cuda/nvcomp/lz4.html
PHPKamijohttps://github.com/kjdev/php-ext-lz4


Compact decoders

Decoders only, often written in assembly, for small or old processors and other environments.

TargetAuthorURL
6502 & 65C02 assemblyPeter Ferriehttps://github.com/pararaum/lz4-6502
Atari XL/XE assemblyxxlhttp://xxl.atari.pl/lz4-decompressor/
65c816 assemblyOlivier Zardinihttp://www.brutaldeluxe.fr/products/crossdevtools/lz4/index.html
Z80 assemblyPiotr Drapichhttps://web.archive.org/web/20260815055553/http://www.union.org.pl/download/z80/LZ4_Z80.asm
Z80 assemblyEdouard Bergehttps://groups.google.com/forum/#!topic/lz4c/A6TLHThL0c8
8086 assemblyE. C. Maslochhttps://hg.pushbx.org/ecm/inicomp/
8088 assemblyJim Leonardhttp://www.oldskool.org/pc/lz4_8088
68k assemblyArnaud Carrehttps://github.com/arnaud-carre/lz4-68k
v810 assemblyMartin Wendthttps://github.com/enthusi/lz4_v810_decode
ARM Cortex assemblyJens Bauerhttps://developer.arm.com/community/developer/ip-products/processors/b/processors-ip-blog/posts/lz4-decompression-routine-for-cortex-m0-and-later
arm64 assemblySiguzahttps://github.com/Siguza/lz4dec
Risc-V assemblyMartin Wendthttps://github.com/enthusi/lz4_rv32i_decode
C (tiny)Justine Tunneyhttps://github.com/jart/cosmopolitan/blob/467504308a103865c058f9a0ac858cc22e72240e/libc/nexgen32e/lz4cpy.c
LuaScott Lembckehttps://github.com/slembcke/mini-lz4
PHP (port)Stephan J. Müllerhttps://heap.ch/blog/2019/05/18/lz4-decompression/
TclD. Bohdanhttps://wiki.tcl-lang.org/page/LZ4
jsonlz4Avi Halachmihttps://github.com/avih/dejsonlz4 : custom Mozilla LZ4 format


LZ4 is used by

A sample : each entry links to a source showing how LZ4 is used.

Operating systems

Linuxkernel image, zram and zswap, SquashFS and EROFS, dm-vdo
Androidsystem partitions in EROFS, compressed with LZ4 HC by default
macOS, iOSsystem Compression API (COMPRESSION_LZ4)
FreeBSDZFS : compression=on selects LZ4
illumoswhere LZ4 entered ZFS (lz4_compress feature)
DragonFly BSDHAMMER2 compresses with LZ4 by default
ZephyrLZ4 module of the embedded real-time OS

Memory and disks

Fast enough to stay always on.

OpenZFSdefault algorithm of compression=on
Marvell Structera Xinline LZ4 compression in a CXL memory expander
ZeroPoint ZeroStorageLZ4 in SSD controllers, transparent to the file system
HHVMshared heap of the Hack type checker, LZ4-compressed

Boot and loading

Decompression speed shortens load times.

corebootromstage and verstage compressed with LZ4
GRUBreads LZ4-compressed ZFS pools
Unitycaches AssetBundles in LZ4
Nintendo SwitchLZ4 in the system software notices
Hitman 3“almost everything in the game runs through” LZ4
Firefoxadd-on startup data stored LZ4-compressed

Network and streams

Compression at network speed.

Kafkacompression.type=lz4 for messages
Sparkdefault codec of shuffle and broadcast data
Hugging Face Xetmodel and dataset chunks in LZ4 frames
Suricatapacket logs (pcap-log) compressed with LZ4
Wiresharkcapture files in LZ4, with fast random access

Databases

Compressed blocks read back fast.

PostgreSQLTOAST compression, LZ4 by default since v19
MySQLInnoDB page compression
RocksDBblock compression, LZ4 recommended
Cassandradefault compressor
ClickHousedefault column compression (self-managed)

File formats

Stored compressed, decoded on read.

ParquetLZ4_RAW codec
ArrowIPC buffers in LZ4 frames
Lucenestored fields LZ4-compressed by default
systemdjournal compressed with LZ4
SubversionLZ4 by default in repositories since 1.10

Backup

Throughput.

BorgBackupLZ4 by default
pgBackRestcompress-type=lz4

Accelerators

Offload the CPU.

Intel QATLZ4 offloaded to QAT (QATzip, Gen4 and later)
NVIDIA nvCOMPLZ4 on GPUs
CASTLZ4 compression IP core

The Android robot is reproduced or modified from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.