<a name="benchmarks"></a> Benchmarks ---------- For comparison, several fast compression algorithms were tested and compared on a server running Linux Debian (`Linux version 4.14.0-3-amd64`), with a Core i7-6700K CPU @ 4.0GHz, using [lzbench], an open-source in-memory benchmark by @inikep compiled with [gcc] 7.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 [gcc]: https://gcc.gnu.org/ | Compressor name | Ratio | Compression| Decompress.| | --------------- | ------| -----------| ---------- | | **zstd 1.3.4 -1** | 2.877 | 470 MB/s | 1380 MB/s | | zlib 1.2.11 -1 | 2.743 | 110 MB/s | 400 MB/s | | brotli 1.0.2 -0 | 2.701 | 410 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.8.1 | 2.101 | 750 MB/s | 3700 MB/s | | snappy 1.1.4 | 2.091 | 530 MB/s | 1800 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 server running Linux Debian (`Linux version 4.14.0-3-amd64`) with a Core i7-6700K CPU @ 4.0GHz, using [lzbench], an open-source in-memory benchmark by @inikep compiled with [gcc] 7.3.0, on the [Silesia compression corpus]. | Compression Speed vs Ratio | Decompression Speed | | ---------------------------|-------------------- | | <img src="https://raw.githubusercontent.com/facebook/zstd/dev/doc/images/CSpeed2.png" alt="Compression Speed vs Ratio" style="height:500px;"> | <img src="https://raw.githubusercontent.com/facebook/zstd/dev/doc/images/DSpeed3.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. ### 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 | | __Python__ (full) | Gregory Szorc | https://pypi.python.org/pypi/zstandard | __Python__ (simple) | Sergey Dryabzhinsky | https://github.com/sergey-dryabzhinsky/python-zstd | __Rust__ | Alexandre Bury | https://crates.io/crates/zstd | | __C#__ | SKB Kontur | https://github.com/skbkontur/ZstdNet | | __C#__ (streaming) | Bernhard Pichler | https://github.com/bp74/Zstandard.Net | __Javascript__ (emscripten) | Yoshihito | https://www.npmjs.com/package/zstd-codec | __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 | | __Swift__ | Anatoli Peredera | https://github.com/omniprog/SwiftZSTD | | __Perl__ | Jiro Nishiguchi | https://metacpan.org/release/Compress-Zstd | __Objective C__ | Micha Mazaheri | https://github.com/luckymarmot/ZstdKit | __Ruby__ | SpringMT | https://github.com/SpringMT/zstd-ruby | | __Ruby__ (FFI) | Michael Sievers | https://github.com/msievers/zstandard-ruby | | __Go__ | Vianney Tran | https://github.com/DataDog/zstd | | __Go__ (+dict) | Aliaksandr Valialkin | https://github.com/valyala/gozstd | | __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__ | Kenta Sato | https://github.com/bicycle1885/CodecZstd.jl | __Tcl__ | D. Bohdan | https://wiki.tcl-lang.org/48788 | | __R__ | Konstantin Sorokin | https://cran.r-project.org/web/packages/zstdr/index.html | __SmallTalk__| Instantiations | http://www.instantiations.com/resources/goodies.html#instantiations | __Elixir__ | chenzhuoyu | https://hex.pm/packages/ex_zstd | | __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 Interfaces Tino Reichardt has created a version of [7-zip archive manager with Zstandard](https://mcmilk.de/projects/7-Zip-ZStd/). Denis Anisimov, of TC4shell fame, also developed a [7-zip plugin with Zstandard support](http://www.tc4shell.com/en/7zip/modern7z/). <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://www.kernel.org/" ><img src="images/linux.png" /></a> [Linux](https://www.phoronix.com/scan.php?page=article&item=linux-414-features) </li> <li><a href="https://www.freebsd.org/" ><img src="images/freebsd.png" /></a> [FreeBSD](https://svnweb.freebsd.org/changeset/base/329240)</li> <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](https://www.mercurial-scm.org/wiki/Release4.1)</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> #### File systems <div class="container"> <ul class="list-inline"> <li><a href="https://btrfs.wiki.kernel.org/index.php/Main_Page"><img src="images/btrfs.png"/></a> [BtrFS](https://btrfs.wiki.kernel.org/index.php/Compression) </li> <li><a href="https://en.wikipedia.org/wiki/SquashFS"><img src="images/squashfs.png"/></a> [SquashFS](https://www.phoronix.com/scan.php?page=news_item&px=Linux-4.14-Zstd-Pull) </li> <li><a href="http://open-zfs.org/wiki/Main_Page"><img src="images/openzfs.png"/></a> [OpenZFS](https://www.bsdcan.org/2018/schedule/events/947.en.html) </li> <li><a href="https://en.wikipedia.org/wiki/ReiserFS"><img src="images/reiserfs.png"/></a> [ReiserFS](https://metztli.it/blog/index.php/building-new-reiser4-software-format?blog=4) </li> </ul> </div> #### Web <div class="container"> <ul class="list-inline"> <li><a href="https://github.com/tokers/zstd-nginx-module"><img src="images/nginx.png"/></a> [nginx (module)](https://github.com/tokers/zstd-nginx-module) </li> <li><a href="https://gitlab.com/gnuwget/wget2" ><img src="images/wget2.png" /></a> [wget2](https://twitter.com/ruehsen/status/1050701663995129862) </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> <li><a href="http://github.khronos.org/KTX-Specification/"><img src="images/ktx.png"/></a> [Khronos's KTX](http://github.khronos.org/KTX-Specification/) </li> </ul> </div> #### Other <div class="container"> <ul class="list-inline"> <li><a href="https://www.ubuntu.com/" ><img src="images/ubuntu.png" /></a> [Ubuntu](https://www.omgubuntu.co.uk/2018/03/faster-ubuntu-installs-zstd-compression) </li> <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/compression/Compression.h#L83) </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://www.libarchive.org/" ><img src="images/libarchive.png"/></a> [libarchive](https://github.com/libarchive/libarchive/pull/905) </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="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://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.ultimatepp.org/" ><img src="images/uppframe.png"/></a> [U++](http://www.ultimatepp.org/www$uppweb$Roadmap$en-us.html) </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> ---