diff --git a/en_US.ISO8859-1/books/handbook/zfs/chapter.xml b/en_US.ISO8859-1/books/handbook/zfs/chapter.xml --- a/en_US.ISO8859-1/books/handbook/zfs/chapter.xml +++ b/en_US.ISO8859-1/books/handbook/zfs/chapter.xml @@ -2926,6 +2926,69 @@ However since quotas do not consider compression, more data may be written than would fit with uncompressed backups. + + + Zstandard Compression + + In OpenZFS 2.0, a new compression + algorithm was added. Zstandard (Zstd) + offers higher compression ratios than the default + LZ4 while offering much greater speeds + than the alternative, gzip. + OpenZFS 2.0 is available starting with + &os; 12.1-RELEASE via + sysutils/openzfs and is the default in + &os; 13.0. + + Zstandard provides a large selection of compression + levels, providing fine-grained control over performance + versus compression ratio. One of the main advantages of + Zstd is that the decompression speed is + independent of the compression level. For data that is + written once but read many times, there is no disadvantage + to using higher compression levels as the read speed will be + just as fast as if a lesser compression level had been + used. + + Even when data is updated frequently, there are often + performance gains that come from enabling compression. One + of the biggest advantages comes from the compressed ARC + feature. ZFS's Adaptive Replacement + Cache (ARC) caches the compressed version + of the data in RAM, decompressing it each + time it is needed. This allows the same amount of cache to + store more data and metadata, increasing the cache hit + ratio. + + ZFS offers 19 levels of Zstandard + compression, each offering incrementally more space savings + in exchange for slower compression. The default level is + zstd-3 and offers greater compression + than LZ4 without being significantly + slower. Levels above 10 require significant amounts of + memory to compress each block, so they are discouraged on + systems with less than 16 GB of RAM. + ZFS also implements a selection of the + Zstandard fast levels, which get + correspondingly faster but offer lower compression ratios. + ZFS supports + zstd-fast-1 through + zstd-fast-10, + zstd-fast-20 through + zstd-fast-100 in increments of 10, and + finally zstd-fast-500 and + zstd-fast-1000 which provide minimal + compression, but offer very high performance. + + If ZFS is not able to allocate the required memory to + compress a block with Zstandard, it will fall back to + storing the block uncompressed. This is unlikely to happen + outside of the highest levels of Zstandard on systems that + are memory constrained. The sysctl + kstat.zfs.misc.zstd.compress_alloc_fail + counts how many times this has occurred since the + ZFS module was loaded. +