Zstd Explained
| Zstandard |
| Author: | Yann Collet |
| Developer: | Yann Collet, Nick Terrell, Przemysław Skibiński[1] |
| Operating System: | Cross-platform |
| Genre: | Data compression |
| Programming Language: | C |
| License: | BSD-3-Clause or GPL-2.0-or-later (dual-licensed) |
| Platform: | Portable |
Zstandard is a lossless data compression algorithm developed by Yann Collet at Facebook. Zstd is the corresponding reference implementation in C, released as open-source software on 31 August 2016.[2] [3]
The algorithm was published in 2018 as, which also defines an associated media type "application/zstd", filename extension "zst", and HTTP content encoding "zstd".[4]
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 7 (fastest)[5] to 22 (slowest in compression speed, but best compression ratio).
Starting from version 1.3.2 (October 2017), zstd optionally implements very-long-range search and deduplication (128 MiB window) similar to rzip or lrzip.[6]
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.[7] The Zstandard command-line has an "adaptive" mode that varies compression level depending on I/O conditions, mainly how fast it can write the output.
Zstandard at its maximum compression level gives a compression ratio close to lzma, lzham, and ppmx.[8] [9] As of 2019, Zstandard reaches the Pareto frontier as it decompresses faster than any other open source algorithm with a similar or better compression ratio.
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.[10] [11] In particular, one dictionary can be loaded to process large sets of files with redundancy between files, but not necessarily within each file, such as for log files.
Design
Zstandard combines a dictionary-matching stage (LZ77) with a large search window and a fast entropy-coding stage. It uses Huffman coding alongside finite-state entropy (FSE), a variant of tANS.[12]
Usage
| Zstandard Dictionary |
| Magic: | 37 A4 30 EC |
The Linux kernel has included Zstandard since November 2017 (version 4.14) as a compression method for the btrfs and squashfs filesystems,[14] [15] [16] as well as for loadable kernel modules.
In 2017, Allan Jude integrated Zstandard into the FreeBSD kernel,[17] and it was subsequently integrated as a compressor option for core dumps (both user programs and kernel panics). It was also used to create a proof-of-concept OpenZFS compression method which was integrated in 2020.[18]
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. Support was added to Debian (and subsequently, Ubuntu) in April 2018 (in version 1.6~rc1).[21] [20] [22]
Fedora added ZStandard support to RPM in May 2018 (Fedora release 28) and used it for packaging the release in October 2019 (Fedora 31).[23] In Fedora 33, the filesystem is compressed by default with zstd.[24] [25]
Arch Linux added support for zstd as a package compression method in October 2019 with the release of the pacman 5.2 package manager[26] 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 14 times faster, decompression memory increased by 50 MiB when using multiple threads, and compression memory increased but scales with the number of threads used.[27] [28] [29] Arch Linux later also switched to zstd as the default compression algorithm for mkinitcpio initial ramdisk generator.[30]
On 15 June 2020, Zstandard was implemented in version 6.3.8 of the zip file format with codec number 93, deprecating the previous codec number of 20 as it was implemented in version 6.3.7, released on 1 June.
On 31 October 2023 Official Zstd support for compression/decompression was added to Windows Explorer in Windows 11 (via update package KB5031455)
In March 2024, Google Chrome version 123 (and Chromium-based browsers such as Brave or Microsoft Edge) added zstd support in the HTTP header Content-Encoding.[31] In May 2024, Firefox release 126.0 added zstd support in the HTTP header Content-Encoding.[32]
License
The reference implementation is licensed under the BSD license, published at GitHub.[33] Since version 1.0, published 31 August 2016,[34] it had an additional Grant of Patent Rights.[35]
From version 1.3.1, released 20 August 2017,[36] this patent grant was dropped and the license was changed to a BSD + GPLv2 dual license.[37]
See also
- LZ4 (compression algorithm) – a fast member of the LZ77 family
- LZFSE – a similar algorithm by Apple used since iOS 9 and OS X 10.11 and made open source on 1 June 2016
- Zlib
- Brotli – also integrated into browsers
- Gzip – one of the most widely used compression tools
External links
Notes and References
- Web site: Contributors to facebook/zstd . 26 Jan 2021 . github.com.
- News: De Simone. Sergio. 2 September 2016. Facebook Open-Sources New Compression Algorithm Outperforming Zlib. InfoQ. 20 April 2019. 7 October 2021. https://web.archive.org/web/20211007055903/https://www.infoq.com/news/2016/09/facebook-zstandard-compression. live.
- News: Williams . Chris . 31 August 2016 . Life imitates satire: Facebook touts zlib killer just like Silicon Valley's Pied Piper . 2016-09-06 . . 3 September 2016 . https://web.archive.org/web/20160903085435/http://www.theregister.co.uk/2016/08/31/facebook_open_source_database/ . live .
- Zstandard Compression and the application/zstd Media Type. 8478. Collet. Yann. Kucherawy. Murray S.. Murray Kucherawy. October 2018. 7 October 2020. Internet Engineering Task Force Request for Comments.
- Web site: Release Zstandard v1.3.4 - faster everything · facebook/zstd . 2024-03-27 . GitHub . en . 11 September 2021 . https://web.archive.org/web/20210911024159/https://github.com/facebook/zstd/releases/tag/v1.3.4 . live .
- Web site: 28 October 2021 . Command Line Interface for Zstandard library . GitHub . Facebook . en.
- Web site: Jude. Allan. ZStandard in ZFS. 2017. 20 April 2019. open-zfs.org. 18 December 2019. https://web.archive.org/web/20191218102535/http://open-zfs.org/w/images/b/b3/03-OpenZFS_2017_-_ZStandard_in_ZFS.pdf. live.
- Web site: Silesia Open Source Compression Benchmark. Mahoney. Matt. 10 May 2019. 21 January 2022. https://web.archive.org/web/20220121165038/http://mattmahoney.net/dc/silesia.html. live.
- Web site: Large Text Compression Benchmark, .2157 zstd. Mahoney. Matt. 29 August 2016. 10 May 2019. 31 March 2022. https://web.archive.org/web/20220331031650/http://mattmahoney.net/dc/text.html. live.
- Web site: Bockelman . Brian . Pivraski . Jim . Shadura . Oksana . Zhang . Zhe . 11 October 2017 . DIANA Contributions Update . Facebook developers report massive speedups and compression ratio improvements when using dictionaries . 27 March 2024 . . 25 January 2018 . https://web.archive.org/web/20180125015337/https://indico.fnal.gov/event/15154/contribution/5/material/slides/0.pdf . live .
- Web site: Collet. Yann. Turner. Chip. Smaller and faster data compression with Zstandard. 31 August 2016. Facebook. 3 September 2016. 27 September 2016. https://web.archive.org/web/20160927080023/https://code.facebook.com/posts/1658392934479273/smaller-and-faster-data-compression-with-zstandard. live.
- Web site: Zstandard Compression Format. GitHub. Facebook. 28 October 2021.
- Zstandard Compression and the application/zstd Media Type . 8878 . Collet . Yann . Kucherawy . Murray S. . Murray Kucherawy . February 2021 . 26 February 2023 . Internet Engineering Task Force Request for Comments.
- Web site: Corbet . Jonathan . 17 September 2017 . The rest of the 4.14 merge window [LWN.net] ]. 27 March 2024 . . 22 November 2021 . https://web.archive.org/web/20211122141753/https://lwn.net/Articles/733846/ . live .
- Web site: 30 December 2017 . Linux_4.14 . 16 August 2018 . Kernelnewbies.org . 10 January 2018 . https://web.archive.org/web/20180110114105/https://kernelnewbies.org/Linux_4.14 . live .
- Web site: Larabel . Michael . 8 September 2017 . Zstd Compression For Btrfs & Squashfs Set For Linux 4.14, Already Used Within Facebook . www.phoronix.com . 13 November 2017 . 25 July 2019 . https://web.archive.org/web/20190725122757/https://www.phoronix.com/scan.php?page=news_item&px=Linux-4.14-Zstd-Pull . live .
- Web site: Integrate ZSTD into the kernel · freebsd/Freebsd-SRC@28ef165 . . The FreeBSD Project .
- Web site: Add ZSTD support to ZFS · openzfs/ZFS@10b3c7f. GitHub. OpenZFS. 12 October 2020. 10 September 2020. https://web.archive.org/web/20200910151903/https://github.com/openzfs/zfs/commit/10b3c7f5e424f54b3ba82dbf1600d866e64ec0a0. live.
- Web site: Zstandard Encoding - Amazon Redshift. 20 April 2019. Amazon Web Services. 24 January 2018. 14 August 2021. https://web.archive.org/web/20210814225631/https://docs.aws.amazon.com/redshift/latest/dg/zstd-encoding.html. dead.
- Web site: Canonical Working On Zstd-Compressed Debian Packages For Ubuntu . Larabel . Michael . 12 March 2018 . phoronix.com . Phoronix Media . 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. . 16 August 2021 . https://web.archive.org/web/20210816101454/https://www.phoronix.com/scan.php?page=news_item&px=Ubuntu-Zstd-Deb-Packages . live .
- Web site: Nestor. Marius. New Ubuntu Installs Could Be Speed Up by 10% with the Zstd Compression Algorithm. Softpedia. 13 August 2018. 12 March 2018. 6 October 2021. https://web.archive.org/web/20211006045638/https://news.softpedia.com/news/new-ubuntu-installs-could-be-speed-up-by-10-with-the-zstd-compression-algorithm-520177.shtml. live.
- Web site: Debian Changelog for apt. Debian. 7 November 2022. en. 19 April 2021.
- Web site: Changes/Switch RPMS to ZSTD compression . Fedora Project Wiki . 8 July 2020 . 2 June 2019 . https://web.archive.org/web/20190602192906/https://fedoraproject.org/wiki/Changes/Switch_RPMs_to_zstd_compression . live .
- Web site: Thurman . Andrew . 14 April 2021 . Fedora Workstation 34 feature focus: Btrfs transparent compression . 12 May 2022 . Fedora Magazine . en-US.
- Web site: Changes/BtrfsTransparentCompression . 2022-05-12 . Fedora Project Wiki.
- Web site: Larabel . Michael . 16 October 2019 . Arch Linux Nears Roll-Out of ZSTD Compressed Packages for Faster Pacman Installs . Phoronix . 21 October 2019 . 18 March 2022 . https://web.archive.org/web/20220318032712/https://www.phoronix.com/scan.php?page=news_item&px=Arch-Linux-Pacman-Zstd-Near . live .
- Web site: Now using Zstandard instead of xz for package compression . Broda . Mara . 4 January 2020 . Arch Linux . 5 January 2020 . 18 March 2022 . https://web.archive.org/web/20220318032814/https://archlinux.org/news/now-using-zstandard-instead-of-xz-for-package-compression/ . live .
- RFC: (devtools) Changing default compression method to zstd . arch-dev-public . Mara . Broda . 2019-03-25 . 5 January 2020 . 17 August 2021 . https://web.archive.org/web/20210817122817/https://lists.archlinux.org/pipermail/arch-dev-public/2019-March/029542.html . live .
- Web site: Broda . Mara . Polyak . Levente . 27 December 2019 . makepkg.conf: change default compression method to zstd . .
- Web site: Razzolini. Giancarlo. 19 February 2021. News: Moving to Zstandard images by default on mkinitcpio. 2021-12-28. Arch Linux.
- Web site: Jara . Adriana . 19 March 2024 . New in Chrome 123 Chrome Blog . 16 April 2024 . Chrome for Developers . Google . en.
- Web site: Firefox 126.0, See All New Features, Updates and Fixes . May 2024 . 15 May 2024 . 13 May 2024 . https://web.archive.org/web/20240513202356/https://www.mozilla.org/en-US/firefox/126.0/releasenotes/ . live .
- News: Dignan . Larry . Facebook open sources Zstandard data compression algorithm, aims to replace technology behind Zip. 31 August 2016. ZDnet. 1 September 2016.
- Web site: Zstandard v1.0 . 2025-01-23 . 2016-08-31 . GitHub . Facebook . 7 April 2023 . https://web.archive.org/web/20230407231122/https://github.com/facebook/zstd/releases/tag/v1.0.0 . live .
- Web site: v1.3.0/PATENTS · facebook/zstd . 27 March 2024 . 30 August 2016 . GitHub . Facebook . en . 15 May 2021 . https://web.archive.org/web/20210515045048/https://github.com/facebook/zstd/blob/v1.3.0/PATENTS . live .
- Web site: Release Zstandard v1.3.1 · facebook/zstd . 27 March 2024 . 20 August 2017 . GitHub . Facebook . en . 12 September 2020 . https://web.archive.org/web/20200912235153/https://github.com/facebook/zstd/releases/tag/v1.3.1 . live .
- Web site: New license by Cyan4973 · Pull Request #801 · facebook/zstd . 27 March 2024 . 19 August 2017 . GitHub . Facebook . en . 12 September 2020 . https://web.archive.org/web/20200912201251/https://github.com/facebook/zstd/pull/801 . live .