Commit Graph
10181 Commits
Author SHA1 Message Date
Nick Terrell 3ff79dbe94 [huf] Improve fast huffman decoding speed in linux kernel
gcc in the linux kernel was not unrolling the inner loops of the Huffman
decoder, which was destroying decoding performance. The compiler was
generating crazy code with all sorts of branches. I suspect because of
Spectre mitigations, but I'm not certain. Once the loops were manually
unrolled, performance was restored.

Additionally, when gcc couldn't prove that the variable left shift in
the 4X2 decode loop wasn't greater than 63, it inserted checks to verify
it. To fix this, mask `entry.nbBits & 0x3F`, which allows gcc to eliete
this check. This is a no op, because `entry.nbBits` is guaranteed to be
less than 64.

Lastly, introduce the `HUF_DISABLE_FAST_DECODE` macro to disable the
fast C loops for Issue #3762. So if even after this change, there is a
performance regression, users can opt-out at compile time.
v1.5.5-kernel
2023-11-20 12:30:47 -08:00
Nick Terrell 58b3ef79eb [linux] Remove usage of deprecated function
ZSTD_resetDStream() is deprecated and replaced by ZSTD_DCtx_reset().
This removes deprecation warnings from the kernel build.

This change is a no-op, see the docs suggesting this replacement.

https://github.com/facebook/zstd/blob/fcbf2fde9ac7ce1562c7b3a394350e764bcb580f/lib/zstd.h#L2655-L2663
2023-11-16 17:08:19 -08:00
Nick Terrell ca498343dd [linux] Backport fix for arry-index-out-of-bounds UBSAN warning
Backport the fix already in the kernel, and is fixed in the dev branch
in a different way.

https://lkml.kernel.org/r/20231012213428.1390905-1-nickrterrell@gmail.com
2023-11-16 12:02:07 -08:00
Nick Terrell 136a16dd8b [linux] Backport intptr_t removal
Linux started providing intptr_t in <linux/types.h> so we no longer need
to define it here.

