Skip to content

Commit f392c83

Browse files
robot-pigletblinkov
authored andcommitted
Update contrib/libs/zstd to 1.5.7
Release highlights are: * The compression speed for small data blocks has been notably (~10%) improved at fast compression levels. * The `--patch-from` functionality of the zstd CLI ... had its speed reduced to uncomfortable levels. v1.5.7 largely mitigates the speed impact of high compression levels 18+ * The compression ratio has been enhanced slightly for large data across all compression levels, commit_hash:c66283dd802e1fd38484f7179848006c58f2baa4
1 parent eda49ff commit f392c83

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+3209
-1946
lines changed

contrib/libs/zstd/.yandex_meta/devtools.copyrights.report

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ BELONGS ya.make
139139
lib/compress/zstd_ldm_geartab.h [2:3]
140140
lib/compress/zstd_opt.c [2:3]
141141
lib/compress/zstd_opt.h [2:3]
142+
lib/compress/zstd_preSplit.c [2:3]
143+
lib/compress/zstd_preSplit.h [2:3]
142144
lib/compress/zstdmt_compress.c [2:3]
143145
lib/compress/zstdmt_compress.h [2:3]
144146
lib/decompress/huf_decompress.c [4:4]

contrib/libs/zstd/.yandex_meta/devtools.licenses.report

Lines changed: 8 additions & 4 deletions
Large diffs are not rendered by default.

