1LZ4 - Extremely fast compression 2================================ 3 4LZ4 is lossless compression algorithm, 5providing compression speed > 500 MB/s per core, 6scalable with multi-cores CPU. 7It features an extremely fast decoder, 8with speed in multiple GB/s per core, 9typically reaching RAM speed limits on multi-core systems. 10 11Speed can be tuned dynamically, selecting an "acceleration" factor 12which trades compression ratio for faster speed. 13On the other end, a high compression derivative, LZ4_HC, is also provided, 14trading CPU time for improved compression ratio. 15All versions feature the same decompression speed. 16 17LZ4 is also compatible with [dictionary compression](https://github.com/facebook/zstd#the-case-for-small-data-compression), 18both at [API](https://github.com/lz4/lz4/blob/v1.8.3/lib/lz4frame.h#L481) and [CLI](https://github.com/lz4/lz4/blob/v1.8.3/programs/lz4.1.md#operation-modifiers) levels. 19It can ingest any input file as dictionary, though only the final 64KB are used. 20This capability can be combined with the [Zstandard Dictionary Builder](https://github.com/facebook/zstd/blob/v1.3.5/programs/zstd.1.md#dictionary-builder), 21in order to drastically improve compression performance on small files. 22 23 24LZ4 library is provided as open-source software using BSD 2-Clause license. 25 26 27|Branch |Status | 28|------------|---------| 29|dev | [![Build status][AppveyorDevBadge]][AppveyorLink] | 30 31[AppveyorDevBadge]: https://ci.appveyor.com/api/projects/status/github/lz4/lz4?branch=dev&svg=true "Windows test suite" 32[AppveyorLink]: https://ci.appveyor.com/project/YannCollet/lz4-1lndh 33 34 35Benchmarks 36------------------------- 37 38The benchmark uses [lzbench], from @inikep 39compiled with GCC v8.2.0 on Linux 64-bits (Ubuntu 4.18.0-17). 40The reference system uses a Core i7-9700K CPU @ 4.9GHz (w/ turbo boost). 41Benchmark evaluates the compression of reference [Silesia Corpus] 42in single-thread mode. 43 44[lzbench]: https://github.com/inikep/lzbench 45[Silesia Corpus]: http://sun.aei.polsl.pl/~sdeor/index.php?page=silesia 46 47| Compressor | Ratio | Compression | Decompression | 48| ---------- | ----- | ----------- | ------------- | 49| memcpy | 1.000 | 13700 MB/s | 13700 MB/s | 50|**LZ4 default (v1.9.0)** |**2.101**| **780 MB/s**| **4970 MB/s** | 51| LZO 2.09 | 2.108 | 670 MB/s | 860 MB/s | 52| QuickLZ 1.5.0 | 2.238 | 575 MB/s | 780 MB/s | 53| Snappy 1.1.4 | 2.091 | 565 MB/s | 1950 MB/s | 54| [Zstandard] 1.4.0 -1 | 2.883 | 515 MB/s | 1380 MB/s | 55| LZF v3.6 | 2.073 | 415 MB/s | 910 MB/s | 56| [zlib] deflate 1.2.11 -1| 2.730 | 100 MB/s | 415 MB/s | 57|**LZ4 HC -9 (v1.9.0)** |**2.721**| 41 MB/s | **4900 MB/s** | 58| [zlib] deflate 1.2.11 -6| 3.099 | 36 MB/s | 445 MB/s | 59 60[zlib]: http://www.zlib.net/ 61[Zstandard]: http://www.zstd.net/ 62 63LZ4 is also compatible and optimized for x32 mode (`-mx32`), 64for which it provides additional speed performance. 65 66 67Installation 68------------------------- 69 70``` 71make 72make install # this command may require root permissions 73``` 74 75LZ4's `Makefile` supports standard [Makefile conventions], 76including [staged installs], [redirection], or [command redefinition]. 77It is compatible with parallel builds (`-j#`). 78 79[Makefile conventions]: https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html 80[staged installs]: https://www.gnu.org/prep/standards/html_node/DESTDIR.html 81[redirection]: https://www.gnu.org/prep/standards/html_node/Directory-Variables.html 82[command redefinition]: https://www.gnu.org/prep/standards/html_node/Utilities-in-Makefiles.html 83 84### Building LZ4 - Using vcpkg 85 86You can download and install LZ4 using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager: 87 88 git clone https://github.com/Microsoft/vcpkg.git 89 cd vcpkg 90 ./bootstrap-vcpkg.sh 91 ./vcpkg integrate install 92 ./vcpkg.exe install lz4 93 94The LZ4 port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository. 95 96Documentation 97------------------------- 98 99The raw LZ4 block compression format is detailed within [lz4_Block_format]. 100 101Arbitrarily long files or data streams are compressed using multiple blocks, 102for streaming requirements. These blocks are organized into a frame, 103defined into [lz4_Frame_format]. 104Interoperable versions of LZ4 must also respect the frame format. 105 106[lz4_Block_format]: doc/lz4_Block_format.md 107[lz4_Frame_format]: doc/lz4_Frame_format.md 108 109 110Other source versions 111------------------------- 112 113Beyond the C reference source, 114many contributors have created versions of lz4 in multiple languages 115(Java, C#, Python, Perl, Ruby, etc.). 116A list of known source ports is maintained on the [LZ4 Homepage]. 117 118[LZ4 Homepage]: http://www.lz4.org 119 120### Packaging status 121 122Most distributions are bundled with a package manager 123which allows easy installation of both the `liblz4` library 124and the `lz4` command line interface. 125 126[](https://repology.org/project/lz4/versions) 127 128 129### Special Thanks 130 131- Takayuki Matsuoka, aka @t-mat, for exceptional first-class support throughout the lifetime of this project 132