Zstd
Original author(s) | Yann Collet |
---|---|
Developer(s) | Yann Collet, Przemysław Skibiński (inikep) |
Initial release | 23 January 2015 |
Stable release | 1.4.5
/ 22 May 2020[1] |
Repository | |
Written in | C |
Operating system | Cross-platform |
Platform | Portable |
Type | Data compression |
License | Dual: BSD License + GPLv2 |
Website | facebook |
Zstandard (or zstd) is a lossless data compression algorithm developed by Yann Collet at Facebook. Zstd is the reference implementation in C. Version 1 of this implementation was released as free software on 31 August 2016.[2][3]
Features
Zstandard was designed to give a compression ratio comparable to that of the DEFLATE algorithm (developed in 1991 and used in the original ZIP and gzip programs), but faster, especially for decompression. It is tunable with compression levels ranging from negative 5 (fastest)[4] to 22 (slowest in compression speed, but best compression ratio).
The zstd package includes parallel (multi-threaded) implementations of both compression and decompression. Starting from version 1.3.2 (October 2017), zstd optionally implements very long range search and deduplication (--long
, 128 MiB window) similar to rzip or lrzip.[5]
Compression speed can vary by a factor of 20 or more between the fastest and slowest levels, while decompression is uniformly fast, varying by less than 20% between the fastest and slowest levels.[6] Zstandard command-line has an "adaptive" (--adapt
) mode that varies compression level depending on I/O conditions, mainly how fast it can write the output.
Zstd at its maximum compression level gives a compression ratio close to lzma, lzham, and ppmx, and performs better than lza, or bzip2.[7][8] Zstandard reaches the current Pareto frontier, as it decompresses faster than any other currently-available algorithm with similar or better compression ratio.[9][10]
Dictionaries can have a large impact on the compression ratio of small files, so Zstandard can use a user-provided compression dictionary. It also offers a training mode, able to generate a dictionary from a set of samples.[11][12] In particular, one dictionary can be loaded to process large sets of files with redundancy between files, but not necessarily within each file, e.g., log files.
Design
Zstandard combines a dictionary-matching stage (LZ77) with a large search window and a fast entropy coding stage, using both Finite State Entropy (a fast tabled version of ANS, tANS, used for entries in the Sequences section), and Huffman coding (used for entries in the Literals section).[13]
Because of the way that FSE carries over state between symbols, decompression involves processing symbols within the Sequences section of each block in reverse order (from last to first).
Usage
Filename extension |
.zst[14] |
---|---|
Internet media type |
application/zstd[14] |
Magic number | 28 b5 2f fd[14] |
Type of format | Data compression |
Standard | RFC 8478 |
Website | https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md |
Internet media type | application/zstd |
---|---|
Magic number | 37 a4 30 ec[14] |
Standard | RFC 8478 |
Website | https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md#dictionary-format |
The Linux kernel has included Zstandard since November 2017 (version 4.14) as a compression method for the btrfs and squashfs filesystems.[15][16][17]
In 2017, Allan Jude integrated Zstandard into the FreeBSD kernel[18] and used it to create a proof of concept OpenZFS compression method.[6] It was subsequently integrated as a compressor option for core dumps (both user programs and kernel panics).
The AWS Redshift and RocksDB databases include support for field compression using Zstandard.[19]
In March 2018, Canonical tested[20] the use of zstd as a deb package compression method by default for the Ubuntu Linux distribution. Compared with xz compression of deb packages, zstd at level 19 decompresses significantly faster, but at the cost of 6% larger package files. Debian developer Ian Jackson favored waiting several years before official adoption.[21][22][23]
In 2018 the algorithm was published as RFC 8478, which also defines an associated media type "application/zstd", filename extension "zst", and HTTP content encoding "zstd".[14]
Arch Linux added support for zstd as a package compression method in October 2019 with the release of the pacman 5.2 package manager,[24] and in January 2020 switched from xz to zstd for the packages in the official repository. Arch uses zstd -c -T0 --ultra -20 -
, the size of all compressed packages combined increased by 0.8% (compared to xz), the decompression speed is 1300% faster, decompression memory increased by 50 MiB when using multiple threads, compression memory increases but scales with the number of threads used.[25][26][27][28]
Fedora added ZStandard support to RPM in May 2018 (Fedora release 28), and used it for packaging the release in October 2019 (Fedora 31)[29]
Full implementation of the algorithm with an option to choose the compression level is used in the .NSZ / .XCZ[30] file formats, developed by the homebrew community for the Nintendo Switch hybrid game console.[31]
License
The reference implementation is licensed under the BSD license, published at GitHub.[32] Since version 1.0, it had an additional Grant of Patent Rights.[33]
From version 1.3.1,[34] this patent grant was dropped and the license was changed to a BSD + GPLv2 dual license.[35]
See also
- Zlib
- LZFSE – a similar algorithm by Apple used since iOS 9 and OS X 10.11 made open source on 1 June 2016
- LZ4 (compression algorithm) – a fast member of the LZ77 family
References
- ^ "Releases - facebook/zstd". Retrieved 22 May 2020 – via GitHub.
- ^ Sergio De Simone (2 September 2016). "Facebook Open-Sources New Compression Algorithm Outperforming Zlib". InfoQ. Retrieved 20 April 2019.
- ^ "Life imitates satire: Facebook touts zlib killer just like Silicon Valley's Pied Piper". The Register. 31 August 2016. Retrieved 6 September 2016.
- ^ https://github.com/facebook/zstd/releases/tag/v1.3.4 Faster compression levels
- ^ "Command Line Interface for Zstandard library". GitHub.
- ^ a b "ZStandard in ZFS" (PDF). open-zfs.org. 2017. Retrieved 20 April 2019.
- ^ Matt Mahoney. "Silesia Open Source Compression Benchmark". Retrieved 10 May 2019.
- ^ Matt Mahoney (29 August 2016). "Large Text Compression Benchmark, .2157 zstd". Retrieved 1 September 2016.
- ^ TurboBench: Static/Dynamic web content compression benchmark, PowTurbo
- ^ Matt Mahoney, Silesia Open Source Compression Benchmark
- ^ "Facebook developers report massive speedups and compression ratio improvements when using dictionaries" (PDF).
- ^ "Smaller and faster data compression with Zstandard". Facebook. 31 August 2016.
- ^ "facebook/zstd". GitHub.
- ^ a b c d e Collet, Yann (October 2018). Kucherawy, Murray S. (ed.). Zstandard Compression and the application/zstd Media Type. Internet Engineering Task Force Request for Comments. doi:10.17487/RFC8478. RFC 8478. Retrieved 7 October 2020.
- ^ "The rest of the 4.14 merge window [LWN.net]". lwn.net.
- ^ "Linux_4.14 - Linux Kernel Newbies". Kernelnewbies.org. Retrieved 16 August 2018.
- ^ "Zstd Compression For Btrfs & Squashfs Set For Linux 4.14, Already Used Within Facebook - Phoronix". www.phoronix.com.
- ^ https://github.com/freebsd/freebsd/commit/28ef16535cde21eeeaf75f6006b3a77952b3b51
- ^ "Zstandard Encoding - Amazon Redshift". 20 April 2019.
- ^ Larabel, Michael (12 March 2018). "Canonical Working On Zstd-Compressed Debian Packages For Ubuntu". phoronix.com. Phoronix Media. Retrieved 29 October 2019.
The developers at Canonical are considering a feature freeze exception to get this newly-developed Zstd Apt/Dpkg support in Ubuntu 18.04 LTS. In doing so, they mention they would be looking at enabling Zstd compression for packages by default in Ubuntu 18.10.
- ^ "New Ubuntu Installs Could Be Speed Up by 10% with the Zstd Compression Algorithm". Softpedia. 12 March 2018. Retrieved 13 August 2018.
- ^ "Canonical Working On Zstd-Compressed Debian Packages For Ubuntu". phoronix. 12 March 2018. Retrieved 13 August 2018.
- ^ RFC: Support for zstd in .deb packages?, Ian Jackson, 2018-04-27.
- ^ https://www.phoronix.com/scan.php?page=news_item&px=Arch-Linux-Pacman-Zstd-Near
- ^ Broda, Robin (4 January 2020). "Now using Zstandard instead of xz for package compression". Arch Linux. Retrieved 5 January 2020.
- ^ [arch-dev-public RFC: (devtools) Changing default compression method to zstd], Robin Broda, 2019-03-25.
- ^ Clarify zstd compressor output compatibility guarantees across versions, Yann Collet, assuring important for the same binary result is zstd version and compression level, 2019-03-18.
- ^ makepkg.conf: change default compression method to zstd, Robin Broda, Levente Polyak, default compression with zstd -c -T0 --ultra -20 -, 2019-12-27.
- ^ https://fedoraproject.org/wiki/Changes/Switch_RPMs_to_zstd_compression
- ^ "RELEASE - nsZip - NSP compressor/decompressor to reduce storage". GBAtemp.net - The Independent Video Game Community. Retrieved 3 November 2019.
- ^ Bosshard, Nico (31 October 2019), nsZip is a tool to compress/decompress Nintendo Switch games using the here specified NSZ file format: nicoboss/nsZip, retrieved 3 November 2019
- ^ "Facebook open sources Zstandard data compression algorithm, aims to replace technology behind Zip". ZDnet. 31 August 2016. Retrieved 1 September 2016.
- ^ zstd/PATENTS "Additional Grant of Patent Rights Version 2", Facebook
- ^ "Zstd v1.3.1 release", GitHub "facebook/zstd"
- ^ "New license", GitHub "facebook/zstd"
External links
- Official website
- zstd on GitHub
- "Smaller and faster data compression with Zstandard", Yann Collet and Chip Turner, 31 August 2016, Facebook Announcement
- The Guardian is using ZStandard instead of zlib