<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 1.0.0 -1**|**2.877**|**330**| **940** | | [zlib] 1.2.8 -1 | 2.730 | 95 | 360 | | brotli 0.4 -0 | 2.708 | 320 | 375 | | 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/facebook/zstd/master/doc/images/Cspeed4.png" alt="Compression Speed vs Ratio" style="height:500px;"> | <img src="https://raw.githubusercontent.com/facebook/zstd/master/doc/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/facebook/zstd/master/doc/images/DCspeed5.png) . <a name="small-data"></a> ### The case for Small Data compression Previous charts provide results applicable to typical file and stream scenarios (several MB). Small data comes with different perspectives. The smaller the amount of data to compress, the more difficult it is to compress. This problem is common to all compression algorithms, and reason is, compression algorithms learn from past data how to compress future data. But at the beginning of a new data set, 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. Training Zstandard is achieved by provide it with a few samples (one file per sample). The result of this training is stored in a file called "dictionary", which must be loaded before compression and decompression. Using this dictionary, the compression ratio achievable on small data improves dramatically. The following example uses the `github-users` [sample set](https://github.com/facebook/zstd/releases/tag/v1.1.3), created from [github public API](https://developer.github.com/v3/users/#get-all-users). It consists of roughly 10K records weighting about 1KB each. Compression Ratio | Compression Speed | Decompression Speed ------------------|-------------------|-------------------- ![Compression Ratio](https://raw.githubusercontent.com/facebook/zstd/master/doc/images/dict-cr.png "Compression Ratio") | ![Compression Speed](https://raw.githubusercontent.com/facebook/zstd/master/doc/images/dict-cs.png "Compression Speed") | ![Decompression Speed](https://raw.githubusercontent.com/facebook/zstd/master/doc/images/dict-ds.png "Decompression Speed") These compression gains are achieved while simultaneously providing _faster_ compression and decompression speeds. Training works if there is some correlation in a family of small data samples. The more data-specific a dictionary is, the more efficient it is (there is no _universal dictionary_). Hence, deploying one dictionary per type of data will provide the greatest benefits. Dictionary gains are mostly effective in the first few KB. Then, the compression algorithm will gradually use previously decoded content to better compress the rest of the file. #### Dictionary compression How To : 1) Create the dictionary `zstd --train FullPathToTrainingSet/* -o dictionaryName` 2) Compress with dictionary `zstd -D dictionaryName FILE` 3) Decompress with dictionary `zstd -D dictionaryName --decompress FILE.zst` <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 | | __Rust__ | Alexandre Bury | https://crates.io/crates/zstd | | __C#__ | SKB Kontur | https://github.com/skbkontur/ZstdNet | | __Python__ | Gregory Szorc | https://pypi.python.org/pypi/zstandard | __Python__ (simple) | Sergey Dryabzhinsky | https://pypi.python.org/pypi/zstd | __Node.js__ streams | albertdb | https://www.npmjs.com/package/node-zstandard | __Node.js__ buffers | Zwb | https://www.npmjs.com/package/node-zstd | __PHP__ | Kamijo | https://github.com/kjdev/php-ext-zstd | | __Perl__ | Jiro Nishiguchi | https://metacpan.org/release/Compress-Zstd | __Swift__ | Anatoli Peredera | https://github.com/omniprog/SwiftZSTD | | __Go__ | Vianney Tran | https://github.com/DataDog/zstd | | __Ruby__ | Jarred Holman | https://github.com/jarredholman/ruby-zstd | __D__ | Masahiro Nakagawa | https://code.dlang.org/packages/zstd | | __Ada__ | John Marino | https://github.com/jrmarino/zstd-ada | | __Lua__ | Soojin Nam | https://github.com/sjnam/lua-resty-zstd | __Haskell__ | Bryan O'Sullivan | https://github.com/facebookexperimental/hs-zstd | __Erlang__ | Yuki Ito | https://hex.pm/packages/zstd | | __Visual Basic 6__ | Tanner_H | http://www.vbforums.com/showthread.php?840413-Compression-in-VB6-modern-solutions | __OCaml__ | ygrek | https://opam.ocaml.org/packages/zstd/ | | __Delphi__ | Razor12911 | http://encode.ru/threads/2119-Zstandard?p=49075&viewfull=1#post49075 [than reference C]:https://github.com/facebook/zstd <br/> <a name="GUI"></a> ## Graphical User Interface Tino Reichardt has developed 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="references"></a> ## Zstandard is used by : #### Cloud solutions <div class="container"> <ul class="list-inline"> <li><a href="https://aws.amazon.com/redshift/" ><img src="images/aws.png" /></a> [Redshift](https://aws.amazon.com/about-aws/whats-new/2017/01/amazon-redshift-now-supports-the-zstandard-high-data-compression-encoding-and-two-new-aggregate-functions/) </li> <li><a href="https://www.mercurial-scm.org/" ><img src="images/mercurial.png"/></a> [Mercurial](http://blog.deveo.com/whats-new-in-mercurial-hg-4-1/)</li> <li><a href="https://docs.taskcluster.net/" ><img src="images/taskc2.png"/></a> [TaskCluster](https://github.com/taskcluster/taskcluster-worker/pull/114)</li> <li><a href="http://ceph.com/" ><img src="images/ceph.png" /></a> [Ceph](https://github.com/ceph/ceph/tree/master/src/compressor/zstd)</li> </ul> </div> #### Databases <div class="container"> <ul class="list-inline"> <li><a href="https://hadoop.apache.org/" ><img src="images/hadoop.png" /></a> [Hadoop](https://issues.apache.org/jira/browse/HADOOP-13578) </li> <li><a href="http://rocksdb.org/" ><img src="images/rocksdb.png"/></a> [RocksDB](https://twitter.com/rocksdb/status/771387757306388480) </li> <li><a href="http://www.wiredtiger.com/" ><img src="images/wt.png" /></a> [WiredTiger](https://github.com/wiredtiger/wiredtiger/tree/master/ext/compressors/zstd) </li> <li><a href="https://redis.io/" ><img src="images/redis.png" /></a> [Redis](https://github.com/chadnickbok/redis-zstd-module) </li> <li><a href="https://clickhouse.yandex/" ><img src="images/clickhouse.png"/></a> [Clickhouse](https://github.com/yandex/ClickHouse/tree/master/contrib/libzstd) </li> <li><a href="http://groonga.org/" ><img src="images/groonga.png"/></a> [Groonga](http://groonga.org/en/blog/2016/11/29/groonga-6.1.1.html) </li> <li><a href="https://tarantool.org/" ><img src="images/tarantool.png"/></a> [Tarantool](https://github.com/tarantool/tarantool/blob/1.8/cmake/BuildZSTD.cmake) </li> <li><a href="https://github.com/XeLabs/tokudb" ><img src="images/tokudb.png" /></a> [TokuDB](https://github.com/XeLabs/tokudb/commit/7ba55b2ee6aaac0980daa0a6b269a5c551da4ba6) </li> </ul> </div> #### Serialization <div class="container"> <ul class="list-inline"> <li><a href="http://www.fstpackage.org/" ><img src="images/fst.png" /></a> [FST](https://github.com/fstpackage/fst/tree/master/src/ZSTD) </li> <li><a href="http://www.blosc.org/" ><img src="images/blosc.png" /></a> [Blosc](http://www.blosc.org/blog/zstd-has-just-landed-in-blosc.html) </li> <li><a href="http://bcolz.blosc.org/en/latest/"><img src="images/bcolz.png" /></a> [bcolz](https://github.com/Blosc/bcolz/tree/master/c-blosc/internal-complibs/zstd-1.1.2) </li> <li><a href="https://pypi.python.org/pypi/mrcz"><img src="images/mrc.png" /></a> [mrcz](https://github.com/em-MRCZ/c-mrcz) </li> <li><a href="http://www.well.ox.ac.uk/~gav/bgen_format/bgen_format.html"><img src="images/oxford.png" /></a> [bgen](http://www.well.ox.ac.uk/~gav/bgen_format/bgen_format.html) </li> <li><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Gecko"><img src="images/gecko.png" /></a> [Gecko](https://bug635044.bugzilla.mozilla.org/show_bug.cgi?id=1316183) </li> <li><a href="https://support.hdfgroup.org/HDF5"><img src="images/hdf.png" /></a> [HDF5](https://github.com/aparamon/HDF5Plugin-Zstandard) </li> <li><a href="https://github.com/Sereal/Sereal" ><img src="images/sereal.png" /></a> [Sereal](https://github.com/Sereal/Sereal/tree/master/Perl/shared/zstd) </li> </ul> </div> #### Network <div class="container"> <ul class="list-inline"> <li><a href="https://code.facebook.com/projects/1410559149202582/fbthrift/"><img src="images/thrift.png"/></a> [fbthrift](https://github.com/facebook/fbthrift/commit/ec42813f0ced737617d4614900ef3a96c1f3d17f) </li> <li><a href="https://code.facebook.com/projects/676603015770415/proxygen/"><img src="images/proxygen.png"/></a> [proxygen](https://github.com/facebook/proxygen/blob/master/proxygen/lib/utils/ZstdStreamDecompressor.h) </li> <li><a href="https://code.facebook.com/projects/470946523057396/mcrouter/"><img src="images/mcrouter.png"/></a> [mcrouter](https://github.com/facebook/mcrouter/blob/master/mcrouter/lib/ZstdCompressionCodec.h) </li> <li><a href="https://rspamd.com/" ><img src="images/rspamd.png" /></a> [Rspamd](https://rspamd.com/announce/2016/11/21/rspamd-1.4.0.html) </li> </ul> </div> #### Other <div class="container"> <ul class="list-inline"> <li><a href="https://code.facebook.com/projects/527543867323997/folly/"><img src="images/folly.png"/></a> [folly](https://github.com/facebook/folly/blob/master/folly/io/Compression.cpp#L39) </li> <li><a href="http://www.ultimatepp.org/" ><img src="images/uppframe.png"/></a> [U++](http://www.ultimatepp.org/www$uppweb$Roadmap$en-us.html) </li> <li><a href="https://fogproject.org/" ><img src="images/fog.png"/></a> [Fog](https://news.fogproject.org/fog-1-3-5-rc-9/) </li> <li><a href="https://github.com/MarekKowalski/LiveScan3D"><img src="images/blank.png"/></a> [LiveScan3D](https://github.com/MarekKowalski/LiveScan3D/pull/14) </li> </ul> </div> ---