Skip to content

Commit cbc5225

Browse files
authored
Merge pull request #531 from facebook/dev
Zstandard v1.1.3
2 parents 817995b + 5962e58 commit cbc5225

Some content is hidden

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

96 files changed

+6018
-1094
lines changed

.buckconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[cxx]
2+
cppflags = -DXXH_NAMESPACE=ZSTD_ -DZSTD_LEGACY_SUPPORT=1
3+
cflags = -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef -Wpointer-arith
4+
cxxppflags = -DXXH_NAMESPACE=ZSTD_ -DZSTD_LEGACY_SUPPORT=1
5+
cxxflags = -std=c++11 -Wno-format-security -Wno-deprecated-declarations
6+
gtest_dep = //contrib/pzstd:gtest
7+
8+
[httpserver]
9+
port = 0

.buckversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
c8dec2e8da52d483f6dd7c6cd2ad694e8e6fed2b

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
# Executables
1717
zstd
18+
zstdmt
1819
*.exe
1920
*.out
2021
*.app
@@ -36,3 +37,5 @@ googletest/
3637

3738
# Directories
3839
bin/
40+
.buckd/
41+
buck-out/

.travis.yml

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ matrix:
88

99

1010
# Container-based Ubuntu 12.04 LTS Server Edition 64 bit (doesn't support 32-bit includes)
11-
- env: Ubu=12.04cont Cmd="make test && make clean && make travis-install"
12-
os: linux
13-
sudo: false
14-
15-
- env: Ubu=12.04cont Cmd="make zlibwrapper && make clean && make -C tests test-zstd-nolegacy && make clean && make cmaketest && make clean && make -C contrib/pzstd googletest pzstd tests check && make -C contrib/pzstd clean"
11+
- env: Ubu=12.04cont Cmd="make zlibwrapper && make clean && make -C tests test-symbols && make clean && make -C tests test-zstd-nolegacy && make clean && make cmaketest && make clean && make -C contrib/pzstd googletest pzstd tests check && make -C contrib/pzstd clean"
1612
os: linux
1713
sudo: false
1814
language: cpp
@@ -37,7 +33,7 @@ matrix:
3733

3834

3935
# Standard Ubuntu 12.04 LTS Server Edition 64 bit
40-
- env: Ubu=12.04 Cmd="make -C programs zstd-small zstd-decompress zstd-compress && make -C tests test-gzstd && make -C programs clean && make -C tests versionsTest"
36+
- env: Ubu=12.04 Cmd="make -C programs zstd-small zstd-decompress zstd-compress && make -C programs clean && make -C tests versionsTest"
4137
os: linux
4238
sudo: required
4339

@@ -69,7 +65,7 @@ matrix:
6965

7066

7167
# Ubuntu 14.04 LTS Server Edition 64 bit
72-
- env: Ubu=14.04 Cmd="make armtest && make clean && make aarch64test"
68+
- env: Ubu=14.04 Cmd="make armtest"
7369
dist: trusty
7470
sudo: required
7571
addons:
@@ -78,11 +74,30 @@ matrix:
7874
- qemu-system-arm
7975
- qemu-user-static
8076
- gcc-arm-linux-gnueabi
81-
- libc6-dev-armel-cross
77+
- libc6-dev-armel-cross
78+
79+
- env: Ubu=14.04 Cmd="make aarch64test"
80+
dist: trusty
81+
sudo: required
82+
addons:
83+
apt:
84+
packages:
85+
- qemu-system-arm
86+
- qemu-user-static
8287
- gcc-aarch64-linux-gnu
8388
- libc6-dev-arm64-cross
8489

85-
- env: Ubu=14.04 Cmd='make ppctest && make clean && make ppc64test'
90+
- env: Ubu=14.04 Cmd='make ppctest'
91+
dist: trusty
92+
sudo: required
93+
addons:
94+
apt:
95+
packages:
96+
- qemu-system-ppc
97+
- qemu-user-static
98+
- gcc-powerpc-linux-gnu
99+
100+
- env: Ubu=14.04 Cmd='make ppc64test'
86101
dist: trusty
87102
sudo: required
88103
addons:
@@ -101,33 +116,43 @@ matrix:
101116
packages:
102117
- valgrind
103118

