git: 0412a4034e27 - main - MFV: zstd 1.6.0
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 25 Nov 2026 23:26:31 UTC
The branch main has been updated by delphij:
URL: https://cgit.FreeBSD.org/src/commit/?id=0412a4034e277629245c8bd87978680216bb06b5
commit 0412a4034e277629245c8bd87978680216bb06b5
Merge: f0ce2ae67f9f 8ba8f15f7888
Author: Xin LI <delphij@FreeBSD.org>
AuthorDate: 2026-11-25 23:23:23 +0000
Commit: Xin LI <delphij@FreeBSD.org>
CommitDate: 2026-11-25 23:24:38 +0000
MFV: zstd 1.6.0
Security: CVE-2026-124851
MFC after: 3 days
lib/libzstd/Makefile | 5 +-
stand/defs.mk | 4 +-
sys/conf/kern.pre.mk | 3 +-
sys/contrib/zstd/CHANGELOG | 62 ++
sys/contrib/zstd/FREEBSD-Xlist | 2 +
sys/contrib/zstd/FREEBSD-upgrade | 2 +-
sys/contrib/zstd/README.md | 77 +-
sys/contrib/zstd/lib/README.md | 30 +-
sys/contrib/zstd/lib/common/allocations.h | 8 +-
sys/contrib/zstd/lib/common/bits.h | 2 +-
sys/contrib/zstd/lib/common/bitstream.h | 6 +-
sys/contrib/zstd/lib/common/bmi2.h | 40 +
sys/contrib/zstd/lib/common/compiler.h | 48 +-
sys/contrib/zstd/lib/common/entropy_common.c | 13 +-
sys/contrib/zstd/lib/common/fse_decompress.c | 7 +-
sys/contrib/zstd/lib/common/pool.c | 35 +-
sys/contrib/zstd/lib/common/portability_macros.h | 31 +
sys/contrib/zstd/lib/common/threading.c | 18 +-
sys/contrib/zstd/lib/common/zstd_common.c | 9 +
sys/contrib/zstd/lib/common/zstd_internal.h | 6 +-
sys/contrib/zstd/lib/compress/hist.c | 303 ++++++-
sys/contrib/zstd/lib/compress/hist.h | 4 +
sys/contrib/zstd/lib/compress/huf_compress.c | 5 +-
sys/contrib/zstd/lib/compress/zstd_compress.c | 989 ++++++++++++++++-----
.../zstd/lib/compress/zstd_compress_internal.h | 41 +-
.../zstd/lib/compress/zstd_compress_sequences.c | 14 +-
.../zstd/lib/compress/zstd_compress_superblock.c | 19 +-
sys/contrib/zstd/lib/compress/zstd_double_fast.c | 4 +-
sys/contrib/zstd/lib/compress/zstd_fast.c | 4 +-
sys/contrib/zstd/lib/compress/zstd_lazy.c | 54 +-
sys/contrib/zstd/lib/compress/zstd_ldm.c | 22 +-
sys/contrib/zstd/lib/compress/zstd_ldm.h | 11 +
sys/contrib/zstd/lib/compress/zstd_opt.c | 34 +-
sys/contrib/zstd/lib/compress/zstd_preSplit.c | 6 +-
sys/contrib/zstd/lib/compress/zstdmt_compress.c | 103 ++-
sys/contrib/zstd/lib/compress/zstdmt_compress.h | 32 +-
sys/contrib/zstd/lib/decompress/huf_decompress.c | 142 +--
.../zstd/lib/decompress/huf_decompress_amd64.S | 200 ++++-
sys/contrib/zstd/lib/decompress/zstd_ddict.c | 86 +-
sys/contrib/zstd/lib/decompress/zstd_ddict.h | 11 +
sys/contrib/zstd/lib/decompress/zstd_decompress.c | 287 ++++--
.../zstd/lib/decompress/zstd_decompress_block.c | 310 +++++--
.../zstd/lib/decompress/zstd_decompress_internal.h | 21 +-
sys/contrib/zstd/lib/dictBuilder/cover.c | 227 +++--
sys/contrib/zstd/lib/dictBuilder/divsufsort.c | 154 ++--
sys/contrib/zstd/lib/dictBuilder/fastcover.c | 90 +-
sys/contrib/zstd/lib/dictBuilder/zdict.c | 32 +-
sys/contrib/zstd/lib/legacy/zstd_v01.c | 18 +-
sys/contrib/zstd/lib/legacy/zstd_v02.c | 369 +-------
sys/contrib/zstd/lib/legacy/zstd_v03.c | 9 +-
sys/contrib/zstd/lib/legacy/zstd_v04.c | 10 +-
sys/contrib/zstd/lib/legacy/zstd_v05.c | 13 +-
sys/contrib/zstd/lib/legacy/zstd_v06.c | 6 +-
sys/contrib/zstd/lib/legacy/zstd_v07.c | 1 +
sys/contrib/zstd/lib/libzstd.mk | 15 +-
sys/contrib/zstd/lib/libzstd.pc.in | 1 +
sys/contrib/zstd/lib/module.modulemap | 21 -
sys/contrib/zstd/lib/zstd.h | 321 ++++---
sys/contrib/zstd/programs/README.md | 21 +-
sys/contrib/zstd/programs/benchfn.c | 3 +-
sys/contrib/zstd/programs/benchzstd.c | 137 ++-
sys/contrib/zstd/programs/benchzstd.h | 4 +-
sys/contrib/zstd/programs/dibio.c | 31 +-
sys/contrib/zstd/programs/fileio.c | 950 +++++++++++++++-----
sys/contrib/zstd/programs/fileio.h | 8 +-
sys/contrib/zstd/programs/fileio_asyncio.c | 3 +-
sys/contrib/zstd/programs/fileio_types.h | 2 +-
sys/contrib/zstd/programs/platform.h | 1 +
sys/contrib/zstd/programs/timefn.c | 4 +-
sys/contrib/zstd/programs/util.c | 502 +++++++++--
sys/contrib/zstd/programs/util.h | 34 +-
sys/contrib/zstd/programs/zstd.1 | 286 +++++-
sys/contrib/zstd/programs/zstd.1.md | 54 +-
sys/contrib/zstd/programs/zstdcli.c | 256 +++---
sys/contrib/zstd/programs/zstdcli_trace.c | 3 +-
sys/contrib/zstd/programs/zstdgrep | 9 +-
sys/contrib/zstd/programs/zstdgrep.1 | 4 +-
sys/contrib/zstd/programs/zstdgrep.1.md | 4 +-
sys/contrib/zstd/programs/zstdless.1 | 2 +-
sys/contrib/zstd/zlibWrapper/gzguts.h | 1 +
sys/contrib/zstd/zlibWrapper/gzlib.c | 1 +
sys/contrib/zstd/zlibWrapper/gzwrite.c | 11 +-
usr.bin/zstd/Makefile | 1 -
83 files changed, 4668 insertions(+), 2061 deletions(-)
diff --cc lib/libzstd/Makefile
index 82e9d2a5b243,000000000000..1930723c1277
mode 100644,000000..100644
--- a/lib/libzstd/Makefile
+++ b/lib/libzstd/Makefile
@@@ -1,79 -1,0 +1,76 @@@
+PACKAGE= zstd
+LIB_PACKAGE=
+
+LIB= zstd
+SRCS= entropy_common.c \
+ error_private.c \
+ fse_decompress.c \
+ pool.c \
+ threading.c \
+ xxhash.c \
+ zstd_common.c \
+ fse_compress.c \
+ huf_compress.c \
+ zstd_compress.c \
+ zstd_compress_literals.c \
+ zstd_compress_sequences.c \
+ zstd_compress_superblock.c \
+ zstd_preSplit.c \
+ zstdmt_compress.c \
+ huf_decompress.c \
+ zstd_ddict.c \
+ zstd_decompress.c \
+ zstd_decompress_block.c \
- zbuff_common.c \
- zbuff_compress.c \
- zbuff_decompress.c \
+ cover.c \
+ divsufsort.c \
+ zdict.c \
+ zstd_fast.c \
+ zstd_lazy.c \
+ zstd_ldm.c \
+ zstd_opt.c \
+ zstd_double_fast.c \
+ debug.c \
+ hist.c \
+ fastcover.c
+WARNS?= 2
+INCS= zstd.h
+CFLAGS+= -I${ZSTDDIR}/lib -I${ZSTDDIR}/lib/common -DXXH_NAMESPACE=ZSTD_ \
+ -DZSTD_MULTITHREAD=1 -fvisibility=hidden
+LIBADD= pthread
+
+# ZSTD_ASM_SUPPORTED is 0 on FreeBSD but 1 on macOS and Linux. Since we build
+# this as a bootstrap library and don't include any assembly sources in SRCS,
+# explicitly disable assembly.
+CFLAGS+= -DZSTD_DISABLE_ASM
+
+PRIVATELIB= yes
+
+ZSTDDIR= ${SRCTOP}/sys/contrib/zstd
+.PATH: ${ZSTDDIR}/lib/common ${ZSTDDIR}/lib/compress \
- ${ZSTDDIR}/lib/decompress ${ZSTDDIR}/lib/deprecated \
++ ${ZSTDDIR}/lib/decompress \
+ ${ZSTDDIR}/lib/dictBuilder ${ZSTDDIR}/lib
+
+.include <bsd.compiler.mk>
+
+# These symbols are needed by dll-linked CLI zstd(1).
+CFLAGS.pool.c+= -fvisibility=default
+
+CFLAGS.huf_decompress.c+= ${NO_WBITWISE_INSTEAD_OF_LOGICAL}
+
+# https://github.com/facebook/zstd/commit/812e8f2a [zstd 1.4.1]
+# "Note that [GCC] autovectorization still does not do a good job on the
+# optimized version, so it's turned off via attribute and flag. I found
+# that neither attribute nor command-line flag were entirely successful in
+# turning off vectorization, which is why there were both."
+.if ${COMPILER_TYPE} == "gcc"
+CFLAGS.zstd_decompress_block.c+= -fno-tree-vectorize
+.endif
+
+# Work around lack of __bswap[sd]i2() intrinsics on riscv. Probably should be
+# added to one of the runtime C libraries instead.
+.if ${MACHINE_CPUARCH} == "riscv"
+.PATH: ${ZSTDDIR}/lib/freebsd
+SRCS+= zstd_kfreebsd.c
+.endif
+
+.include <bsd.lib.mk>
diff --cc stand/defs.mk
index 8470e973fda8,000000000000..53d1bb347ef8
mode 100644,000000..100644
--- a/stand/defs.mk
+++ b/stand/defs.mk
@@@ -1,281 -1,0 +1,281 @@@
+
+.if !defined(__BOOT_DEFS_MK__)
+__BOOT_DEFS_MK__=${MFILE}
+
+FORTIFY_SOURCE= 0
+
+# We need to define all the MK_ options before including src.opts.mk
+# because it includes bsd.own.mk which needs the right MK_ values,
+# espeically MK_CTF.
+
+MK_CTF= no
+MK_SSP= no
+MK_PIE= no
+MK_RETPOLINE= no
+MK_ZEROREGS= no
+MAN=
+.if !defined(PIC)
+NO_PIC=
+INTERNALLIB=
+.endif
+# Should be NO_CPU_FLAGS, but bsd.cpu.mk is included too early in bsd.init.mk
+# via the early include of bsd.opts.mk. Moving Makefile.inc include earlier in
+# that file causes weirdness, so this is the next best thing. We need to do this
+# because the loader needs very specific flags to work right, and things like
+# CPUTYPE?=native prevent that, and introduce an endless game of whack-a-mole
+# to disable more and more features. Boot loader performance is never improved
+# enough to make that hassle worth chasing.
+_CPUCFLAGS=
+
+.if ${LDFLAGS:M-nostdlib}
+# Sanitizers won't work unless we link against libc (e.g. in userboot/test).
+MK_ASAN:= no
+MK_UBSAN:= no
+.endif
+
+.include <src.opts.mk>
+.include <bsd.linker.mk>
+
+WARNS?= 1
+
+BOOTSRC= ${SRCTOP}/stand
+EDK2INC= ${SYSDIR}/contrib/edk2/Include
+EFISRC= ${BOOTSRC}/efi
+EFIINC= ${EFISRC}/include
+# For amd64, there's a bit of mixed bag. Some of the tree (i386, lib*32) is
+# built 32-bit and some 64-bit (lib*, efi). Centralize all the 32-bit magic here
+# and activate it when DO32 is explicitly defined to be 1.
+.if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1
+EFIINCMD= ${EFIINC}/i386
+.else
+EFIINCMD= ${EFIINC}/${MACHINE}
+.endif
+FDTSRC= ${BOOTSRC}/fdt
+FICLSRC= ${BOOTSRC}/ficl
+LDRSRC= ${BOOTSRC}/common
+LIBLUASRC= ${BOOTSRC}/liblua
+LIBOFWSRC= ${BOOTSRC}/libofw
+LUASRC= ${SRCTOP}/contrib/lua/src
+SASRC= ${BOOTSRC}/libsa
+SAZFSSRC= ${SASRC}/zfs
+SYSDIR= ${SRCTOP}/sys
+UBOOTSRC= ${BOOTSRC}/uboot
+ZFSOSSRC= ${ZFSTOP}/module/os/freebsd/
+ZFSOSINC= ${ZFSTOP}/include/os/freebsd
+LIBCSRC= ${SRCTOP}/lib/libc
+
+BOOTOBJ= ${OBJTOP}/stand
+
+# BINDIR is where we install
+BINDIR?= /boot
+
+# LUAPATH is where we search for and install lua scripts.
+LUAPATH?= /boot/lua
+FLUASRC?= ${SRCTOP}/libexec/flua
+FLUALIB?= ${SRCTOP}/libexec/flua
+
+LIBSA= ${BOOTOBJ}/libsa/libsa.a
+.if ${MACHINE} == "i386"
+LIBSA32= ${LIBSA}
+.else
+LIBSA32= ${BOOTOBJ}/${"${LOADER}" == "loader_ia32":?efi/libsa32efi:libsa32}/libsa32.a
+.endif
+
+# Standard options:
+CFLAGS+= -nostdinc
+# Allow CFLAGS_EARLY.file/target so that code that needs specific stack
+# of include paths can set them up before our include paths. Normally
+# the only thing that should be there are -I directives, and as few of
+# those as possible.
+CFLAGS+= ${CFLAGS_EARLY} ${CFLAGS_EARLY.${.IMPSRC:T}} ${CFLAGS_EARLY.${.TARGET:T}}
+.if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1
+CFLAGS+= -I${BOOTOBJ}/libsa32
+.else
+CFLAGS+= -I${BOOTOBJ}/libsa
+.endif
+CFLAGS+= -I${SASRC} -D_STANDALONE
+CFLAGS+= -I${SYSDIR}
+# Spike the floating point interfaces
+CFLAGS+= -Ddouble=jagged-little-pill -Dfloat=floaty-mcfloatface
+.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64"
+# Slim down the image. This saves about 15% in size with clang 6 on x86
+# Our most constrained /boot/loader env is BIOS booting on x86, where
+# our text + data + BTX have to fit into 640k below the ISA hole.
+# Experience has shown that problems arise between ~520k to ~530k.
+CFLAGS.clang+= -Oz
+CFLAGS.gcc+= -Os
+CFLAGS+= -ffunction-sections -fdata-sections
+.endif
+
+# GELI Support, with backward compat hooks (mostly)
+.if defined(LOADER_NO_GELI_SUPPORT)
+MK_LOADER_GELI=no
+.warning "Please move from LOADER_NO_GELI_SUPPORT to WITHOUT_LOADER_GELI"
+.endif
+.if defined(LOADER_GELI_SUPPORT)
+MK_LOADER_GELI=yes
+.warning "Please move from LOADER_GELI_SUPPORT to WITH_LOADER_GELI"
+.endif
+.if ${MK_LOADER_GELI} == "yes"
+CFLAGS+= -DLOADER_GELI_SUPPORT
+CFLAGS+= -I${SASRC}/geli
+.endif # MK_LOADER_GELI
+
+# These should be confined to loader.mk, but can't because uboot/lib
+# also uses it. It's part of loader, but isn't a loader so we can't
+# just include loader.mk
+.if ${LOADER_DISK_SUPPORT:Uyes} == "yes"
+CFLAGS+= -DLOADER_DISK_SUPPORT
+.endif
+.if ${LOADER_NET_SUPPORT:Uno} == "yes"
+CFLAGS+= -DLOADER_NET_SUPPORT
+.endif
+.if ${LOADER_MD_SUPPORT:Uno} == "yes"
+CFLAGS+= -DLOADER_MD_SUPPORT
+.endif
+
+# Machine specific flags for all builds here
+
+# Ensure PowerPC64 and PowerPC64LE boot loaders are compiled as 32 bit.
+# PowerPC64LE boot loaders are 32-bit little-endian.
+.if ${MACHINE_ARCH} == "powerpc64"
+CFLAGS+= -m32 -mcpu=powerpc -mbig-endian
+.elif ${MACHINE_ARCH} == "powerpc64le"
+CFLAGS+= -m32 -mcpu=powerpc -mlittle-endian
+.endif
+
+.if ${MACHINE_ARCH} == "amd64" && ${DO32:U0} == 1
+CFLAGS+= -m32
+# LD_FLAGS is passed directly to ${LD}, not via ${CC}:
+LD_FLAGS+= -m elf_i386_fbsd
+AFLAGS+= --32
+.endif
+
+# Add in the no float / no SIMD stuff and announce we're freestanding
+# aarch64 and riscv don't have -msoft-float, but all others do.
+CFLAGS+= -ffreestanding ${CFLAGS_NO_SIMD}
+.if ${MACHINE_CPUARCH} == "aarch64"
+CFLAGS+= -mgeneral-regs-only -ffixed-x18 -fPIC
+.elif ${MACHINE_CPUARCH} == "riscv"
+CFLAGS+= -march=rv64imac -mabi=lp64 -fPIC
+CFLAGS.clang+= -mcmodel=medium
+CFLAGS.gcc+= -mcmodel=medany
+.else
+CFLAGS+= -msoft-float
+.endif
+
+.if ${MACHINE_CPUARCH} == "i386" || (${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 1)
+CFLAGS+= -march=i386
+CFLAGS.gcc+= -mpreferred-stack-boundary=2
+.endif
+.if ${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 0
+CFLAGS+= -fPIC -mno-red-zone
+.endif
+
+.if ${MACHINE_CPUARCH} == "arm"
+# Do not generate movt/movw, because the relocation fixup for them does not
+# translate to the -Bsymbolic -pie format required by self_reloc() in loader(8).
+# Also, the fpu is not available in a standalone environment.
+CFLAGS.clang+= -mno-movt
+CFLAGS.clang+= -mfpu=none
+CFLAGS+= -fPIC
+.endif
+
+# Some RISC-V linkers have support for relaxations, while some (lld) do not
+# yet. If this is the case we inhibit the compiler from emitting relaxations.
+.if ${LINKER_FEATURES:Mriscv-relaxations} == ""
+CFLAGS+= -mno-relax
+.endif
+
+# ZLIB flags
+ZLIB_CFLAGS=-DHAVE_MEMCPY -I${SYSDIR}/contrib/zlib ${NO_WDEPRECATED_NON_PROTOTYPE}
+
+# BZIP2 flags
+BZIP2_CFLAGS=-I${SRCTOP}/contrib/bzip2 -DBZ_NO_STDIO -DBZ_NO_COMPRESS
+
- # ZSTD client cflags
- ZSTD_CFLAGS=-I${SYSDIR}/contrib/zstd/lib
++# ZSTD client cflags (match the OpenZFS zstd linked into libsa)
++ZSTD_CFLAGS=-I${ZFSTOP}/module/zstd/lib
+
+# XZ flags
+XZ_DIR=${SRCTOP}/sys/contrib/xz-embedded
+XZ_CFLAGS=-DXZ_USE_CRC64 -I${XZ_DIR}/freebsd -I${XZ_DIR}/linux/include/linux
+
+
+# The boot loader build uses dd status=none, where possible, for reproducible
+# build output (since performance varies from run to run). Trouble is that
+# option was recently (10.3) added to FreeBSD and is non-standard. Only use it
+# when this test succeeds rather than require dd to be a bootstrap tool.
+DD_NOSTATUS!=(dd status=none count=0 2> /dev/null && echo status=none) || true
+DD=dd ${DD_NOSTATUS}
+
+#
+# Have a sensible default
+#
+.if ${MK_LOADER_LUA} == "yes"
+LOADER_DEFAULT_INTERP?=lua
+.elif ${MK_FORTH} == "yes"
+LOADER_DEFAULT_INTERP?=4th
+.else
+LOADER_DEFAULT_INTERP?=simp
+.endif
+LOADER_INTERP?=${LOADER_DEFAULT_INTERP}
+
+# Make sure we use the machine link we're about to create
+CFLAGS+=-I.
+
+.include "${BOOTSRC}/veriexec.mk"
+
+all: ${PROG}
+
+CLEANFILES+= teken_state.h
+teken.c: teken_state.h
+
+teken_state.h: ${SYSDIR}/teken/sequences
+ awk -f ${SYSDIR}/teken/gensequences \
+ ${SYSDIR}/teken/sequences > teken_state.h
+
+.if !defined(NO_OBJ)
+_ILINKS=include/machine
+.if ${MACHINE} != ${MACHINE_CPUARCH} && ${MACHINE} != "arm64"
+_ILINKS+=include/${MACHINE_CPUARCH}
+.endif
+.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
+_ILINKS+=include/x86
+.endif
+CFLAGS+= -Iinclude
+CLEANDIRS+= include
+
+beforedepend: ${_ILINKS}
+beforebuild: ${_ILINKS}
+
+# Ensure that the links exist without depending on it when it exists which
+# causes all the modules to be rebuilt when the directory pointed to changes.
+.for _link in ${_ILINKS}
+.if !exists(${.OBJDIR}/${_link})
+${OBJS}: ${_link}
+.endif # _link exists
+.endfor
+
+.NOPATH: ${_ILINKS}
+
+${_ILINKS}: .NOMETA
+ @case ${.TARGET:T} in \
+ machine) \
+ if [ ${DO32:U0} -eq 0 ]; then \
+ path=${SYSDIR}/${MACHINE}/include ; \
+ else \
+ path=${SYSDIR}/${MACHINE:C/amd64/i386/}/include ; \
+ fi ;; \
+ *) \
+ path=${SYSDIR}/${.TARGET:T}/include ;; \
+ esac ; \
+ case ${.TARGET} in \
+ */*) mkdir -p ${.TARGET:H};; \
+ esac ; \
+ path=`(cd $$path && /bin/pwd)` ; \
+ ${ECHO} ${.TARGET} "->" $$path ; \
+ ln -fns $$path ${.TARGET}
+.endif # !NO_OBJ
+
+.-include "local.defs.mk"
+.endif # __BOOT_DEFS_MK__
diff --cc sys/conf/kern.pre.mk
index d17a25ef1636,000000000000..982ea8a31301
mode 100644,000000..100644
--- a/sys/conf/kern.pre.mk
+++ b/sys/conf/kern.pre.mk
@@@ -1,351 -1,0 +1,352 @@@
+
+# Part of a unified Makefile for building kernels. This part contains all
+# of the definitions that need to be before %BEFORE_DEPEND.
+
+# Allow user to configure things that only effect src tree builds.
+# Note: This is duplicated from src.sys.mk to ensure that we include
+# /etc/src.conf when building the kernel. Kernels can be built without
+# the rest of /usr/src, but they still always process SRCCONF even though
+# the normal mechanisms to prevent that (compiling out of tree) won't
+# work. To ensure they do work, we have to duplicate thee few lines here.
+.if exists(${SRCTOP}/src.conf)
+SRCCONF?= ${SRCTOP}/src.conf
+.else
+SRCCONF?= /etc/src.conf
+.endif
+.if (exists(${SRCCONF}) || ${SRCCONF} != "/etc/src.conf") && !target(_srcconf_included_)
+.include "${SRCCONF}"
+_srcconf_included_:
+.endif
+
+.include <bsd.own.mk>
+.include <bsd.compiler.mk>
+.include "kern.opts.mk"
+.-include <local.kern.pre.mk>
+
+# The kernel build always occurs in the object directory which is .CURDIR.
+.if ${.MAKE.MODE:Unormal:Mmeta}
+.MAKE.MODE+= curdirOk=yes
+.endif
+
+# The kernel build always expects .OBJDIR=.CURDIR.
+.OBJDIR: ${.CURDIR}
+
+.if defined(NO_OBJWALK) || ${MK_AUTO_OBJ} == "yes"
+NO_OBJWALK= t
+NO_MODULES_OBJ= t
+.endif
+.if !defined(NO_OBJWALK)
+_obj= obj
+.endif
+
+# Can be overridden by makeoptions or /etc/make.conf
+KERNEL_KO?= kernel
+KERNEL?= kernel
+KODIR?= /boot/${KERNEL}
+LDSCRIPT_NAME?= ldscript.$M
+LDSCRIPT?= $S/conf/${LDSCRIPT_NAME}
+
+M= ${MACHINE}
+
+AWK?= awk
+CP?= cp
+ELFDUMP?= elfdump
+NM?= nm
+OBJCOPY?= objcopy
+SIZE?= size
+
+.if defined(DEBUG)
+CTFFLAGS+= -g
+.endif
+.if ${MACHINE_CPUARCH} == "amd64" && ${COMPILER_TYPE} != "clang"
+_COPTFLAGS_EXTRA=-frename-registers
+.else
+_COPTFLAGS_EXTRA=
+.endif
+COPTFLAGS?=-O2 -pipe ${_COPTFLAGS_EXTRA}
+.if !empty(COPTFLAGS:M-O[23s]) && empty(COPTFLAGS:M-fno-strict-aliasing)
+COPTFLAGS+= -fno-strict-aliasing
+.endif
+.if !defined(NO_CPU_COPTFLAGS)
+COPTFLAGS+= ${_CPUCFLAGS}
+.endif
+NOSTDINC= -nostdinc
+
+INCLUDES= ${NOSTDINC} ${INCLMAGIC} -I. -I$S -I$S/contrib/ck/include
+
+CFLAGS= ${COPTFLAGS} ${DEBUG}
+CPPFLAGS= ${INCLUDES} -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h
+CFLAGS+= ${CPPFLAGS}
+CFLAGS_PARAM_INLINE_UNIT_GROWTH?=100
+CFLAGS_PARAM_LARGE_FUNCTION_GROWTH?=1000
+CFLAGS.gcc+= -finline-limit=${INLINE_LIMIT}
+CFLAGS.gcc+= --param inline-unit-growth=${CFLAGS_PARAM_INLINE_UNIT_GROWTH}
+CFLAGS.gcc+= --param large-function-growth=${CFLAGS_PARAM_LARGE_FUNCTION_GROWTH}
+.if defined(CFLAGS_ARCH_PARAMS)
+CFLAGS.gcc+=${CFLAGS_ARCH_PARAMS}
+.endif
+WERROR?= -Werror
+# The following should be removed no earlier than LLVM11 being imported into the
+# tree, to ensure we don't regress the build. LLVM11 and GCC10 will switch the
+# default over to -fno-common, making this redundant.
+CFLAGS+= -fno-common
+
+# XXX LOCORE means "don't declare C stuff" not "for locore.s".
+ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS} ${ASM_CFLAGS.${.IMPSRC:T}}
+
+COMPAT_FREEBSD32_ENABLED!= grep COMPAT_FREEBSD32 opt_global.h || true ; echo
+
+KASAN_ENABLED!= grep KASAN opt_global.h || true ; echo
+KCSAN_ENABLED!= grep KCSAN opt_global.h || true ; echo
+KMSAN_ENABLED!= grep KMSAN opt_global.h || true ; echo
+KUBSAN_ENABLED!= grep KUBSAN opt_global.h || true ; echo
+COVERAGE_ENABLED!= grep COVERAGE opt_global.h || true ; echo
+
+GCOV_ENABLED!= grep GCOV opt_global.h || true ; echo
+.if !empty(GCOV_ENABLED)
+.if ${COMPILER_TYPE} == "gcc"
+GCOV_CFLAGS+= -fprofile-arcs -ftest-coverage
+.endif
+.endif
+
+CFLAGS+= ${GCOV_CFLAGS}
+
+# Put configuration-specific C flags last so that they can override
+# the others.
+CFLAGS+= ${CONF_CFLAGS}
+
+LDFLAGS+= --build-id=sha1
+
+.if ${MACHINE_CPUARCH} == "amd64"
+LDFLAGS+= -z max-page-size=2097152
+.if ${LINKER_TYPE} != "lld"
+LDFLAGS+= -z common-page-size=4096
+.else
+.if defined(LINKER_FEATURES) && !${LINKER_FEATURES:Mifunc-noplt}
+.warning "Linker ${LD} does not support -z ifunc-noplt -> ifunc calls are unoptimized."
+.else
+LDFLAGS+= -z notext -z ifunc-noplt
+.endif
+.endif
+.endif # ${MACHINE_CPUARCH} == "amd64"
+
+.if ${MACHINE_CPUARCH} == "riscv"
+# Hack: Work around undefined weak symbols being out of range when linking with
+# LLD (address is a PC-relative calculation, and BFD works around this by
+# rewriting the instructions to generate an absolute address of 0); -fPIE
+# avoids this since it uses the GOT for all extern symbols, which is overly
+# inefficient for us. Drop once undefined weak symbols work with medany.
+.if ${LINKER_TYPE} == "lld"
+CFLAGS+= -fPIE
+.endif
+.endif
+
+NORMAL_C= ${CC} -c ${CFLAGS} ${WERROR} ${.IMPSRC}
+NORMAL_S= ${CC:N${CCACHE_BIN}} -c ${ASM_CFLAGS} ${WERROR} ${.IMPSRC}
+NORMAL_C_NOWERROR= ${CC} -c ${CFLAGS} ${.IMPSRC}
+
+NORMAL_M= ${AWK} -f $S/tools/makeobjops.awk ${.IMPSRC} -c ; \
+ ${CC} -c ${CFLAGS} ${WERROR} ${.PREFIX}.c
+
+NORMAL_FW= uudecode -o ${.TARGET} ${.ALLSRC}
+NORMAL_FWO= ${CC:N${CCACHE_BIN}} -c ${ASM_CFLAGS} ${WERROR} -o ${.TARGET} \
+ $S/kern/firmw.S -DFIRMW_FILE=\""${.ALLSRC:M*.fw}"\" \
+ -DFIRMW_SYMBOL="${.ALLSRC:M*.fw:C/[-.\/]/_/g}"
+
+# Remove sanitizer arguments. Some -fno-sanitize* and -fasan-shadow-offset*
+# arguments become an error if the appropriate sanitizer is not enabled.
+NOSAN_C= ${NORMAL_C:N-fsanitize*:N-fno-sanitize*:N-fasan-shadow-offset*}
+
+# for ZSTD in the kernel (include zstd/lib/freebsd before other CFLAGS)
+ZSTD_C= ${CC} -c -DZSTD_HEAPMODE=1 -I$S/contrib/zstd/lib/freebsd ${CFLAGS} \
+ -I$S/contrib/zstd/lib -I$S/contrib/zstd/lib/common ${WERROR} \
- -Wno-missing-prototypes -U__BMI__ -DZSTD_NO_INTRINSICS ${.IMPSRC}
++ -Wno-missing-prototypes -U__BMI__ -DZSTD_NO_INTRINSICS \
++ -DZSTD_DISABLE_ASM ${.IMPSRC}
+# https://github.com/facebook/zstd/commit/812e8f2a [zstd 1.4.1]
+# "Note that [GCC] autovectorization still does not do a good job on the
+# optimized version, so it's turned off via attribute and flag. I found
+# that neither attribute nor command-line flag were entirely successful in
+# turning off vectorization, which is why there were both."
+.if ${COMPILER_TYPE} == "gcc"
+ZSTD_DECOMPRESS_BLOCK_FLAGS= -fno-tree-vectorize
+.endif
+
+ZINCDIR=$S/contrib/openzfs/include
+# Common for dtrace / zfs
+CDDL_CFLAGS= \
+ -DFREEBSD_NAMECACHE \
+ -D_SYS_VMEM_H_ \
+ -D__KERNEL \
+ -D__KERNEL__ \
+ -nostdinc \
+ -include $S/modules/zfs/static_ccompile.h \
+ -I${ZINCDIR} \
+ -I${ZINCDIR}/os/freebsd \
+ -I${ZINCDIR}/os/freebsd/spl \
+ -I${ZINCDIR}/os/freebsd/zfs \
+ -I$S/modules/zfs \
+ -I$S/contrib/openzfs/module/zstd/include \
+ ${CFLAGS} \
+ -Wno-cast-qual \
+ -Wno-duplicate-decl-specifier \
+ -Wno-missing-braces \
+ -Wno-missing-prototypes \
+ -Wno-parentheses \
+ -Wno-pointer-arith \
+ -Wno-strict-prototypes \
+ -Wno-switch \
+ -Wno-undef \
+ -Wno-uninitialized \
+ -Wno-unknown-pragmas \
+ -Wno-unused \
+ -include ${ZINCDIR}/os/freebsd/spl/sys/ccompile.h \
+ -I$S/cddl/contrib/opensolaris/uts/common \
+ -I$S -I$S/cddl/compat/opensolaris
+CDDL_C= ${CC} -c ${CDDL_CFLAGS} ${WERROR} ${.IMPSRC}
+
+# Special flags for managing the compat compiles for ZFS
+ZFS_CFLAGS+= -I$S/contrib/openzfs/module/icp/include \
+ -include $S/contrib/openzfs/include/sys/simd_config.h \
+ ${CDDL_CFLAGS} -DBUILDING_ZFS -DHAVE_UIO_ZEROCOPY \
+ -DWITH_NETDUMP -D__KERNEL__ -D_SYS_CONDVAR_H_ -DSMP
+
+.if ${MACHINE_ARCH} == "amd64"
+ZFS_CFLAGS+= -D__x86_64 -DHAVE_TOOLCHAIN_SSE2 -DHAVE_TOOLCHAIN_SSSE3 \
+ -DHAVE_TOOLCHAIN_SSE4_1 -DHAVE_TOOLCHAIN_AVX -DHAVE_TOOLCHAIN_AVX2 \
+ -DHAVE_TOOLCHAIN_AVX512F -DHAVE_TOOLCHAIN_AVX512VL \
+ -DHAVE_TOOLCHAIN_AVX512BW \
+ -DHAVE_TOOLCHAIN_VAES -DHAVE_TOOLCHAIN_VPCLMULQDQ
+.endif
+
+.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "powerpc" || \
+ ${MACHINE_ARCH} == "arm"
+ZFS_CFLAGS+= -DBITS_PER_LONG=32
+.else
+ZFS_CFLAGS+= -DBITS_PER_LONG=64
+.endif
+
+
+ZFS_ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${ZFS_CFLAGS}
+ZFS_C= ${CC} -c ${ZFS_CFLAGS} ${WERROR} ${.IMPSRC}
+ZFS_RPC_C= ${CC} -c ${ZFS_CFLAGS} -DHAVE_RPC_TYPES ${WERROR} ${.IMPSRC}
+ZFS_S= ${CC} -c ${ZFS_ASM_CFLAGS} ${WERROR} ${.IMPSRC}
+
+# ATH driver
+ATH_CFLAGS= -I${SRCTOP}/sys/dev/ath ${NO_WUNUSED_BUT_SET_VARIABLE}
+ATH_C= ${CC} -c ${CFLAGS} ${WERROR} ${ATH_CFLAGS} ${.IMPSRC}
+
+# Special flags for managing the compat compiles for DTrace
+DTRACE_CFLAGS= -DBUILDING_DTRACE ${CDDL_CFLAGS} -I$S/cddl/dev/dtrace -I$S/cddl/dev/dtrace/${MACHINE_CPUARCH}
+.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
+DTRACE_CFLAGS+= -I$S/cddl/contrib/opensolaris/uts/intel -I$S/cddl/dev/dtrace/x86
+.endif
+DTRACE_CFLAGS+= -I$S/cddl/contrib/opensolaris/common/util -I$S -DDIS_MEM -DSMP -I$S/cddl/compat/opensolaris
+DTRACE_CFLAGS+= -I$S/cddl/contrib/opensolaris/uts/common
+DTRACE_ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${DTRACE_CFLAGS}
+DTRACE_C= ${CC} -c ${DTRACE_CFLAGS} ${WERROR} ${.IMPSRC}
+DTRACE_S= ${CC} -c ${DTRACE_ASM_CFLAGS} ${WERROR} ${.IMPSRC}
+
+# zlib code supports systems that are quite old, but will fix this issue once C2x gets radified.
+# see https://github.com/madler/zlib/issues/633 for details
+ZLIB_CFLAGS= -Wno-cast-qual ${NO_WDEPRECATED_NON_PROTOTYPE} ${NO_WSTRICT_PROTOTYPES}
+ZLIB_C= ${CC} -c ${CFLAGS} ${WERROR} ${ZLIB_CFLAGS} ${.IMPSRC}
+
+# Special flags for managing the compat compiles for DTrace/FBT
+FBT_CFLAGS= -DBUILDING_DTRACE -nostdinc -I$S/cddl/dev/fbt/${MACHINE_CPUARCH} -I$S/cddl/dev/fbt ${CDDL_CFLAGS} -I$S/cddl/compat/opensolaris -I$S/cddl/contrib/opensolaris/uts/common
+.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
+FBT_CFLAGS+= -I$S/cddl/dev/fbt/x86
+.endif
+FBT_C= ${CC} -c ${FBT_CFLAGS} ${WERROR} ${.IMPSRC}
+
+.if ${MK_CTF} != "no"
+NORMAL_CTFCONVERT= ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
+.elif ${MAKE_VERSION} >= 5201111300
+NORMAL_CTFCONVERT=
+.else
+NORMAL_CTFCONVERT= @:
+.endif
+
+# Linux Kernel Programming Interface C-flags
+LINUXKPI_INCLUDES= -I$S/compat/linuxkpi/common/include \
+ -I$S/compat/linuxkpi/dummy/include \
+ -include $S/compat/linuxkpi/common/include/linux/kconfig.h
+LINUXKPI_C= ${NORMAL_C} ${LINUXKPI_INCLUDES}
+
+# Infiniband C flags. Correct include paths and omit errors that linux
+# does not honor.
+OFEDINCLUDES= -I$S/ofed/include -I$S/ofed/include/uapi ${LINUXKPI_INCLUDES}
+OFEDNOERR= -Wno-cast-qual -Wno-pointer-arith ${NO_WUNUSED_BUT_SET_VARIABLE}
+OFEDCFLAGS= ${CFLAGS:N-I*} -DCONFIG_INFINIBAND_USER_MEM \
+ ${OFEDINCLUDES} ${CFLAGS:M-I*} ${OFEDNOERR}
+OFED_C_NOIMP= ${CC} -c -o ${.TARGET} ${OFEDCFLAGS} ${WERROR}
+OFED_C= ${OFED_C_NOIMP} ${.IMPSRC}
+
+# mlxfw C flags.
+MLXFW_C= ${OFED_C_NOIMP} \
+ -I${SRCTOP}/sys/contrib/xz-embedded/freebsd \
+ -I${SRCTOP}/sys/contrib/xz-embedded/linux/lib/xz \
+ ${.IMPSRC}
+# BNXT Driver
+BNXT_CFLAGS= -I$S/dev/bnxt/bnxt_en ${OFEDCFLAGS}
+BNXT_C_NOIMP= ${CC} -c -o ${.TARGET} ${BNXT_CFLAGS} ${WERROR}
+BNXT_C= ${BNXT_C_NOIMP} ${.IMPSRC}
+
+# IP Filter
+IPFILTER_CFLAGS= -I$S/netpfil/ipfilter
+IPFILTER_C= ${NORMAL_C} ${IPFILTER_CFLAGS}
+
+GEN_CFILES= $S/$M/$M/genassym.c ${MFILES:T:S/.m$/.c/}
+SYSTEM_CFILES= config.c env.c hints.c vnode_if.c
+SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
+SYSTEM_OBJS= locore.o ${MDOBJS} ${OBJS}
+SYSTEM_OBJS+= ${SYSTEM_CFILES:.c=.o}
+SYSTEM_OBJS+= force-dynamic-hack.pico
+
+KEYMAP=kbdcontrol -P ${SRCTOP}/share/vt/keymaps -P ${SRCTOP}/share/syscons/keymaps
+KEYMAP_FIX=sed -e 's/^static keymap_t.* = /static keymap_t key_map = /' -e 's/^static accentmap_t.* = /static accentmap_t accent_map = /'
+
+MD_ROOT_SIZE_CONFIGURED!= grep MD_ROOT_SIZE opt_md.h || true ; echo
+.if ${MFS_IMAGE:Uno} != "no"
+.if empty(MD_ROOT_SIZE_CONFIGURED)
+SYSTEM_OBJS+= embedfs_${MFS_IMAGE:T:R}.o
+.endif
+.endif
+SYSTEM_LD_BASECMD= \
+ ${LD} -m ${LD_EMULATION} -Bdynamic -L $S/conf -T ${LDSCRIPT} ${_LDFLAGS} \
+ --no-warn-mismatch --warn-common --export-dynamic \
+ --dynamic-linker /red/herring -X
+SYSTEM_LD= @${SYSTEM_LD_BASECMD} -o ${.TARGET} ${SYSTEM_OBJS} vers.o
+SYSTEM_LD_TAIL= @${SIZE} ${.TARGET} ; chmod 755 ${.TARGET}
+SYSTEM_DEP+= ${LDSCRIPT}
+
+# Calculate path for .m files early, if needed.
+.if !defined(NO_MODULES) && !defined(__MPATH) && !make(install) && \
+ (empty(.MAKEFLAGS:M-V) || defined(NO_SKIP_MPATH))
+__MPATH!=find ${S:tA}/ -name \*_if.m
+.endif
+
+# MKMODULESENV is set here so that port makefiles can augment
+# them.
+
+MKMODULESENV+= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
+MKMODULESENV+= MACHINE_CPUARCH=${MACHINE_CPUARCH}
+MKMODULESENV+= MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH}
+MKMODULESENV+= MODULES_EXTRA="${MODULES_EXTRA}" WITHOUT_MODULES="${WITHOUT_MODULES}"
+MKMODULESENV+= ARCH_FLAGS="${ARCH_FLAGS}"
+.if (${KERN_IDENT} == LINT)
+MKMODULESENV+= ALL_MODULES=LINT
+.endif
+.if defined(MODULES_OVERRIDE)
+MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}"
+.endif
+.if defined(DEBUG)
+MKMODULESENV+= DEBUG_FLAGS="${DEBUG}"
+.endif
+.if !defined(NO_MODULES)
+MKMODULESENV+= __MPATH="${__MPATH}"
+.endif
+
+# Detect kernel config options that force stack frames to be turned on.
+DDB_ENABLED!= grep DDB opt_ddb.h || true ; echo
+DTRACE_ENABLED!=grep KDTRACE_FRAME opt_kdtrace.h || true ; echo
+HWPMC_ENABLED!= grep HWPMC opt_hwpmc_hooks.h || true ; echo
diff --cc sys/contrib/zstd/FREEBSD-Xlist
index 7d87acac5f4a,000000000000..9e17d8e68051
mode 100644,000000..100644
--- a/sys/contrib/zstd/FREEBSD-Xlist
+++ b/sys/contrib/zstd/FREEBSD-Xlist
@@@ -1,19 -1,0 +1,21 @@@
+*/BUCK
+.buckconfig
+.buckversion
+.cirrus.yml
+.github
+.gitignore
+.travis.yml
++CMakeLists.txt
+CODE_OF_CONDUCT.md
+CONTRIBUTING.md
+Makefile
+Package.swift
+TESTING.md
+build
+contrib
+doc
+examples
+lib/dll
++lib/install_oses.mk
+programs/windres
+tests
diff --cc sys/contrib/zstd/FREEBSD-upgrade
index e00f5e4520ad,000000000000..63691fefed37
mode 100644,000000..100644
--- a/sys/contrib/zstd/FREEBSD-upgrade
+++ b/sys/contrib/zstd/FREEBSD-upgrade
@@@ -1,12 -1,0 +1,12 @@@
+zstd
+
+To import new vendor sources, prune unwanted files with:
+
+ tar -X FREEBSD-Xlist -xf zstd-x.y.z.tar.zst
+
+When importing a new version, be sure to check if there are any new bits that
+we don't want.
+
- Please find instructions for importing new releases and merging to HEAD here:
++Please find instructions for importing new releases and merging to main here:
+
+https://docs.freebsd.org/en/articles/committers-guide/#vendor-import-git
diff --cc sys/contrib/zstd/README.md
index d91ef5df1b26,000000000000..3aa01a0c1d1f
mode 100644,000000..100644
--- a/sys/contrib/zstd/README.md
+++ b/sys/contrib/zstd/README.md
@@@ -1,237 -1,0 +1,244 @@@
+<p align="center"><img src="https://raw.githubusercontent.com/facebook/zstd/dev/doc/images/zstd_logo86.png" alt="Zstandard"></p>
+
+__Zstandard__, or `zstd` as short version, is a fast lossless compression algorithm,
+targeting real-time compression scenarios at zlib-level and better compression ratios.
+It's backed by a very fast entropy stage, provided by [Huff0 and FSE library](https://github.com/Cyan4973/FiniteStateEntropy).
+
+Zstandard's format is stable and documented in [RFC8878](https://datatracker.ietf.org/doc/html/rfc8878). Multiple independent implementations are already available.
+This repository represents the reference implementation, provided as an open-source dual [BSD](LICENSE) OR [GPLv2](COPYING) licensed **C** library,
+and a command line utility producing and decoding `.zst`, `.gz`, `.xz` and `.lz4` files.
+Should your project require another programming language,
+a list of known ports and bindings is provided on [Zstandard homepage](https://facebook.github.io/zstd/#other-languages).
+
+**Development branch status:**
+
+[![Build Status][travisDevBadge]][travisLink]
+[![Build status][CircleDevBadge]][CircleLink]
+[![Build status][CirrusDevBadge]][CirrusLink]
+[![Fuzzing Status][OSSFuzzBadge]][OSSFuzzLink]
+
+[travisDevBadge]: https://api.travis-ci.com/facebook/zstd.svg?branch=dev "Continuous Integration test suite"
+[travisLink]: https://travis-ci.com/facebook/zstd
+[CircleDevBadge]: https://circleci.com/gh/facebook/zstd/tree/dev.svg?style=shield "Short test suite"
+[CircleLink]: https://circleci.com/gh/facebook/zstd
+[CirrusDevBadge]: https://api.cirrus-ci.com/github/facebook/zstd.svg?branch=dev
+[CirrusLink]: https://cirrus-ci.com/github/facebook/zstd
+[OSSFuzzBadge]: https://oss-fuzz-build-logs.storage.googleapis.com/badges/zstd.svg
+[OSSFuzzLink]: https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:zstd
+
+## Benchmarks
+
+For reference, several fast compression algorithms were tested and compared
+on a desktop featuring a Core i7-9700K CPU @ 4.9GHz
- and running Ubuntu 20.04 (`Linux ubu20 5.15.0-101-generic`),
++and running Ubuntu 24.04 (`Linux 6.8.0-53-generic`),
+using [lzbench], an open-source in-memory benchmark by @inikep
- compiled with [gcc] 9.4.0,
++compiled with [gcc] 14.2.0,
+on the [Silesia compression corpus].
+
+[lzbench]: https://github.com/inikep/lzbench
+[Silesia compression corpus]: https://sun.aei.polsl.pl//~sdeor/index.php?page=silesia
+[gcc]: https://gcc.gnu.org/
+
+| Compressor name | Ratio | Compression| Decompress.|
+| --------------- | ------| -----------| ---------- |
- | **zstd 1.5.6 -1** | 2.887 | 510 MB/s | 1580 MB/s |
- | [zlib] 1.2.11 -1 | 2.743 | 95 MB/s | 400 MB/s |
- | brotli 1.0.9 -0 | 2.702 | 395 MB/s | 430 MB/s |
- | **zstd 1.5.6 --fast=1** | 2.437 | 545 MB/s | 1890 MB/s |
- | **zstd 1.5.6 --fast=3** | 2.239 | 650 MB/s | 2000 MB/s |
- | quicklz 1.5.0 -1 | 2.238 | 525 MB/s | 750 MB/s |
- | lzo1x 2.10 -1 | 2.106 | 650 MB/s | 825 MB/s |
- | [lz4] 1.9.4 | 2.101 | 700 MB/s | 4000 MB/s |
- | lzf 3.6 -1 | 2.077 | 420 MB/s | 830 MB/s |
- | snappy 1.1.9 | 2.073 | 530 MB/s | 1660 MB/s |
++| **zstd 1.5.7 -1** | 2.896 | 510 MB/s | 1550 MB/s |
++| brotli 1.1.0 -1 | 2.883 | 290 MB/s | 425 MB/s |
++| [zlib] 1.3.1 -1 | 2.743 | 105 MB/s | 390 MB/s |
++| **zstd 1.5.7 --fast=1** | 2.439 | 545 MB/s | 1850 MB/s |
++| quicklz 1.5.0 -1 | 2.238 | 520 MB/s | 750 MB/s |
++| **zstd 1.5.7 --fast=4** | 2.146 | 665 MB/s | 2050 MB/s |
++| lzo1x 2.10 -1 | 2.106 | 650 MB/s | 780 MB/s |
++| [lz4] 1.10.0 | 2.101 | 675 MB/s | 3850 MB/s |
++| snappy 1.2.1 | 2.089 | 520 MB/s | 1500 MB/s |
++| lzf 3.6 -1 | 2.077 | 410 MB/s | 820 MB/s |
+
+[zlib]: https://www.zlib.net/
+[lz4]: https://lz4.github.io/lz4/
+
+The negative compression levels, specified with `--fast=#`,
+offer faster compression and decompression speed
+at the cost of compression ratio.
+
+Zstd can also offer stronger compression ratios at the cost of compression speed.
+Speed vs Compression trade-off is configurable by small increments.
+Decompression speed is preserved and remains 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
+---------------------------|--------------------
+ | 
+
+A few other algorithms can produce higher compression ratios at slower speeds, falling outside of the graph.
+For a larger picture including slow modes, [click on this link](doc/images/DCspeed5.png).
+
+
+## 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.
*** 226 LINES SKIPPED ***