zfs/module/zstd
Rich Ercolani f375b23c02
Tiered early abort, zstd edition
It turns out that "do LZ4 and zstd-1 both fail" is a great heuristic
for "don't even bother trying higher zstd tiers".

By way of illustration:
$ cat /incompress | mbuffer | zfs recv -o compression=zstd-12 evenfaster/lowcomp_1M_zstd12_normal
summary: 39.8 GiByte in  3min 40.2sec - average of  185 MiB/s
$ echo 3 | sudo tee /sys/module/zzstd/parameters/zstd_lz4_pass
3
$ cat /incompress | mbuffer -m 4G | zfs recv -o compression=zstd-12 evenfaster/lowcomp_1M_zstd12_patched
summary: 39.8 GiByte in 48.6sec - average of  839 MiB/s
$ sudo zfs list -p -o name,used,lused,ratio evenfaster/lowcomp_1M_zstd12_normal evenfaster/lowcomp_1M_zstd12_patched
NAME                                         USED        LUSED  RATIO
evenfaster/lowcomp_1M_zstd12_normal   39549931520  42721221632   1.08
evenfaster/lowcomp_1M_zstd12_patched  39626399744  42721217536   1.07
$ python3 -c "print(39626399744 - 39549931520)"
76468224
$

I'll take 76 MB out of 42 GB for > 4x speedup.

Reviewed-by: Allan Jude <allan@klarasystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Reviewed-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Closes #13244
2022-05-24 09:43:22 -07:00
..
include linux: module: weld all but spl.ko into zfs.ko 2022-04-20 13:28:24 -07:00
lib Silence unused-but-set-variable warnings 2022-04-29 14:21:11 -07:00
README.md linux: module: weld all but spl.ko into zfs.ko 2022-04-20 13:28:24 -07:00
zfs_zstd.c Tiered early abort, zstd edition 2022-05-24 09:43:22 -07:00
zstd-in.c Import ZStandard v1.4.5 2020-08-20 10:30:06 -07:00
zstd_sparc.c Fix cross-endian interoperability of zstd 2021-08-30 14:13:46 -07:00

README.md

ZSTD-On-ZFS Library Manual

Introduction

This subtree contains the ZSTD library used in ZFS. It is heavily cut-down by dropping any unneeded files, and combined into a single file, but otherwise is intentionally unmodified. Please do not alter the file containing the zstd library, besides upgrading to a newer ZSTD release.

Tree structure:

  • zfs_zstd.c are the actual zfs kernel module hooks.
  • lib/ contains the unmodified version of the Zstandard library
  • zstd-in.c is our template file for generating the single-file library
  • include/: This directory contains supplemental includes for platform compatibility, which are not expected to be used by ZFS elsewhere in the future. Thus we keep them private to ZSTD.

Updating ZSTD

To update ZSTD the following steps need to be taken:

  1. Grab the latest release of ZSTD.
  2. Copy the files output by the following script to module/zstd/lib/: grep include [path to zstd]/contrib/single_file_libs/zstd-in.c | awk '{ print $2 }'
  3. Remove debug.c, threading.c, and zstdmt_compress.c.
  4. Update Makefiles with resulting file lists.
  5. Follow symbol renaming notes in include/zstd_compat_wrapper.h

Altering ZSTD and breaking changes

If ZSTD made changes that break compatibility or you need to make breaking changes to the way we handle ZSTD, it is required to maintain backwards compatibility.

We already save the ZSTD version number within the block header to be used to add future compatibility checks and/or fixes. However, currently it is not actually used in such a way.