104-
- env: Ubu=14.04 Cmd="make gpptest && make clean && make gnu90test && make clean && make c99test && make clean && make gnu99test && make clean && make clangtest && make clean && make -C contrib/pzstd googletest32 && make -C contrib/pzstd all32 && make -C contrib/pzstd check && make -C contrib/pzstd clean"
119+
120+
121+
# other feature branches => short tests
122+
- env: Ubu=12.04cont Cmd="make test && make clean && make travis-install"
123+
os: linux
124+
sudo: false
125+
126+
- env: Ubu=14.04 Cmd="make -C tests test32"
105127
os: linux
106128
dist: trusty
107129
sudo: required
108-
install:
109-
- export CXX="g++-4.8" CC="gcc-4.8"
110130
addons:
111131
apt:
112132
packages:
113133
- libc6-dev-i386
114-
- g++-multilib
115-
- gcc-4.8
116-
- gcc-4.8-multilib
117-
- g++-4.8
118-
- g++-4.8-multilib
134+
- gcc-multilib
119135

120-
- env: Ubu=14.04 Cmd="make -C tests test32"
136+
- env: Ubu=14.04 Cmd="make gpptest && make clean && make gnu90test && make clean
137+
&& make c99test && make clean && make gnu99test && make clean
138+
&& make clangtest && make clean && make -C contrib/pzstd googletest32
139+
&& make -C contrib/pzstd all32 && make -C contrib/pzstd check && make -C contrib/pzstd clean"
121140
os: linux
122141
dist: trusty
123142
sudo: required
143+
install:
144+
- export CXX="g++-4.8" CC="gcc-4.8"
124145
addons:
125146
apt:
126147
packages:
127148
- libc6-dev-i386
128-
- gcc-multilib
149+
- g++-multilib
150+
- gcc-4.8
151+
- gcc-4.8-multilib
152+
- g++-4.8
153+
- g++-4.8-multilib
129154

130-
- env: Ubu=14.04 Cmd="make gcc5test && make clean && make gcc6test"
155+
- env: Ubu=14.04 Cmd="make gcc5test && make clean && make gcc6test && make clean && make -C tests dll"
131156
os: linux
132157
dist: trusty
133158
sudo: required
@@ -144,5 +169,7 @@ matrix:
144169

145170
script:
146171
- JOB_NUMBER=$(echo $TRAVIS_JOB_NUMBER | sed -e 's:[0-9][0-9]*\.\(.*\):\1:')
147-
# - if [ $JOB_NUMBER -eq 9 ] || [ $JOB_NUMBER -eq 10 ]; then sh -c "$Cmd"; fi
148-
- sh -c "$Cmd"
172+
# dev => normal tests; other feature branches => short tests (number > 11)
173+
- if [ "$TRAVIS_PULL_REQUEST" = "true" ] || [ $JOB_NUMBER -gt 11 ] || [ "$TRAVIS_BRANCH" = "dev" ] && [ "$TRAVIS_BRANCH" != "master" ]; then sh -c "$Cmd"; fi
174+
# master => long tests, as this is the final step towards a Release
175+
- if [ "$TRAVIS_BRANCH" = "master" ]; then FUZZERTEST=-T10mn sh -c "$Cmd"; fi

Makefile

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,23 @@ EXT =
2323
endif
2424

2525
.PHONY: default
26-
default: lib zstd
26+
default: lib zstd-release
2727

2828
.PHONY: all
29-
all:
30-
$(MAKE) -C $(ZSTDDIR) $@
31-
$(MAKE) -C $(PRGDIR) $@ zstd32
32-
$(MAKE) -C $(TESTDIR) $@ all32
29+
all: allmost
30+
CPPFLAGS=-I../lib LDFLAGS=-L../lib $(MAKE) -C examples/ $@
31+
32+
.PHONY: allmost
33+
allmost:
34+
$(MAKE) -C $(ZSTDDIR) all
35+
$(MAKE) -C $(PRGDIR) all
36+
$(MAKE) -C $(TESTDIR) all
37+
$(MAKE) -C $(ZWRAPDIR) all
38+
39+
.PHONY: all32
40+
all32:
41+
$(MAKE) -C $(PRGDIR) zstd32
42+
$(MAKE) -C $(TESTDIR) all32
3343

3444
.PHONY: lib
3545
lib:
@@ -40,6 +50,16 @@ zstd:
4050
@$(MAKE) -C $(PRGDIR) $@
4151
cp $(PRGDIR)/zstd$(EXT) .
4252