https://lkml.kernel.org/r/ed66b9e4-1fb7-45be-9bb9-d4bc291c691f@p183
2023-11-16 12:00:11 -08:00
Yann ColletandGitHub 63779c7982 Merge pull request #3595 from facebook/dev
v1.5.5 last changes
v1.5.5
2023-04-04 13:13:52 -07:00
Yann ColletandGitHub d4871d5e6e Merge pull request #3593 from facebook/appvbadge
removed Appveyor Badge
2023-04-03 18:25:06 -07:00
Yann ColletandGitHub 838f96a955 Merge pull request #3592 from facebook/overRead_magicless
fix potential over-reads
2023-04-03 17:46:37 -07:00
Yann Collet 8eef3370a3 removed Appveyor Badge
as we don't use Appveyor CI anymore.
2023-04-03 17:40:39 -07:00
Yann Collet e4120c5513 fixing potential over-reads
detected by @terrelln,
these issue could be triggered in specific scenarios
namely decompression of certain invalid magic-less frames,
or requested properties from certain invalid skippable frames.
2023-04-03 16:52:32 -07:00
Yann ColletandGitHub d507e02940 Merge pull request #3590 from facebook/dev
v1.5.5
2023-04-03 14:38:22 -07:00
Felix HandteandGitHub 2b71b79f98 Merge pull request #3591 from felixhandte/win-rel-artifact-name
Rename/Restructure Windows Release Artifact
2023-04-03 13:46:17 -07:00
W. Felix Handte fcaa422897 Rename/Restructure Windows Release Artifact
https://github.com/facebook/zstd/releases/tag/v1.5.0 describes the structure
we want to adhere to. This commit tries to accomplish that automatically, so
we can avoid manual fixups on future releases.
2023-04-03 15:35:57 -04:00
Yann ColletandGitHub 130c2640d0 Merge pull request #3589 from facebook/fix3583
fix #3583
2023-04-03 10:58:49 -07:00
Yann Collet 2e29728797 fix #3583
As reported by @georgmu,
the previous fix is undone by the later initialization.
Switch order, so that initialization is adjusted by special case.
2023-04-03 09:45:11 -07:00
Yann ColletandGitHub 73e19c4cf1 Merge pull request #3585 from facebook/dev
Preparation for release v1.5.5
2023-04-01 18:06:35 -07:00
Yann ColletandYann Collet 9b4833df2d updated changelog
in preparation for v1.5.5
2023-03-31 23:02:08 -07:00
Yann ColletandYann Collet 9f58241dcc updated version number to v1.5.5
also : updated man pages
2023-03-31 23:02:08 -07:00
Yann ColletandGitHub c45eddfa40 Merge pull request #3584 from facebook/fix_o_blockdev
fix decompression with -o writing into a block device
2023-03-31 23:01:50 -07:00
daniellerozenblitandGitHub fcaf06ddb4 Check that dest is valid for decompression (#3555)
* add check for valid dest buffer and fuzz on random dest ptr when malloc 0

* add uptrval to linux-kernel

* remove bin files

* get rid of uptrval

* restrict max pointer value check to platforms where sizeof(size_t) == sizeof(void*)
2023-03-31 23:00:55 -07:00
Yann Collet 14d0cd5d69 do not add invocation of UTIL_isRegularFile() 2023-03-31 13:09:52 -07:00
Yann ColletandGitHub 7b828aaeb5 Merge pull request #3581 from facebook/seekable_readOpt
Seekable format read optimization
2023-03-31 12:26:16 -07:00
Yann ColletandGitHub f33a4068b1 Merge pull request #3579 from facebook/clangclwintest
added a Clang-CL Windows test to CI
2023-03-31 12:26:01 -07:00
Yann ColletandGitHub c1024af3e3 Merge pull request #3540 from dvoropaev/tests_timeout
Increase tests timeout
2023-03-31 12:25:38 -07:00
Yann ColletandGitHub bb7fbd56a6 Merge pull request #3576 from zhuhan0/dev
Couple tweaks to improve decompression speed with clang PGO compilation
2023-03-31 12:25:13 -07:00
Yann Collet 5bf1359e3b fix decompression with -o writing into a block device
decompression features automatic support of sparse files,
aka a form of "compression" where entire blocks consists only of zeroes.
This only works for some compatible file systems (like ext4),
others simply ignore it (like afs).

Triggering this feature relies of `fseek()`.
But `fseek()` is not compatible with non-seekable devices, such as pipes.
Therefore it's disabled for pipes.

However, there are other objects which are not compatible with `fseek()`, such as block devices.

Changed the logic, so that `fseek()` (and therefore sparse write) is only automatically enabled on regular files.

Note that this automatic behavior can always be overridden by explicit commands `--sparse` and `--no-sparse`.

fix #3583
2023-03-31 11:29:16 -07:00
Yoni GiladandYann Collet 649a9c85c3 seekable_format: Add unit test for multiple decompress calls
This does the following:
1. Compress test data into multiple frames
2. Perform a series of small decompressions and seeks forward, checking
   that compressed data wasn't reread unnecessarily.
3. Perform some seeks forward and backward to ensure correctness.
2023-03-29 21:35:52 -07:00
Yoni GiladandYann Collet 618bf84e0d seekable_format: Prevent rereading frame when seeking forward
When decompressing a seekable file, if seeking forward within
a frame (by issuing multiple ZSTD_seekable_decompress calls
with a small gap between them), the frame will be unnecessarily
reread from the beginning. This patch makes it continue using
the current frame data and simply skip over the unneeded bytes.
2023-03-29 21:24:12 -07:00
Yann Collet 0f77956bcc added a Clang-CL Windows test to CI
If I understand correctly,
this should trigger the issue notified in #3569.
2023-03-28 22:06:18 -07:00
Yann ColletandGitHub 871f3a4026 Merge pull request #3569 from tru/linker_flag_fix
Disable linker flag detection on MSVC/ClangCL.
2023-03-28 22:05:07 -07:00
Yann ColletandGitHub 262e553b23 Merge pull request #3573 from facebook/dependabot/github_actions/github/codeql-action-2.2.8
Bump github/codeql-action from 2.2.6 to 2.2.8
2023-03-28 16:59:41 -07:00
daniellerozenblitandGitHub b2ad17a658 mmap for windows (#3557)
* mmap for windows

* remove enabling mmap for testing

* rename FIO dictionary initialization methods + un-const dictionary objects in free functions

* remove enabling mmap for testing

* initDict returns void, underlying setDictBuffer methods return the size of the set buffer

* fix comment
2023-03-28 19:44:53 -04:00
Han Zhu b558190ac7 Remove clang-only branch hints from ZSTD_decodeSequence
Looking at the __builtin_expect in ZSTD_decodeSequence:

{   size_t offset;
    #if defined(__clang__)
 if (LIKELY(ofBits > 1)) {
    #else
 if (ofBits > 1) {
    #endif
 ZSTD_STATIC_ASSERT(ZSTD_lo_isLongOffset == 1);

From profile-annotated assembly, the probability of ofBits > 1 is about 75%
(101k counts out of 135k counts). This is much smaller than the recommended
likelihood to use __builtin_expect which is 99%. As a result, clang moved the
else block further away which hurts cache locality. Removing this
__built_expect along with two others in ZSTD_decodeSequence gave better
performance when PGO is enabled. I suggest to remove these branch hints and
rely on PGO which leverages runtime profiles from actual workload to calculate
branch probability instead.
2023-03-28 15:36:22 -07:00
Han Zhu e6dccbf482 Inline BIT_reloadDStream
Inlining `BIT_reloadDStream` provided >3% decompression speed improvement for
clang PGO-optimized zstd binary, measured using the Silesia corpus with
compression level 1. The win comes from improved register allocation which leads
to fewer spills and reloads. Take a look at this comparison of
profile-annotated hot assembly before and after this change:
https://www.diffchecker.com/UjDGIyLz/. The diff is a bit messy, but notice three
fewer moves after inlining.

In general LLVM's register allocator works better when it can see more code. For
example, when the register allocator sees a call instruction, it partitions the
registers into caller registers and callee registers, and it is not free to do
whatever it wants with all the registers for the current function. Inlining the
callee lets the register allocation access all registers and use them more
flexsibly.
2023-03-28 15:36:02 -07:00
Elliot GorokhovskyandGitHub 57e1b45920 Merge pull request #3551 from embg/seq_prod_fuzz
Provide an interface for fuzzing sequence producer plugins
2023-03-28 14:20:54 -07:00
Elliot Gorokhovsky a810e1eeb7 Provide an interface for fuzzing sequence producer plugins 2023-03-28 12:02:57 -07:00
Yann ColletandGitHub abb3585c3b Merge pull request #3568 from facebook/readme_cmake_fat
Add instructions for building Universal2 on macOS via CMake
2023-03-28 10:48:39 -07:00
Felix HandteandGitHub 93da0416e8 Merge pull request #3574 from felixhandte/pzstd-max-cpp-std
[contrib/pzstd] Detect and Select Maximum Available C++ Standard
2023-03-27 16:44:07 -07:00
W. Felix Handte cbe0f0e435 Switch Strategies: Only Set -std=c++11 When Default is Older 2023-03-27 18:37:19 -04:00
Yann ColletandGitHub c36d54f5ed Update README.md
fix minor doc mistake (`ninja build` doesn't work)
2023-03-27 09:09:22 -07:00
Yann ColletandGitHub 7306832e8a Merge pull request #3570 from facebook/rsync_doc
[easy] minor doc update for --rsyncable
2023-03-27 09:07:13 -07:00
W. Felix Handte 1b8bddc41e [contrib/pzstd] Detect and Select Maximum Available C++ Standard
Rather than remove the flag entirely, as proposed in #3499, this commit uses
the newest C++ standard the compiler supports. This retains the selection of
using only standardized features (excluding GNU extensions) and keeps the
recency requirements of the codebase explicit.

Tested with various versions of `g++` and `clang++`.
2023-03-27 11:24:47 -04:00
Yann ColletandGitHub 167157dd74 Merge pull request #3572 from facebook/dependabot/github_actions/actions/checkout-3.5.0
Bump actions/checkout from 3.3.0 to 3.5.0
2023-03-27 07:07:55 -07:00
dependabot[bot]andGitHub 191d22994f Bump github/codeql-action from 2.2.6 to 2.2.8
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.2.6 to 2.2.8.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/16964e90ba004cdf0cd845b866b5df21038b7723...67a35a08586135a9573f4327e904ecbf517a882d)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-27 06:06:11 +00:00
dependabot[bot]andGitHub 4cf9c7e098 Bump actions/checkout from 3.3.0 to 3.5.0
Bumps [actions/checkout](https://github.com/actions/checkout) from 3.3.0 to 3.5.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/ac593985615ec2ede58e132d2e21d2b1cbd6127c...8f4b7f84864484a7bf31766abe9204da3cbe65b3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-27 06:06:05 +00:00
Yann Collet 35c0c2075e minor doc update on --rsyncable
as requested by @devZer0.
fix #3567
2023-03-23 15:42:27 -06:00
Rick Mark ca799f84ca Merge branch 'readme_cmake_fat' of github.com:facebook/zstd into readme_cmake_fat 2023-03-23 09:44:06 -07:00
Rick Mark 408bd1e9fe Add instructions for building Universal2 on macOS via CMake 2023-03-23 09:41:31 -07:00
Tobias Hieta 979b047114 Disable linker flag detection on MSVC/ClangCL.
This fixes compilation with clang-cl on Windows. There
is a bug in cmake so that check_linker_flag() doesn't give
the correct result when using link.exe/lld-link.exe.

Details in CMake's gitlab: https://gitlab.kitware.com/cmake/cmake/-/issues/22023

Fixes #3522
2023-03-22 22:13:57 +01:00
Rick Mark 82cf6037ac Add instructions for building Universal2 on macOS via CMake 2023-03-22 11:28:03 -07:00
daniellerozenblitandGitHub 3e0550ee52 fix window update (#3556) 2023-03-21 13:28:26 -04:00