<a name="benchmarks"></a> Benchmarks ---------- For comparison, several fast compression algorithms were tested and compared on a Linux Mint Debian edition server (`Linux version 4.8.0-1-amd64`), with a Core i7-6700K CPU @ 4.0GHz, using [lzbench], an open-source in-memory benchmark by @inikep compiled with gcc 6.3.0, on the [Silesia compression corpus]. [lzbench]: https://github.com/inikep/lzbench [Silesia compression corpus]: http://sun.aei.polsl.pl/~sdeor/index.php?page=silesia | Compressor name | Ratio | Compression| Decompress.| | --------------- | ------| -----------| ---------- | | **zstd 1.1.3 -1** | 2.877 | 430 MB/s | 1110 MB/s | | zlib 1.2.8 -1 | 2.743 | 110 MB/s | 400 MB/s | | brotli 0.5.2 -0 | 2.708 | 400 MB/s | 430 MB/s | | quicklz 1.5.0 -1 | 2.238 | 550 MB/s | 710 MB/s | | lzo1x 2.09 -1 | 2.108 | 650 MB/s | 830 MB/s | | lz4 1.7.5 | 2.101 | 720 MB/s | 3600 MB/s | | snappy 1.1.3 | 2.091 | 500 MB/s | 1650 MB/s | | lzf 3.6 -1 | 2.077 | 400 MB/s | 860 MB/s | [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` ### A rich API set : Zstandard API is designed with learning curve in mind. At the top, you'll find simple methods, using trivial arguments and behavior. Then, at each new paragraph, the API introduces new concepts and parameters, giving gradually more control for advanced usages. You can learn more about Zstandard API by reading [its documentation](http://facebook.github.io/zstd/zstd_manual.html). <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 | | __Python__ (full) | Gregory Szorc | https://pypi.python.org/pypi/zstandard | __Python__ (simple) | Sergey Dryabzhinsky | https://github.com/sergey-dryabzhinsky/python-zstd | __C#__ | SKB Kontur | https://github.com/skbkontur/ZstdNet | | __C#__ (streaming) | Bernhard Pichler | https://github.com/bp74/Zstandard.Net | __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__ | SpringMT | https://github.com/SpringMT/zstd-ruby | | __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 Helland | https://github.com/tannerhelland/VB6-Compression | __Julia__ | Alex Arslan | https://github.com/ararslan/ZStd.jl | | __Tcl__ | D. Bohdan | https://wiki.tcl-lang.org/48788 | | __R__ | Konstantin Sorokin | https://cran.r-project.org/web/packages/zstdr/index.html | __C#__ (streaming) | Dmitry Alexandrov | https://gist.github.com/dimzon/4e7f076dd59fa6df2a3207e1fa6ac406 | __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 ## Ports into other languages This is a re-implementation of Zstandard following the [format specification](https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md) | Language | Author | URL | | ------------ | ------------------- | ------------------------------------- | | __Java__ (decoder) | Martin Traverso | https://github.com/airlift/aircompressor/tree/master/src/main/java/io/airlift/compress/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 : #### Featured <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> </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> <li><a href="https://prestodb.io/" ><img src="images/prestoDB.png"/></a> [Presto](https://github.com/prestodb/presto/tree/master/presto-orc/src/main/java/com/facebook/presto/orc/zstd) </li> <li><a href="https://hbase.apache.org/" ><img src="images/hbase.png" /></a> [HBase](https://issues.apache.org/jira/browse/HBASE-16710) </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> <li><a href="https://www.cog-genomics.org/plink/2.0/"><img src="images/hulon.png"/></a> [PLink2](https://www.cog-genomics.org/plink/2.0/) </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> <li><a href="https://www.torproject.org/" ><img src="images/tor.png" /></a> [Tor](https://blog.torproject.org/blog/tor-0312-alpha-out-notes-about-0311-alpha) </li> </ul> </div> #### Games <div class="container"> <ul class="list-inline"> <li><a href="http://masseffect.bioware.com/" ><img src="images/andromeda.png"/></a> [Mass Effect:Andromeda](https://youtu.be/u3zSdu2mp9A?t=6m33s) </li> <li><a href="https://github.com/Siv3D/OpenSiv3D"><img src="images/siv3d.png" /></a> [OpenSiv3D](https://github.com/Siv3D/OpenSiv3D/tree/master/Siv3D/Source/ThirdParty/zstd) </li> <li><a href="http://www.esenthel.com/"> <img src="images/esenthel.png" /></a> [Esenthel](http://www.esenthel.com/?id=feature_list) </li> <li><a href="https://godotengine.org/"> <img src="images/godot.png" /></a> [Godot](https://github.com/godotengine/godot/tree/master/thirdparty/zstd) </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="http://www.libarchive.org/" ><img src="images/libarchive.png"/></a> [libarchive](https://github.com/libarchive/libarchive/pull/905) </li> <li><a href="https://borgbackup.readthedocs.io/en/stable/"><img src="images/borg50.png"/></a> [Backup](https://github.com/borgbackup/borg/issues/1633#issuecomment-307556500) </li> <li><a href="http://www.powerarchiver.com/" ><img src="images/powerarc.png"/></a> [PowerAchiver](http://www.powerarchiver.com/2017/07/07/powerarchiver-2017-release-candidate-2-released/) </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> <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> ---