Zstandard v1.5.5 Release Note
This is a quick fix release. The primary focus is to correct a rare corruption bug in high compression mode, detected by @danlark1 . The probability to generate such a scenario by random chance is extremely low. It evaded months of continuous fuzzer tests, due to the nb and complexity of simultaneous conditions required to trigger it. Nevertheless, @danlark1 from Google shepherds such a humongous amount of data that he managed to detect a reproduction case (corruptions are detected thanks to the checksum), making it possible for @terrelln to investigate and fix the bug. Thanks !
While the probability might be very small, corruption issues are nonetheless very serious, so an update to this version is highly recommended, especially if you employ high compression modes (levels 16+).
When the issue was detected, there were a number of other improvements and minor fixes already in the making, hence they are also present in this release. Let’s detail the main ones.
Improved memory usage and speed for the --patch-from
mode
V1.5.5
introduces memory-mapped dictionaries, by @daniellerozenblit, for both posix #3486 and windows #3557.
This feature allows zstd
to memory-map large dictionaries, rather than requiring to load them into memory. This can make a pretty big difference for memory-constrained environments operating patches for large data sets.
It's mostly visible under memory pressure, since mmap
will be able to release less-used memory and continue working.
But even when memory is plentiful, there are still measurable memory benefits, as shown in the graph below, especially when the reference turns out to be not completely relevant for the patch.
This feature is automatically enabled for --patch-from
compression/decompression when the dictionary is larger than the user-set memory limit. It can also be manually enabled/disabled using --mmap-dict
or --no-mmap-dict
respectively.
Additionally, @daniellerozenblit introduces significant speed improvements for --patch-from
.
An I/O
optimization in #3486 greatly improves --patch-from
decompression speed on Linux, typically by +50%
on large files (~1GB).
Compression speed is also taken care of, with a dictionary-indexing speed optimization introduced in #3545. It wildly accelerates --patch-from
compression, typically doubling speed on large files (~1GB), sometimes even more depending on exact scenario.
This speed improvement comes at a slight regression in compression ratio, and is therefore not enabled for very high compression strategies (such as >= ZSTD_btultra
), in order to preserve their higher compression ratios.
Speed improvements of middle-level compression for specific scenarios
The row-hash match finder introduced in version 1.5.0 for levels 5-12 has been improved in version 1.5.5, enhancing its speed in specific corner-case scenarios.
The first optimization (#3426) accelerates streaming compression using ZSTD_compressStream
on small inputs by removing an expensive table initialization step. This results in remarkable speed increases for very small inputs.
The following scenario measures compression speed of ZSTD_compressStream
at level 9 for different sample sizes on a linux platform running an i7-9700k cpu.
sample size | v1.5.4 (MB/s)
| v1.5.5 (MB/s)
| improvement |
---|---|---|---|
100 | 1.4 | 44.8 | x32 |
200 | 2.8 | 44.9 | x16 |
500 | 6.5 | 60.0 | x9.2 |
1K | 12.4 | 70.0 | x5.6 |
2K | 25.0 | 111.3 | x4.4 |
4K | 44.4 | 139.4 | x3.2 |
... | ... | ... | |
1M | 97.5 | 99.4 | +2% |
The second optimization (#3552) speeds up compression of incompressible data by a large multiplier. This is achieved by increasing the step size and reducing the frequency of matching when no matches are found, with negligible impact on the compression ratio. It makes mid-level compression essentially inexpensive when processing incompressible data, typically, already compressed data (note: this was already the case for fast compression levels).
The following scenario measures compression speed of ZSTD_compress
compiled with gcc-9
for a ~10MB incompressible sample on a linux platform running an i7-9700k cpu.
level | v1.5.4 (MB/s)
| v1.5.5 (MB/s)
| improvement |
---|---|---|---|
3 | 3500 | 3500 | not a row-hash level (control) |
5 | 400 | 2500 | x6.2 |
7 | 380 | 2200 | x5.8 |
9 | 176 | 1880 | x10 |
11 | 67 | 1130 | x16 |
13 | 89 | 89 | not a row-hash level (control) |
Miscellaneous
There are other welcome speed improvements in this package.
For example, @felixhandte managed to increase processing speed of small files by carefully reducing the nb of system calls (#3479). This can easily translate into +10% speed when processing a lot of small files in batch.
The Seekable format received a bit of care. It's now much faster when splitting data into very small blocks (#3544). In an extreme scenario reported by @P-E-Meunier, it improves processing speed by x90. Even for more "common" settings, such as using 4KB blocks on some "normally" compressible data like enwik
, it still provides a healthy x2 processing speed benefit. Moreover, @dloidolt merged an optimization that reduces the nb of I/O
seek()
events during reads (decompression), which is also beneficial for speed.
The release is not limited to speed improvements, several loose ends and corner cases were also fixed in this release. Though, for a more detailed list of changes, I will invite you to take a look at the changelog.
Change Log
- fix: fix rare corruption bug affecting the high compression mode, reported by @danlark1 (#3517, @terrelln)
- perf: improve mid-level compression speed (#3529, #3533, #3543, @yoniko and #3552, @terrelln)
- lib: deprecated bufferless block-level API (#3534) by @terrelln
- cli: mmap large dictionaries to save memory, by @daniellerozenblit
- cli: improve speed of --patch-from mode (~+50%) (#3545) by @daniellerozenblit
- cli: improve i/o speed (~+10%) when processing lots of small files (#3479) by @felixhandte
- cli: zstd no longer crashes when requested to write into write-protected directory (#3541) by @felixhandte
- cli: fix decompression into block device using -o (#3584, @Cyan4973) reported by @georgmu
- build: fix zstd CLI compiled with lzma support but not zlib support (#3494) by @Hello71
- build: fix cmake does no longer require 3.18 as minimum version (#3510) by @kou
- build: fix MSVC+ClangCL linking issue (#3569) by @tru
- build: fix zstd-dll, version of zstd CLI that links to the dynamic library (#3496) by @yoniko
- build: fix MSVC warnings (#3495) by @embg
- doc: updated zstd specification to clarify corner cases, by @Cyan4973
- doc: document how to create fat binaries for macos (#3568) by @rickmark
- misc: improve seekable format ingestion speed (~+100%) for very small chunk sizes (#3544) by @Cyan4973
- misc: tests/fullbench can benchmark multiple files (#3516) by @dloidolt
Full change list (auto-generated)
- Fix all MSVC warnings by @embg in #3495
- Fix zstd-dll build missing dependencies by @yoniko in #3496
- Bump github/codeql-action from 2.2.1 to 2.2.4 by @dependabot in #3503
- Github Action to generate Win64 artifacts by @Cyan4973 in #3491
- Use correct types in LZMA comp/decomp by @Hello71 in #3497
- Make Github workflows permissions read-only by default by @yoniko in #3488
- CI Workflow for external compressors dependencies by @yoniko in #3505
- Fix cli-tests issues by @daniellerozenblit in #3509
- Fix Permissions on Publish Release Artifacts Job by @felixhandte in #3511
- Use
f
-variants ofchmod()
andchown()
by @felixhandte in #3479 - Don't require CMake 3.18 or later by @kou in #3510
- meson: always build the zstd binary when tests are enabled by @eli-schwartz in #3490
- [bug-fix] Fix rare corruption bug affecting the block splitter by @terrelln in #3517
- Clarify zstd specification for Huffman blocks by @Cyan4973 in #3514
- Fix typos found by codespell by @DimitriPapadopoulos in #3513
- Bump github/codeql-action from 2.2.4 to 2.2.5 by @dependabot in #3518
- fullbench with two files by @dloidolt in #3516
- Add initialization of clevel to static cdict (#3525) by @yoniko in #3527
- [linux-kernel] Fix assert definition by @terrelln in #3532
- Add ZSTD_set{C,F,}Params() helper functions by @terrelln in #3530
- Clarify dstCapacity requirements by @terrelln in #3531
- Mmap large dictionaries in patch-from mode by @daniellerozenblit in #3486
- added clarifications for sizes of compressed huffman blocks and streams. by @Cyan4973 in #3538
- Simplify benchmark unit invocation API from CLI by @Cyan4973 in #3526
- Avoid Segfault Caused by Calling
setvbuf()
on Null File Pointer by @felixhandte in #3541 - Pin Moar Action Dependencies by @felixhandte in #3542
- Improved seekable format ingestion speed for small frame size by @Cyan4973 in #3544
- Reduce RowHash's tag space size by x2 by @yoniko in #3543
- [Bugfix] row hash tries to match position 0 by @yoniko in #3548
- Bump github/codeql-action from 2.2.5 to 2.2.6 by @dependabot in #3549
- Add init once memory (#3528) by @yoniko in #3529
- Introduce salt into row hash (#3528 part 2) by @yoniko in #3533
- added documentation for the seekable format by @Cyan4973 in #3547
- patch-from speed optimization by @daniellerozenblit in #3545
- Deprecated bufferless and block level APIs by @terrelln in #3534
- added documentation for LDM + dictionary compatibility by @Cyan4973 in #3553
- Fix a bug in the CLI tests newline processing, then simplify it further by @ppentchev in #3559
- [lazy] Skip over incompressible data by @terrelln in #3552
- Fix patch-from speed optimization by @daniellerozenblit in #3556
- Bump actions/checkout from 3.3.0 to 3.5.0 by @dependabot in #3572
- [easy] minor doc update for --rsyncable by @Cyan4973 in #3570
- [contrib/pzstd] Select
-std=c++11
When Default is Older by @felixhandte in #3574 - Add instructions for building Universal2 on macOS via CMake by @rickmark in #3568
- Provide an interface for fuzzing sequence producer plugins by @embg in #3551
- mmap for windows by @daniellerozenblit in #3557
- Bump github/codeql-action from 2.2.6 to 2.2.8 by @dependabot in #3573
- Disable linker flag detection on MSVC/ClangCL. by @tru in #3569
- Couple tweaks to improve decompression speed with clang PGO compilation by @zhuhan0 in #3576
- Increase tests timeout by @dvoropaev in #3540
- added a Clang-CL Windows test to CI by @Cyan4973 in #3579
- Seekable format read optimization by @Cyan4973 in #3581
- Check that
dest
is valid for decompression by @daniellerozenblit in #3555 - fix decompression with -o writing into a block device by @Cyan4973 in #3584
- updated version number to v1.5.5 by @Cyan4973 in #3577
New Contributors
- @kou made their first contribution in #3510
- @dloidolt made their first contribution in #3516
- @ppentchev made their first contribution in #3559
- @rickmark made their first contribution in #3568
- @dvoropaev made their first contribution in #3540
Full Changelog: v1.5.4...v1.5.5