53+
.PHONY: zstd-release
54+
zstd-release:
55+
@$(MAKE) -C $(PRGDIR)
56+
cp $(PRGDIR)/zstd$(EXT) .
57+
58+
.PHONY: zstdmt
59+
zstdmt:
60+
@$(MAKE) -C $(PRGDIR) $@
61+
cp $(PRGDIR)/zstd$(EXT) ./zstdmt$(EXT)
62+
4363
.PHONY: zlibwrapper
4464
zlibwrapper:
4565
$(MAKE) -C $(ZWRAPDIR) test
@@ -54,7 +74,8 @@ clean:
5474
@$(MAKE) -C $(PRGDIR) $@ > $(VOID)
5575
@$(MAKE) -C $(TESTDIR) $@ > $(VOID)
5676
@$(MAKE) -C $(ZWRAPDIR) $@ > $(VOID)
57-
@$(RM) zstd$(EXT) tmp*
77+
@$(MAKE) -C examples/ $@ > $(VOID)
78+
@$(RM) zstd$(EXT) zstdmt$(EXT) tmp*
5879
@echo Cleaning completed
5980

6081

@@ -77,7 +98,7 @@ travis-install:
7798
$(MAKE) install PREFIX=~/install_test_dir
7899

79100
gpptest: clean
80-
$(MAKE) -C programs all CC=g++ CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror"
101+
CC=g++ $(MAKE) -C programs all CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror"
81102

82103
gcc5test: clean
83104
gcc-5 -v
@@ -148,13 +169,13 @@ gnu90test: clean
148169
CFLAGS="-std=gnu90" $(MAKE) all
149170

150171
c99test: clean
151-
CFLAGS="-std=c99" $(MAKE) all
172+
CFLAGS="-std=c99" $(MAKE) allmost
152173

153174
gnu99test: clean
154175
CFLAGS="-std=gnu99" $(MAKE) all
155176

156177
c11test: clean
157-
CFLAGS="-std=c11" $(MAKE) all
178+
CFLAGS="-std=c11" $(MAKE) allmost
158179

159180
bmix64test: clean
160181
CFLAGS="-O3 -mbmi -Werror" $(MAKE) -C $(TESTDIR) test

