<a name="benchmarks"></a> Benchmarks ---------- For comparison, several fast compression algorithms were tested and compared on a Core i7-3930K CPU @ 4.5GHz, using [lzbench], an open-source in-memory benchmark by @inikep compiled with gcc 5.2.1, with the [Silesia compression corpus]. [lzbench]: https://github.com/inikep/lzbench [Silesia compression corpus]: http://sun.aei.polsl.pl/~sdeor/index.php?page=silesia |Name | Ratio | C.speed | D.speed | |-----------------|-------|--------:|--------:| | | | MB/s | MB/s | |**zstd 0.7.0 -1**|**2.877**|**325**| **930** | | [zlib] 1.2.8 -1 | 2.730 | 95 | 360 | | brotli -0 | 2.708 | 220 | 430 | | QuickLZ 1.5 | 2.237 | 510 | 605 | | LZO 2.09 | 2.106 | 610 | 870 | | [LZ4] r131 | 2.101 | 620 | 3100 | | Snappy 1.1.3 | 2.091 | 480 | 1600 | | LZF 3.6 | 2.077 | 375 | 790 | [zlib]:http://www.zlib.net/ [LZ4]: http://www.lz4.org/ Zstd can trade compression speed for stronger compression ratios. It is configurable by small increment. Decompression speed is preserved and remain roughly the same at all settings, a property shared by most LZ compression algorithms, such as [zlib] or lzma. The following tests were run on a Core i7-3930K CPU @ 4.5GHz, using [lzbench], an open-source in-memory benchmark by @inikep compiled with gcc 5.2.1, on the [Silesia compression corpus]. | Compression Speed vs Ratio | Decompression Speed | | ---------------------------|-------------------- | | <img src="https://raw.githubusercontent.com/Cyan4973/zstd/master/images/Cspeed4.png" alt="Compression Speed vs Ratio" style="height:500px;"> | <img src="https://raw.githubusercontent.com/Cyan4973/zstd/master/images/Dspeed4.png" alt="Decompression Speed" style="height:500px;"> Several algorithms can produce higher compression ratio but at slower speed, falling outside of the graph. For a larger picture including very slow modes, [click on this link](https://raw.githubusercontent.com/Cyan4973/zstd/master/images/DCspeed5.png) . <a name="small-data"></a> ### The case for Small Data compression Previous charts provide results applicable to typical files and streams scenarios (several MB). Small data come with different perspectives. The smaller the amount of data to compress, the more difficult it is to achieve any significant compression. This problem is common to any compression algorithm. The reason is, compression algorithms learn from past data how to compress future data. But at the beginning of a new file, there is no "past" to build upon. To solve this situation, Zstd offers a __training mode__, which can be used to tune the algorithm for a selected type of data, by providing it with a few samples. The result of the training is stored in a file called "dictionary", which can be loaded before compression and decompression. Using this dictionary, the compression ratio achievable on small data improves dramatically : <img src="https://raw.githubusercontent.com/Cyan4973/zstd/master/images/smallData.png" alt="Compressing Small Data" style="height:600px;"> These compression gains are achieved while simultaneously providing faster compression and decompression speeds. Dictionary work if there is some correlation in a family of small data (there is no _universal dictionary_). Hence, deploying one dictionary per type of data will provide the greater benefits. Dictionary gains are mostly effective in the first few KB. Then, the compression algorithm will rely more and more on previously decoded content to compress the rest of the file. #### Dictionary compression How To : ##### _Using the Command Line Utility_ : 1) Create the dictionary `zstd --train FullPathToTrainingSet/* -o dictionaryName` 2) Compress with dictionary `zstd FILE -D dictionaryName` 3) Decompress with dictionary `zstd --decompress FILE.zst -D dictionaryName` <br/> <a name="GUI"></a> ## Graphical User Interface Tino Reichardt has developped and hosts a version of [7-zip archive manager with Zstandard](https://mcmilk.de/projects/7-Zip-ZStd/). <img src="https://mcmilk.de/projects/7-Zip-ZStd/7-Zip_02.png" alt="7-zip with Zstandard" style="height:500px;"> <br/> <a name="other-languages"></a> ## Bindings for other languages Should you need Zstandard in another language [than reference C], here is a list of known bindings and their authors : | Language | Author | URL | | ------------ | ------------------- | ------------------------------------- | | __Java__ | Luben Karavelov | https://github.com/luben/zstd-jni | | __C#__ | SKB Kontur | https://github.com/skbkontur/ZstdNet | | __Rust__ | Alexandre Bury | https://crates.io/crates/zstd | | __Ada__ | John Marino | https://github.com/jrmarino/zstd-ada | | __Python__ | Sergey Dryabzhinsky | https://pypi.python.org/pypi/zstd | | __Go__ | Jason Moiron | https://github.com/DataDog/zstd | | __Node.js__ | albertdb | https://www.npmjs.com/package/node-zstandard | __OCaml__ | ygrek | https://opam.ocaml.org/packages/zstd/ | | __PHP__ | Kamijo | https://github.com/kjdev/php-ext-zstd | | __Ruby__ | Jarred Holman | https://github.com/jarredholman/ruby-zstd | __Delphi__ | Razor12911 | http://encode.ru/threads/2119-Zstandard?p=49075&viewfull=1#post49075 [than reference C]:https://github.com/Cyan4973/zstd ---