README.md
1 LZ4 - Extremely fast compression
2 ================================
3
4 LZ4 is lossless compression algorithm,
5 providing compression speed > 500 MB/s per core,
6 scalable with multi-cores CPU.
7 It features an extremely fast decoder,
8 with speed in multiple GB/s per core,
9 typically reaching RAM speed limits on multi-core systems.
10
11 Speed can be tuned dynamically, selecting an "acceleration" factor
12 which trades compression ratio for faster speed.
13 On the other end, a high compression derivative, LZ4_HC, is also provided,
14 trading CPU time for improved compression ratio.
15 All versions feature the same decompression speed.
16
17 LZ4 is also compatible with [dictionary compression](https://github.com/facebook/zstd#the-case-for-small-data-compression),
18 and can ingest any input file as dictionary,
19 including those created by [Zstandard Dictionary Builder](https://github.com/facebook/zstd/blob/v1.3.5/programs/zstd.1.md#dictionary-builder).
20 (note: only the final 64KB are used).
21
22 LZ4 library is provided as open-source software using BSD 2-Clause license.
23
24
25 |Branch |Status |
26 |------------|---------|
27 |master | [![Build Status][travisMasterBadge]][travisLink] [![Build status][AppveyorMasterBadge]][AppveyorLink] [![coverity][coverBadge]][coverlink] |
28 |dev | [![Build Status][travisDevBadge]][travisLink] [![Build status][AppveyorDevBadge]][AppveyorLink] |
29
30 [travisMasterBadge]: https://travis-ci.org/lz4/lz4.svg?branch=master "Continuous Integration test suite"
31 [travisDevBadge]: https://travis-ci.org/lz4/lz4.svg?branch=dev "Continuous Integration test suite"
32 [travisLink]: https://travis-ci.org/lz4/lz4
33 [AppveyorMasterBadge]: https://ci.appveyor.com/api/projects/status/github/lz4/lz4?branch=master&svg=true "Windows test suite"
34 [AppveyorDevBadge]: https://ci.appveyor.com/api/projects/status/github/lz4/lz4?branch=dev&svg=true "Windows test suite"
35 [AppveyorLink]: https://ci.appveyor.com/project/YannCollet/lz4-1lndh
36 [coverBadge]: https://scan.coverity.com/projects/4735/badge.svg "Static code analysis of Master branch"
37 [coverlink]: https://scan.coverity.com/projects/4735
38
39 > **Branch Policy:**
40 > - The "master" branch is considered stable, at all times.
41 > - The "dev" branch is the one where all contributions must be merged
42 before being promoted to master.
43 > + If you plan to propose a patch, please commit into the "dev" branch,
44 or its own feature branch.
45 Direct commit to "master" are not permitted.
46
47 Benchmarks
48 -------------------------
49
50 The benchmark uses [lzbench], from @inikep
51 compiled with GCC v7.3.0 on Linux 64-bits (Debian 4.15.17-1).
52 The reference system uses a Core i7-6700K CPU @ 4.0GHz.
53 Benchmark evaluates the compression of reference [Silesia Corpus]
54 in single-thread mode.
55
56 [lzbench]: https://github.com/inikep/lzbench
57 [Silesia Corpus]: http://sun.aei.polsl.pl/~sdeor/index.php?page=silesia
58
59 | Compressor | Ratio | Compression | Decompression |
60 | ---------- | ----- | ----------- | ------------- |
61 | memcpy | 1.000 |13100 MB/s | 13100 MB/s |
62 |**LZ4 default (v1.8.2)** |**2.101**|**730 MB/s** | **3900 MB/s** |
63 | LZO 2.09 | 2.108 | 630 MB/s | 800 MB/s |
64 | QuickLZ 1.5.0 | 2.238 | 530 MB/s | 720 MB/s |
65 | Snappy 1.1.4 | 2.091 | 525 MB/s | 1750 MB/s |
66 | [Zstandard] 1.3.4 -1 | 2.877 | 470 MB/s | 1380 MB/s |
67 | LZF v3.6 | 2.073 | 380 MB/s | 840 MB/s |
68 | [zlib] deflate 1.2.11 -1| 2.730 | 100 MB/s | 380 MB/s |
69 |**LZ4 HC -9 (v1.8.2)** |**2.721**| 40 MB/s | **3920 MB/s** |
70 | [zlib] deflate 1.2.11 -6| 3.099 | 34 MB/s | 410 MB/s |
71
72 [zlib]: http://www.zlib.net/
73 [Zstandard]: http://www.zstd.net/
74
75 LZ4 is also compatible and optimized for x32 mode,
76 for which it provides additional speed performance.
77
78
79 Installation
80 -------------------------
81
82 ```
83 make
84 make install # this command may require root permissions
85 ```
86
87 LZ4's `Makefile` supports standard [Makefile conventions],
88 including [staged installs], [redirection], or [command redefinition].
89 It is compatible with parallel builds (`-j#`).
90
91 [Makefile conventions]: https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html
92 [staged installs]: https://www.gnu.org/prep/standards/html_node/DESTDIR.html
93 [redirection]: https://www.gnu.org/prep/standards/html_node/Directory-Variables.html
94 [command redefinition]: https://www.gnu.org/prep/standards/html_node/Utilities-in-Makefiles.html
95
96
97 Documentation
98 -------------------------
99
100 The raw LZ4 block compression format is detailed within [lz4_Block_format].
101
102 Arbitrarily long files or data streams are compressed using multiple blocks,
103 for streaming requirements. These blocks are organized into a frame,
104 defined into [lz4_Frame_format].
105 Interoperable versions of LZ4 must also respect the frame format.
106
107 [lz4_Block_format]: doc/lz4_Block_format.md
108 [lz4_Frame_format]: doc/lz4_Frame_format.md
109
110
111 Other source versions
112 -------------------------
113
114 Beyond the C reference source,
115 many contributors have created versions of lz4 in multiple languages
116 (Java, C#, Python, Perl, Ruby, etc.).
117 A list of known source ports is maintained on the [LZ4 Homepage].
118
119 [LZ4 Homepage]: http://www.lz4.org
120