contrib/libs/zstd/.yandex_meta/override.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
pkgs: attrs: with pkgs; with attrs; rec {
2-
version = "1.5.6";
2+
version = "1.5.7";
33

44
src = fetchFromGitHub {
55
owner = "facebook";
66
repo = "zstd";
77
rev = "v${version}";
8-
hash = "sha256-qcd92hQqVBjMT3hyntjcgk29o9wGQsg5Hg7HE5C0UNc=";
8+
hash = "sha256-tNFWIT9ydfozB8dWcmTMuZLCQmQudTFJIkSr0aG7S44=";
99
};
1010

1111
patches= [];

contrib/libs/zstd/CHANGELOG

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,35 @@
1+
V1.5.7 (Feb 2025)
2+
fix: compression bug in 32-bit mode associated with long-lasting sessions
3+
api: new method `ZSTD_compressSequencesAndLiterals()` (#4217, #4232)
4+
api: `ZSTD_getFrameHeader()` works on skippable frames (#4228)
5+
perf: substantial compression speed improvements (up to +30%) on small data, by @TocarIP (#4144) and @cyan4973 (#4165)
6+
perf: improved compression speed (~+5%) for dictionary compression at low levels (#4170)
7+
perf: much faster speed for `--patch-from` at high compression levels (#4276)
8+
perf: higher `--patch-from` compression ratios, notably at high levels (#4288)
9+
perf: better speed for binaries on Windows (@pps83) and when compiled with Visual Studio (@MessyHack)
10+
perf: slight compression ratio improvement thanks to better block boundaries (#4136, #4176, #4178)
11+
perf: slight compression ratio improvement for `dfast`, aka levels 3 and 4 (#4171)
12+
perf: runtime bmi2 detection enabled on x86 32-bit mode (#4251)
13+
cli: multi-threading as default CLI setting, by @daniellerozenblit
14+
cli: new `--max` command (#4290)
15+
build: improve `msbuild` version autodetection, support VS2022, by @ManuelBlanc
16+
build: fix `meson` build by @artem and @Victor-C-Zhang, and on Windows by @bgilbert
17+
build: compatibility with Apple Framework, by @Treata11
18+
build: improve icc/icx compatibility, by @josepho0918 and @luau-project
19+
build: improve compatibility with Android NDK, by Adenilson Cavalcanti
20+
portability: linux kernel branch, with improved support for Sequence producers (@embg, @gcabiddu, @cyan4973)
21+
portability: improved qnx compatibility, suggested by @rainbowball
22+
portability: improved install script for FreeBSD, by @sunpoet
23+
portability: fixed test suite compatibility with gnu hurd, by @diegonc
24+
doc: clarify specification, by @elasota
25+
misc: improved tests/decodecorpus validation tool (#4102), by antmicro
26+
127
V1.5.6 (Mar 2024)
228
api: Promote `ZSTD_c_targetCBlockSize` to Stable API by @felixhandte
329
api: new `ZSTD_d_maxBlockSize` experimental parameter, to reduce streaming decompression memory, by @terrelln
430
perf: improve performance of param `ZSTD_c_targetCBlockSize`, by @Cyan4973
531
perf: improved compression of arrays of integers at high compression, by @Cyan4973
6-
lib: reduce binary size with selective built-time exclusion, by @felixhandte
32+
lib: reduce binary size with selective build-time exclusion, by @felixhandte
733
lib: improved huffman speed on small data and linux kernel, by @terrelln
834
lib: accept dictionaries with partial literal tables, by @terrelln
935
lib: fix CCtx size estimation with external sequence producer, by @embg
@@ -489,7 +515,7 @@ misc: added /contrib/docker script by @gyscos
489515

490516
v1.3.3 (Dec 21, 2017)
491517
perf: faster zstd_opt strategy (levels 16-19)
492-
fix : bug #944 : multithreading with shared ditionary and large data, reported by @gsliepen
518+
fix : bug #944 : multithreading with shared dictionary and large data, reported by @gsliepen
493519
cli : fix : content size written in header by default
494520
cli : fix : improved LZ4 format support, by @felixhandte
495521
cli : new : hidden command `-S`, to benchmark multiple files while generating one result per file

contrib/libs/zstd/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Our contribution process works in three main stages:
6060
* Note: run local tests to ensure that your changes didn't break existing functionality
6161
* Quick check
6262
```
63-
make shortest
63+
make check
6464
```
6565
* Longer check
6666
```

contrib/libs/zstd/README.md

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ a list of known ports and bindings is provided on [Zstandard homepage](https://f
2929
## Benchmarks
3030

3131
For reference, several fast compression algorithms were tested and compared
32-
on a desktop running Ubuntu 20.04 (`Linux 5.11.0-41-generic`),
33-
with a Core i7-9700K CPU @ 4.9GHz,
32+
on a desktop featuring a Core i7-9700K CPU @ 4.9GHz
33+
and running Ubuntu 20.04 (`Linux ubu20 5.15.0-101-generic`),
3434
using [lzbench], an open-source in-memory benchmark by @inikep
35-
compiled with [gcc] 9.3.0,
35+
compiled with [gcc] 9.4.0,
3636
on the [Silesia compression corpus].
3737

3838
[lzbench]: https://github.com/inikep/lzbench
@@ -41,24 +41,23 @@ on the [Silesia compression corpus].
4141

4242
| Compressor name | Ratio | Compression| Decompress.|
4343
| --------------- | ------| -----------| ---------- |
44-
| **zstd 1.5.1 -1** | 2.887 | 530 MB/s | 1700 MB/s |
44+
| **zstd 1.5.6 -1** | 2.887 | 510 MB/s | 1580 MB/s |
4545
| [zlib] 1.2.11 -1 | 2.743 | 95 MB/s | 400 MB/s |
46-
| brotli 1.0.9 -0 | 2.702 | 395 MB/s | 450 MB/s |
47-
| **zstd 1.5.1 --fast=1** | 2.437 | 600 MB/s | 2150 MB/s |
48-
| **zstd 1.5.1 --fast=3** | 2.239 | 670 MB/s | 2250 MB/s |
49-
| quicklz 1.5.0 -1 | 2.238 | 540 MB/s | 760 MB/s |
50-
| **zstd 1.5.1 --fast=4** | 2.148 | 710 MB/s | 2300 MB/s |
51-
| lzo1x 2.10 -1 | 2.106 | 660 MB/s | 845 MB/s |
52-
| [lz4] 1.9.3 | 2.101 | 740 MB/s | 4500 MB/s |
53-
| lzf 3.6 -1 | 2.077 | 410 MB/s | 830 MB/s |
54-
| snappy 1.1.9 | 2.073 | 550 MB/s | 1750 MB/s |
46+
| brotli 1.0.9 -0 | 2.702 | 395 MB/s | 430 MB/s |
47+
| **zstd 1.5.6 --fast=1** | 2.437 | 545 MB/s | 1890 MB/s |
48+
| **zstd 1.5.6 --fast=3** | 2.239 | 650 MB/s | 2000 MB/s |
49+
| quicklz 1.5.0 -1 | 2.238 | 525 MB/s | 750 MB/s |
50+
| lzo1x 2.10 -1 | 2.106 | 650 MB/s | 825 MB/s |
51+
| [lz4] 1.9.4 | 2.101 | 700 MB/s | 4000 MB/s |
52+
| lzf 3.6 -1 | 2.077 | 420 MB/s | 830 MB/s |
53+
| snappy 1.1.9 | 2.073 | 530 MB/s | 1660 MB/s |
5554

5655
[zlib]: https://www.zlib.net/
5756
[lz4]: https://lz4.github.io/lz4/
5857

5958
The negative compression levels, specified with `--fast=#`,
6059
offer faster compression and decompression speed
61-
at the cost of compression ratio (compared to level 1).
60+
at the cost of compression ratio.
6261

6362
Zstd can also offer stronger compression ratios at the cost of compression speed.
6463
Speed vs Compression trade-off is configurable by small increments.
@@ -185,6 +184,17 @@ You can build and install zstd [vcpkg](https://github.com/Microsoft/vcpkg/) depe
185184
The zstd port in vcpkg is kept up to date by Microsoft team members and community contributors.
186185
If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
187186

187+
### Conan
188+
189+
You can install pre-built binaries for zstd or build it from source using [Conan](https://conan.io/). Use the following command:
190+
191+
```bash
192+
conan install --requires="zstd/[*]" --build=missing
193+
```
194+
195+
The zstd Conan recipe is kept up to date by Conan maintainers and community contributors.
196+
If the version is out of date, please [create an issue or pull request](https://github.com/conan-io/conan-center-index) on the ConanCenterIndex repository.
197+
188198
### Visual Studio (Windows)
189199

190200
Going into `build` directory, you will find additional possibilities:

contrib/libs/zstd/lib/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,16 @@ Enabling multithreading requires 2 conditions :
2727

2828
For convenience, we provide a build target to generate multi and single threaded libraries:
2929
- Force enable multithreading on both dynamic and static libraries by appending `-mt` to the target, e.g. `make lib-mt`.
30+
Note that the `.pc` generated on calling `make lib-mt` will already include the require Libs and Cflags.
3031
- Force disable multithreading on both dynamic and static libraries by appending `-nomt` to the target, e.g. `make lib-nomt`.
3132
- By default, as mentioned before, dynamic library is multithreaded, and static library is single-threaded, e.g. `make lib`.
3233

3334
When linking a POSIX program with a multithreaded version of `libzstd`,
3435
note that it's necessary to invoke the `-pthread` flag during link stage.
3536

37+
The `.pc` generated from `make install` or `make install-pc` always assume a single-threaded static library
38+
is compiled. To correctly generate a `.pc` for the multi-threaded static library, set `MT=1` as ENV variable.
39+
3640
Multithreading capabilities are exposed
3741
via the [advanced API defined in `lib/zstd.h`](https://github.com/facebook/zstd/blob/v1.4.3/lib/zstd.h#L351).
3842

@@ -145,6 +149,13 @@ The file structure is designed to make this selection manually achievable for an
145149
will expose the deprecated `ZSTDMT` API exposed by `zstdmt_compress.h` in
146150
the shared library, which is now hidden by default.
147151

152+
- The build macro `STATIC_BMI2` can be set to 1 to force usage of `bmi2` instructions.
153+
It is generally not necessary to set this build macro,
154+
because `STATIC_BMI2` will be automatically set to 1
155+
on detecting the presence of the corresponding instruction set in the compilation target.
156+
It's nonetheless available as an optional manual toggle for better control,
157+
and can also be used to forcefully disable `bmi2` instructions by setting it to 0.
158+
148159
- The build macro `DYNAMIC_BMI2` can be set to 1 or 0 in order to generate binaries
149160
which can detect at runtime the presence of BMI2 instructions, and use them only if present.
150161
These instructions contribute to better performance, notably on the decoder side.

contrib/libs/zstd/lib/common/bits.h

Lines changed: 92 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,29 @@ MEM_STATIC unsigned ZSTD_countTrailingZeros32_fallback(U32 val)
2828
MEM_STATIC unsigned ZSTD_countTrailingZeros32(U32 val)
2929
{
3030
assert(val != 0);
31-
# if defined(_MSC_VER)
32-
# if STATIC_BMI2 == 1
33-
return (unsigned)_tzcnt_u32(val);
34-
# else
35-
if (val != 0) {
36-
unsigned long r;
37-
_BitScanForward(&r, val);
38-
return (unsigned)r;
39-
} else {
40-
/* Should not reach this code path */
41-
__assume(0);
42-
}
43-
# endif
44-
# elif defined(__GNUC__) && (__GNUC__ >= 4)
45-
return (unsigned)__builtin_ctz(val);
46-
# else
47-
return ZSTD_countTrailingZeros32_fallback(val);
48-
# endif
31+
#if defined(_MSC_VER)
32+
# if STATIC_BMI2
33+
return (unsigned)_tzcnt_u32(val);
34+
# else
35+
if (val != 0) {
36+
unsigned long r;
37+
_BitScanForward(&r, val);
38+
return (unsigned)r;
39+
} else {
40+
__assume(0); /* Should not reach this code path */
41+
}
42+
# endif
43+
#elif defined(__GNUC__) && (__GNUC__ >= 4)
44+
return (unsigned)__builtin_ctz(val);
45+
#elif defined(__ICCARM__)
46+
return (unsigned)__builtin_ctz(val);
47+
#else
48+
return ZSTD_countTrailingZeros32_fallback(val);
49+
#endif
4950
}
5051

51-
MEM_STATIC unsigned ZSTD_countLeadingZeros32_fallback(U32 val) {
52+
MEM_STATIC unsigned ZSTD_countLeadingZeros32_fallback(U32 val)
53+
{
5254
assert(val != 0);
5355
{
5456
static const U32 DeBruijnClz[32] = {0, 9, 1, 10, 13, 21, 2, 29,
@@ -67,86 +69,89 @@ MEM_STATIC unsigned ZSTD_countLeadingZeros32_fallback(U32 val) {
6769
MEM_STATIC unsigned ZSTD_countLeadingZeros32(U32 val)
6870
{
6971
assert(val != 0);
70-
# if defined(_MSC_VER)
71-
# if STATIC_BMI2 == 1
72-
return (unsigned)_lzcnt_u32(val);
73-
# else
74-
if (val != 0) {
75-
unsigned long r;
76-
_BitScanReverse(&r, val);
77-
return (unsigned)(31 - r);
78-
} else {
79-
/* Should not reach this code path */
80-
__assume(0);
81-
}
82-
# endif
83-
# elif defined(__GNUC__) && (__GNUC__ >= 4)
84-
return (unsigned)__builtin_clz(val);
85-
# else
86-
return ZSTD_countLeadingZeros32_fallback(val);
87-
# endif
72+
#if defined(_MSC_VER)
73+
# if STATIC_BMI2
74+
return (unsigned)_lzcnt_u32(val);
75+
# else
76+
if (val != 0) {
77+
unsigned long r;
78+
_BitScanReverse(&r, val);
79+
return (unsigned)(31 - r);
80+
} else {
81+
__assume(0); /* Should not reach this code path */
82+
}
83+
# endif
84+
#elif defined(__GNUC__) && (__GNUC__ >= 4)
85+
return (unsigned)__builtin_clz(val);
86+
#elif defined(__ICCARM__)
87+
return (unsigned)__builtin_clz(val);
88+
#else
89+
return ZSTD_countLeadingZeros32_fallback(val);
90+
#endif
8891
}
8992

9093
MEM_STATIC unsigned ZSTD_countTrailingZeros64(U64 val)
9194
{
9295
assert(val != 0);
93-
# if defined(_MSC_VER) && defined(_WIN64)
94-
# if STATIC_BMI2 == 1
95-
return (unsigned)_tzcnt_u64(val);
96-
# else
97-
if (val != 0) {
98-
unsigned long r;
99-
_BitScanForward64(&r, val);
100-
return (unsigned)r;
101-
} else {
102-
/* Should not reach this code path */
103-
__assume(0);
104-
}
105-
# endif
106-
# elif defined(__GNUC__) && (__GNUC__ >= 4) && defined(__LP64__)
107-
return (unsigned)__builtin_ctzll(val);
108-
# else
109-
{
110-
U32 mostSignificantWord = (U32)(val >> 32);
111-
U32 leastSignificantWord = (U32)val;
112-
if (leastSignificantWord == 0) {
113-
return 32 + ZSTD_countTrailingZeros32(mostSignificantWord);
114-
} else {
115-
return ZSTD_countTrailingZeros32(leastSignificantWord);
116-
}
96+
#if defined(_MSC_VER) && defined(_WIN64)
97+
# if STATIC_BMI2
98+
return (unsigned)_tzcnt_u64(val);
99+
# else
100+
if (val != 0) {
101+
unsigned long r;
102+
_BitScanForward64(&r, val);
103+
return (unsigned)r;
104+
} else {
105+
__assume(0); /* Should not reach this code path */
106+
}
107+
# endif
108+
#elif defined(__GNUC__) && (__GNUC__ >= 4) && defined(__LP64__)
109+
return (unsigned)__builtin_ctzll(val);
110+
#elif defined(__ICCARM__)
111+
return (unsigned)__builtin_ctzll(val);
112+
#else
113+
{
114+
U32 mostSignificantWord = (U32)(val >> 32);
115+
U32 leastSignificantWord = (U32)val;
116+
if (leastSignificantWord == 0) {
117+
return 32 + ZSTD_countTrailingZeros32(mostSignificantWord);
118+
} else {
119+
return ZSTD_countTrailingZeros32(leastSignificantWord);
117120
}
118-
# endif
121+
}
122+
#endif
119123
}
120124

121125
MEM_STATIC unsigned ZSTD_countLeadingZeros64(U64 val)
122126
{
123127
assert(val != 0);
124-
# if defined(_MSC_VER) && defined(_WIN64)
125-
# if STATIC_BMI2 == 1
126-
return (unsigned)_lzcnt_u64(val);
127-
# else
128-
if (val != 0) {
129-
unsigned long r;
130-
_BitScanReverse64(&r, val);
131-
return (unsigned)(63 - r);
132-
} else {
133-
/* Should not reach this code path */
134-
__assume(0);
135-
}
136-
# endif
137-
# elif defined(__GNUC__) && (__GNUC__ >= 4)
138-
return (unsigned)(__builtin_clzll(val));
139-
# else
140-
{
141-
U32 mostSignificantWord = (U32)(val >> 32);
142-
U32 leastSignificantWord = (U32)val;
143-
if (mostSignificantWord == 0) {
144-
return 32 + ZSTD_countLeadingZeros32(leastSignificantWord);
145-
} else {
146-
return ZSTD_countLeadingZeros32(mostSignificantWord);
147-
}
128+
#if defined(_MSC_VER) && defined(_WIN64)
129+
# if STATIC_BMI2
130+
return (unsigned)_lzcnt_u64(val);
131+
# else
132+
if (val != 0) {
133+
unsigned long r;
134+
_BitScanReverse64(&r, val);
135+
return (unsigned)(63 - r);
136+
} else {
137+
__assume(0); /* Should not reach this code path */
138+
}
139+
# endif
140+
#elif defined(__GNUC__) && (__GNUC__ >= 4)
141+
return (unsigned)(__builtin_clzll(val));
142+
#elif defined(__ICCARM__)
143+
return (unsigned)(__builtin_clzll(val));
144+
#else
145+
{
146+
U32 mostSignificantWord = (U32)(val >> 32);
147+
U32 leastSignificantWord = (U32)val;
148+
if (mostSignificantWord == 0) {
149+
return 32 + ZSTD_countLeadingZeros32(leastSignificantWord);
150+
} else {
151+
return ZSTD_countLeadingZeros32(mostSignificantWord);
148152
}
149-
# endif
153+
}
154+
#endif
150155
}
151156

152157
MEM_STATIC unsigned ZSTD_NbCommonBytes(size_t val)

0 commit comments

Comments
 (0)