NEWS

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
v1.1.3
2+
cli : zstd can decompress .gz files (can be disabled with `make zstd-nogz` or `make HAVE_ZLIB=0`)
3+
cli : new : experimental target `make zstdmt`, with multi-threading support
4+
cli : new : improved dictionary builder "cover" (experimental), by Nick Terrell
5+
cli : new : advanced commands for detailed parameters, by Przemyslaw Skibinski
6+
cli : fix zstdless on Mac OS-X, by Andrew Janke
7+
cli : fix #232 "compress non-files"
8+
dictBuilder : improved dictionary generation quality, thanks to Nick Terrell
9+
API : new : lib/compress/ZSTDMT_compress.h multithreading API (experimental)
10+
API : new : ZSTD_create?Dict_byReference(), requested by Bartosz Taudul
11+
API : new : ZDICT_finalizeDictionary()
12+
API : fix : ZSTD_initCStream_usingCDict() properly writes dictID into frame header, by Gregory Szorc (#511)
13+
API : fix : all symbols properly exposed in libzstd, by Nick Terrell
14+
build : support for Solaris target, by Przemyslaw Skibinski
15+
doc : clarified specification, by Andrew Purcell
16+
117
v1.1.2
218
API : streaming : decompression : changed : automatic implicit reset when chain-decoding new frames without init
319
API : experimental : added : dictID retrieval functions, and ZSTD_initCStream_srcSize()

README.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
targeting real-time compression scenarios at zlib-level and better compression ratios.
33

44
It is provided as an open-source BSD-licensed **C** library,
5-
and a command line utility producing and decoding `.zst` compressed files.
5+
and a command line utility producing and decoding `.zst` and `.gz` files.
66
For other programming languages,
77
you can consult a list of known ports on [Zstandard homepage](http://www.zstd.net/#other-languages).
88

@@ -47,18 +47,27 @@ For a larger picture including very slow modes, [click on this link](doc/images/
4747

4848
### The case for Small Data compression
4949

50-
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 achieve any significant compression.
50+
Previous charts provide results applicable to typical file and stream scenarios (several MB). Small data comes with different perspectives.
5151

52-
This problem is common to many compression algorithms. The reason is, compression algorithms learn from past data how to compress future data. But at the beginning of a new file, there is no "past" to build upon.
52+
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.
5353

54-
To solve this situation, Zstd offers a __training mode__, which can be used to tune the algorithm for a selected type of data, by providing it with a few samples. The result of the training is stored in a file called "dictionary", which can be loaded before compression and decompression. Using this dictionary, the compression ratio achievable on small data improves dramatically:
54+
To solve this situation, Zstd offers a __training mode__, which can be used to tune the algorithm for a selected type of data.
55+
Training Zstandard is achieved by provide it with a few samples (one file per sample). The result of this training is stored in a file called "dictionary", which must be loaded before compression and decompression.
56+
Using this dictionary, the compression ratio achievable on small data improves dramatically.
5557

56-
![Compressing Small Data](doc/images/smallData.png "Compressing Small Data")
58+
The following example uses the `github-users` [sample set](https://www.dropbox.com/s/mnktkomhkjbf1i2/github_users.tar.zst?dl=0), created from [github public API](https://developer.github.com/v3/users/#get-all-users).
59+
It consists of roughly 10K records weighting about 1KB each.
5760

58-
These compression gains are achieved while simultaneously providing faster compression and decompression speeds.
61+
Compression Ratio | Compression Speed | Decompression Speed
62+
------------------|-------------------|--------------------
63+
![Compression Ratio](doc/images/dict-cr.png "Compression Ratio") | ![Compression Speed](doc/images/dict-cs.png "Compression Speed") | ![Decompression Speed](doc/images/dict-ds.png "Decompression Speed")
5964

60-
Dictionary works if there is some correlation in a family of small data (there is no _universal dictionary_).
61-
Hence, deploying one dictionary per type of data will provide the greatest benefits. Dictionary gains are mostly effective in the first few KB. Then, the compression algorithm will rely more and more on previously decoded content to compress the rest of the file.
65+
66+
These compression gains are achieved while simultaneously providing _faster_ compression and decompression speeds.
67+
68+
Training works if there is some correlation in a family of small data samples. The more data-specific a dictionary is, the more efficient it is (there is no _universal dictionary_).
69+
Hence, deploying one dictionary per type of data will provide the greatest benefits.
70+
Dictionary gains are mostly effective in the first few KB. Then, the compression algorithm will gradually use previously decoded content to better compress the rest of the file.
6271

6372
#### Dictionary compression How To :
6473

@@ -68,11 +77,12 @@ Hence, deploying one dictionary per type of data will provide the greatest benef
6877

6978
2) Compress with dictionary
7079

71-
`zstd FILE -D dictionaryName`
80+
`zstd -D dictionaryName FILE`
7281

7382
3) Decompress with dictionary
7483

75-
`zstd --decompress FILE.zst -D dictionaryName`
84+
`zstd -D dictionaryName --decompress FILE.zst`
85+
7686

7787
### Build
7888

appveyor.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ version: 1.0.{build}
22
environment:
33
matrix:
44
- COMPILER: "gcc"
5-
MAKE_PARAMS: "test"
5+
MAKE_PARAMS: '"make test && make lib && make -C tests test-symbols fullbench-dll fullbench-lib"'
66
PLATFORM: "mingw64"
77
- COMPILER: "gcc"
8-
MAKE_PARAMS: "test"
8+
MAKE_PARAMS: "make test"
99
PLATFORM: "mingw32"
1010
- COMPILER: "visual"
1111
CONFIGURATION: "Debug"
@@ -46,6 +46,13 @@ build_script:
4646
ECHO make %CLANG_PARAMS% &&
4747
make %CLANG_PARAMS% &&
4848
COPY tests\fuzzer.exe tests\fuzzer_clang.exe &&
49+
ECHO *** &&
50+
ECHO *** Building cmake for %PLATFORM% &&
51+
ECHO *** &&
52+
mkdir build\cmake\build &&
53+
cd build\cmake\build &&
54+
cmake -G "Visual Studio 14 2015 Win64" .. &&
55+
cd ..\..\.. &&
4956
make clean &&
5057
ECHO *** &&
5158
ECHO *** Building pzstd for %PLATFORM% &&
@@ -62,8 +69,8 @@ build_script:
6269
ECHO *** &&
6370
make -v &&
6471
cc -v &&
65-
ECHO make %MAKE_PARAMS% &&
66-
make %MAKE_PARAMS%
72+
ECHO %MAKE_PARAMS% &&
73+
sh -c %MAKE_PARAMS%
6774
)
6875
- if [%COMPILER%]==[gcc] if [%PLATFORM%]==[mingw64] (
6976
COPY programs\zstd.exe bin\zstd.exe &&

0 commit comments

Comments
 (0)