1*22ce4affSfengbojiangCommand Line Interface for Zstandard library
2*22ce4affSfengbojiang============================================
3*22ce4affSfengbojiang
4*22ce4affSfengbojiangCommand Line Interface (CLI) can be created using the `make` command without any additional parameters.
5*22ce4affSfengbojiangThere are however other Makefile targets that create different variations of CLI:
6*22ce4affSfengbojiang- `zstd` : default CLI supporting gzip-like arguments; includes dictionary builder, benchmark, and supports decompression of legacy zstd formats
7*22ce4affSfengbojiang- `zstd_nolegacy` : Same as `zstd` but without support for legacy zstd formats
8*22ce4affSfengbojiang- `zstd-small` : CLI optimized for minimal size; no dictionary builder, no benchmark, and no support for legacy zstd formats
9*22ce4affSfengbojiang- `zstd-compress` : version of CLI which can only compress into zstd format
10*22ce4affSfengbojiang- `zstd-decompress` : version of CLI which can only decompress zstd format
11*22ce4affSfengbojiang
12*22ce4affSfengbojiang
13*22ce4affSfengbojiang### Compilation variables
14*22ce4affSfengbojiang`zstd` scope can be altered by modifying the following `make` variables :
15*22ce4affSfengbojiang
16*22ce4affSfengbojiang- __HAVE_THREAD__ : multithreading is automatically enabled when `pthread` is detected.
17*22ce4affSfengbojiang  It's possible to disable multithread support, by setting `HAVE_THREAD=0`.
18*22ce4affSfengbojiang  Example : `make zstd HAVE_THREAD=0`
19*22ce4affSfengbojiang  It's also possible to force multithread support, using `HAVE_THREAD=1`.
20*22ce4affSfengbojiang  In which case, linking stage will fail if neither `pthread` nor `windows.h` library can be found.
21*22ce4affSfengbojiang  This is useful to ensure this feature is not silently disabled.
22*22ce4affSfengbojiang
23*22ce4affSfengbojiang- __ZSTD_LEGACY_SUPPORT__ : `zstd` can decompress files compressed by older versions of `zstd`.
24*22ce4affSfengbojiang  Starting v0.8.0, all versions of `zstd` produce frames compliant with the [specification](../doc/zstd_compression_format.md), and are therefore compatible.
25*22ce4affSfengbojiang  But older versions (< v0.8.0) produced different, incompatible, frames.
26*22ce4affSfengbojiang  By default, `zstd` supports decoding legacy formats >= v0.4.0 (`ZSTD_LEGACY_SUPPORT=4`).
27*22ce4affSfengbojiang  This can be altered by modifying this compilation variable.
28*22ce4affSfengbojiang  `ZSTD_LEGACY_SUPPORT=1` means "support all formats >= v0.1.0".
29*22ce4affSfengbojiang  `ZSTD_LEGACY_SUPPORT=2` means "support all formats >= v0.2.0", and so on.
30*22ce4affSfengbojiang  `ZSTD_LEGACY_SUPPORT=0` means _DO NOT_ support any legacy format.
31*22ce4affSfengbojiang  if `ZSTD_LEGACY_SUPPORT >= 8`, it's the same as `0`, since there is no legacy format after `7`.
32*22ce4affSfengbojiang  Note : `zstd` only supports decoding older formats, and cannot generate any legacy format.
33*22ce4affSfengbojiang
34*22ce4affSfengbojiang- __HAVE_ZLIB__ : `zstd` can compress and decompress files in `.gz` format.
35*22ce4affSfengbojiang  This is ordered through command `--format=gzip`.
36*22ce4affSfengbojiang  Alternatively, symlinks named `gzip` or `gunzip` will mimic intended behavior.
37*22ce4affSfengbojiang  `.gz` support is automatically enabled when `zlib` library is detected at build time.
38*22ce4affSfengbojiang  It's possible to disable `.gz` support, by setting `HAVE_ZLIB=0`.
39*22ce4affSfengbojiang  Example : `make zstd HAVE_ZLIB=0`
40*22ce4affSfengbojiang  It's also possible to force compilation with zlib support, using `HAVE_ZLIB=1`.
41*22ce4affSfengbojiang  In which case, linking stage will fail if `zlib` library cannot be found.
42*22ce4affSfengbojiang  This is useful to prevent silent feature disabling.
43*22ce4affSfengbojiang
44*22ce4affSfengbojiang- __HAVE_LZMA__ : `zstd` can compress and decompress files in `.xz` and `.lzma` formats.
45*22ce4affSfengbojiang  This is ordered through commands `--format=xz` and `--format=lzma` respectively.
46*22ce4affSfengbojiang  Alternatively, symlinks named `xz`, `unxz`, `lzma`, or `unlzma` will mimic intended behavior.
47*22ce4affSfengbojiang  `.xz` and `.lzma` support is automatically enabled when `lzma` library is detected at build time.
48*22ce4affSfengbojiang  It's possible to disable `.xz` and `.lzma` support, by setting `HAVE_LZMA=0`.
49*22ce4affSfengbojiang  Example : `make zstd HAVE_LZMA=0`
50*22ce4affSfengbojiang  It's also possible to force compilation with lzma support, using `HAVE_LZMA=1`.
51*22ce4affSfengbojiang  In which case, linking stage will fail if `lzma` library cannot be found.
52*22ce4affSfengbojiang  This is useful to prevent silent feature disabling.
53*22ce4affSfengbojiang
54*22ce4affSfengbojiang- __HAVE_LZ4__ : `zstd` can compress and decompress files in `.lz4` formats.
55*22ce4affSfengbojiang  This is ordered through commands `--format=lz4`.
56*22ce4affSfengbojiang  Alternatively, symlinks named `lz4`, or `unlz4` will mimic intended behavior.
57*22ce4affSfengbojiang  `.lz4` support is automatically enabled when `lz4` library is detected at build time.
58*22ce4affSfengbojiang  It's possible to disable `.lz4` support, by setting `HAVE_LZ4=0` .
59*22ce4affSfengbojiang  Example : `make zstd HAVE_LZ4=0`
60*22ce4affSfengbojiang  It's also possible to force compilation with lz4 support, using `HAVE_LZ4=1`.
61*22ce4affSfengbojiang  In which case, linking stage will fail if `lz4` library cannot be found.
62*22ce4affSfengbojiang  This is useful to prevent silent feature disabling.
63*22ce4affSfengbojiang
64*22ce4affSfengbojiang- __ZSTD_NOBENCH__ : `zstd` cli will be compiled without its integrated benchmark module.
65*22ce4affSfengbojiang  This can be useful to produce smaller binaries.
66*22ce4affSfengbojiang  In this case, the corresponding unit can also be excluded from compilation target.
67*22ce4affSfengbojiang
68*22ce4affSfengbojiang- __ZSTD_NODICT__ : `zstd` cli will be compiled without support for the integrated dictionary builder.
69*22ce4affSfengbojiang  This can be useful to produce smaller binaries.
70*22ce4affSfengbojiang  In this case, the corresponding unit can also be excluded from compilation target.
71*22ce4affSfengbojiang
72*22ce4affSfengbojiang- __ZSTD_NOCOMPRESS__ : `zstd` cli will be compiled without support for compression.
73*22ce4affSfengbojiang  The resulting binary will only be able to decompress files.
74*22ce4affSfengbojiang  This can be useful to produce smaller binaries.
75*22ce4affSfengbojiang  A corresponding `Makefile` target using this ability is `zstd-decompress`.
76*22ce4affSfengbojiang
77*22ce4affSfengbojiang- __ZSTD_NODECOMPRESS__ : `zstd` cli will be compiled without support for decompression.
78*22ce4affSfengbojiang  The resulting binary will only be able to compress files.
79*22ce4affSfengbojiang  This can be useful to produce smaller binaries.
80*22ce4affSfengbojiang  A corresponding `Makefile` target using this ability is `zstd-compress`.
81*22ce4affSfengbojiang
82*22ce4affSfengbojiang- __BACKTRACE__ : `zstd` can display a stack backtrace when execution
83*22ce4affSfengbojiang  generates a runtime exception. By default, this feature may be
84*22ce4affSfengbojiang  degraded/disabled on some platforms unless additional compiler directives are
85*22ce4affSfengbojiang  applied. When triaging a runtime issue, enabling this feature can provide
86*22ce4affSfengbojiang  more context to determine the location of the fault.
87*22ce4affSfengbojiang  Example : `make zstd BACKTRACE=1`
88*22ce4affSfengbojiang
89*22ce4affSfengbojiang
90*22ce4affSfengbojiang### Aggregation of parameters
91*22ce4affSfengbojiangCLI supports aggregation of parameters i.e. `-b1`, `-e18`, and `-i1` can be joined into `-b1e18i1`.
92*22ce4affSfengbojiang
93*22ce4affSfengbojiang
94*22ce4affSfengbojiang### Symlink shortcuts
95*22ce4affSfengbojiangIt's possible to invoke `zstd` through a symlink.
96*22ce4affSfengbojiangWhen the name of the symlink has a specific value, it triggers an associated behavior.
97*22ce4affSfengbojiang- `zstdmt` : compress using all cores available on local system.
98*22ce4affSfengbojiang- `zcat` : will decompress and output target file using any of the supported formats. `gzcat` and `zstdcat` are also equivalent.
99*22ce4affSfengbojiang- `gzip` : if zlib support is enabled, will mimic `gzip` by compressing file using `.gz` format, removing source file by default (use `--keep` to preserve). If zlib is not supported, triggers an error.
100*22ce4affSfengbojiang- `xz` : if lzma support is enabled, will mimic `xz` by compressing file using `.xz` format, removing source file by default (use `--keep` to preserve). If xz is not supported, triggers an error.
101*22ce4affSfengbojiang- `lzma` : if lzma support is enabled, will mimic `lzma` by compressing file using `.lzma` format, removing source file by default (use `--keep` to preserve). If lzma is not supported, triggers an error.
102*22ce4affSfengbojiang- `lz4` : if lz4 support is enabled, will mimic `lz4` by compressing file using `.lz4` format. If lz4 is not supported, triggers an error.
103*22ce4affSfengbojiang- `unzstd` and `unlz4` will decompress any of the supported format.
104*22ce4affSfengbojiang- `ungz`, `unxz` and `unlzma` will do the same, and will also remove source file by default (use `--keep` to preserve).
105*22ce4affSfengbojiang
106*22ce4affSfengbojiang
107*22ce4affSfengbojiang### Dictionary builder in Command Line Interface
108*22ce4affSfengbojiangZstd offers a training mode, which can be used to tune the algorithm for a selected
109*22ce4affSfengbojiangtype of data, by providing it with a few samples. The result of the training is stored
110*22ce4affSfengbojiangin a file selected with the `-o` option (default name is `dictionary`),
111*22ce4affSfengbojiangwhich can be loaded before compression and decompression.
112*22ce4affSfengbojiang
113*22ce4affSfengbojiangUsing a dictionary, the compression ratio achievable on small data improves dramatically.
114*22ce4affSfengbojiangThese compression gains are achieved while simultaneously providing faster compression and decompression speeds.
115*22ce4affSfengbojiangDictionary work if there is some correlation in a family of small data (there is no universal dictionary).
116*22ce4affSfengbojiangHence, deploying one dictionary per type of data will provide the greater benefits.
117*22ce4affSfengbojiangDictionary gains are mostly effective in the first few KB. Then, the compression algorithm
118*22ce4affSfengbojiangwill rely more and more on previously decoded content to compress the rest of the file.
119*22ce4affSfengbojiang
120*22ce4affSfengbojiangUsage of the dictionary builder and created dictionaries with CLI:
121*22ce4affSfengbojiang
122*22ce4affSfengbojiang1. Create the dictionary : `zstd --train PathToTrainingSet/* -o dictionaryName`
123*22ce4affSfengbojiang2. Compress with the dictionary: `zstd FILE -D dictionaryName`
124*22ce4affSfengbojiang3. Decompress with the dictionary: `zstd --decompress FILE.zst -D dictionaryName`
125*22ce4affSfengbojiang
126*22ce4affSfengbojiang
127*22ce4affSfengbojiang### Benchmark in Command Line Interface
128*22ce4affSfengbojiangCLI includes in-memory compression benchmark module for zstd.
129*22ce4affSfengbojiangThe benchmark is conducted using given filenames. The files are read into memory and joined together.
130*22ce4affSfengbojiangIt makes benchmark more precise as it eliminates I/O overhead.
131*22ce4affSfengbojiangMultiple filenames can be supplied, as multiple parameters, with wildcards,
132*22ce4affSfengbojiangor names of directories can be used as parameters with `-r` option.
133*22ce4affSfengbojiang
134*22ce4affSfengbojiangThe benchmark measures ratio, compressed size, compression and decompression speed.
135*22ce4affSfengbojiangOne can select compression levels starting from `-b` and ending with `-e`.
136*22ce4affSfengbojiangThe `-i` parameter selects minimal time used for each of tested levels.
137*22ce4affSfengbojiang
138*22ce4affSfengbojiang
139*22ce4affSfengbojiang### Usage of Command Line Interface
140*22ce4affSfengbojiangThe full list of options can be obtained with `-h` or `-H` parameter:
141*22ce4affSfengbojiang```
142*22ce4affSfengbojiangUsage :
143*22ce4affSfengbojiang      zstd [args] [FILE(s)] [-o file]
144*22ce4affSfengbojiang
145*22ce4affSfengbojiangFILE    : a filename
146*22ce4affSfengbojiang          with no FILE, or when FILE is - , read standard input
147*22ce4affSfengbojiangArguments :
148*22ce4affSfengbojiang -#     : # compression level (1-19, default: 3)
149*22ce4affSfengbojiang -d     : decompression
150*22ce4affSfengbojiang -D DICT: use DICT as Dictionary for compression or decompression
151*22ce4affSfengbojiang -o file: result stored into `file` (only 1 output file)
152*22ce4affSfengbojiang -f     : overwrite output without prompting, also (de)compress links
153*22ce4affSfengbojiang--rm    : remove source file(s) after successful de/compression
154*22ce4affSfengbojiang -k     : preserve source file(s) (default)
155*22ce4affSfengbojiang -h/-H  : display help/long help and exit
156*22ce4affSfengbojiang
157*22ce4affSfengbojiangAdvanced arguments :
158*22ce4affSfengbojiang -V     : display Version number and exit
159*22ce4affSfengbojiang -c     : force write to standard output, even if it is the console
160*22ce4affSfengbojiang -v     : verbose mode; specify multiple times to increase verbosity
161*22ce4affSfengbojiang -q     : suppress warnings; specify twice to suppress errors too
162*22ce4affSfengbojiang--no-progress : do not display the progress counter
163*22ce4affSfengbojiang -r     : operate recursively on directories
164*22ce4affSfengbojiang--filelist FILE : read list of files to operate upon from FILE
165*22ce4affSfengbojiang--output-dir-flat DIR : processed files are stored into DIR
166*22ce4affSfengbojiang--output-dir-mirror DIR : processed files are stored into DIR respecting original directory structure
167*22ce4affSfengbojiang--[no-]check : during compression, add XXH64 integrity checksum to frame (default: enabled). If specified with -d, decompressor will ignore/validate checksums in compressed frame (default: validate).
168*22ce4affSfengbojiang--      : All arguments after "--" are treated as files
169*22ce4affSfengbojiang
170*22ce4affSfengbojiangAdvanced compression arguments :
171*22ce4affSfengbojiang--ultra : enable levels beyond 19, up to 22 (requires more memory)
172*22ce4affSfengbojiang--long[=#]: enable long distance matching with given window log (default: 27)
173*22ce4affSfengbojiang--fast[=#]: switch to very fast compression levels (default: 1)
174*22ce4affSfengbojiang--adapt : dynamically adapt compression level to I/O conditions
175*22ce4affSfengbojiang -T#    : spawns # compression threads (default: 1, 0==# cores)
176*22ce4affSfengbojiang -B#    : select size of each job (default: 0==automatic)
177*22ce4affSfengbojiang--single-thread : use a single thread for both I/O and compression (result slightly different than -T1)
178*22ce4affSfengbojiang--rsyncable : compress using a rsync-friendly method (-B sets block size)
179*22ce4affSfengbojiang--exclude-compressed: only compress files that are not already compressed
180*22ce4affSfengbojiang--stream-size=# : specify size of streaming input from `stdin`
181*22ce4affSfengbojiang--size-hint=# optimize compression parameters for streaming input of approximately this size
182*22ce4affSfengbojiang--target-compressed-block-size=# : generate compressed block of approximately targeted size
183*22ce4affSfengbojiang--no-dictID : don't write dictID into header (dictionary compression only)
184*22ce4affSfengbojiang--[no-]compress-literals : force (un)compressed literals
185*22ce4affSfengbojiang--format=zstd : compress files to the .zst format (default)
186*22ce4affSfengbojiang--format=gzip : compress files to the .gz format
187*22ce4affSfengbojiang--format=xz : compress files to the .xz format
188*22ce4affSfengbojiang--format=lzma : compress files to the .lzma format
189*22ce4affSfengbojiang--format=lz4 : compress files to the .lz4 format
190*22ce4affSfengbojiang
191*22ce4affSfengbojiangAdvanced decompression arguments :
192*22ce4affSfengbojiang -l     : print information about zstd compressed files
193*22ce4affSfengbojiang--test  : test compressed file integrity
194*22ce4affSfengbojiang -M#    : Set a memory usage limit for decompression
195*22ce4affSfengbojiang--[no-]sparse : sparse mode (default: disabled)
196*22ce4affSfengbojiang
197*22ce4affSfengbojiangDictionary builder :
198*22ce4affSfengbojiang--train ## : create a dictionary from a training set of files
199*22ce4affSfengbojiang--train-cover[=k=#,d=#,steps=#,split=#,shrink[=#]] : use the cover algorithm with optional args
200*22ce4affSfengbojiang--train-fastcover[=k=#,d=#,f=#,steps=#,split=#,accel=#,shrink[=#]] : use the fast cover algorithm with optional args
201*22ce4affSfengbojiang--train-legacy[=s=#] : use the legacy algorithm with selectivity (default: 9)
202*22ce4affSfengbojiang -o DICT : DICT is dictionary name (default: dictionary)
203*22ce4affSfengbojiang--maxdict=# : limit dictionary to specified size (default: 112640)
204*22ce4affSfengbojiang--dictID=# : force dictionary ID to specified value (default: random)
205*22ce4affSfengbojiang
206*22ce4affSfengbojiangBenchmark arguments :
207*22ce4affSfengbojiang -b#    : benchmark file(s), using # compression level (default: 3)
208*22ce4affSfengbojiang -e#    : test all compression levels successively from -b# to -e# (default: 1)
209*22ce4affSfengbojiang -i#    : minimum evaluation time in seconds (default: 3s)
210*22ce4affSfengbojiang -B#    : cut file into independent blocks of size # (default: no block)
211*22ce4affSfengbojiang -S     : output one benchmark result per input file (default: consolidated result)
212*22ce4affSfengbojiang--priority=rt : set process priority to real-time
213*22ce4affSfengbojiang```
214*22ce4affSfengbojiang
215*22ce4affSfengbojiang### Passing parameters through Environment Variables
216*22ce4affSfengbojiangThere is no "generic" way to pass "any kind of parameter" to `zstd` in a pass-through manner.
217*22ce4affSfengbojiangUsing environment variables for this purpose has security implications.
218*22ce4affSfengbojiangTherefore, this avenue is intentionally restricted and only supports `ZSTD_CLEVEL` and `ZSTD_NBTHREADS`.
219*22ce4affSfengbojiang
220*22ce4affSfengbojiang`ZSTD_CLEVEL` can be used to modify the default compression level of `zstd`
221*22ce4affSfengbojiang(usually set to `3`) to another value between 1 and 19 (the "normal" range).
222*22ce4affSfengbojiang
223*22ce4affSfengbojiang`ZSTD_NBTHREADS` can be used to specify a number of threads
224*22ce4affSfengbojiangthat `zstd` will use for compression, which by default is `1`.
225*22ce4affSfengbojiangThis functionality only exists when `zstd` is compiled with multithread support.
226*22ce4affSfengbojiang`0` means "use as many threads as detected cpu cores on local system".
227*22ce4affSfengbojiangThe max # of threads is capped at: `ZSTDMT_NBWORKERS_MAX==200`.
228*22ce4affSfengbojiang
229*22ce4affSfengbojiangThis functionality can be useful when `zstd` CLI is invoked in a way that doesn't allow passing arguments.
230*22ce4affSfengbojiangOne such scenario is `tar --zstd`.
231*22ce4affSfengbojiangAs `ZSTD_CLEVEL` and `ZSTD_NBTHREADS` only replace the default compression level
232*22ce4affSfengbojiangand number of threads respectively, they can both be overridden by corresponding command line arguments:
233*22ce4affSfengbojiang`-#` for compression level and `-T#` for number of threads.
234*22ce4affSfengbojiang
235*22ce4affSfengbojiang
236*22ce4affSfengbojiang### Long distance matching mode
237*22ce4affSfengbojiangThe long distance matching mode, enabled with `--long`, is designed to improve
238*22ce4affSfengbojiangthe compression ratio for files with long matches at a large distance (up to the
239*22ce4affSfengbojiangmaximum window size, `128 MiB`) while still maintaining compression speed.
240*22ce4affSfengbojiang
241*22ce4affSfengbojiangEnabling this mode sets the window size to `128 MiB` and thus increases the memory
242*22ce4affSfengbojiangusage for both the compressor and decompressor. Performance in terms of speed is
243*22ce4affSfengbojiangdependent on long matches being found. Compression speed may degrade if few long
244*22ce4affSfengbojiangmatches are found. Decompression speed usually improves when there are many long
245*22ce4affSfengbojiangdistance matches.
246*22ce4affSfengbojiang
247*22ce4affSfengbojiangBelow are graphs comparing the compression speed, compression ratio, and
248*22ce4affSfengbojiangdecompression speed with and without long distance matching on an ideal use
249*22ce4affSfengbojiangcase: a tar of four versions of clang (versions `3.4.1`, `3.4.2`, `3.5.0`,
250*22ce4affSfengbojiang`3.5.1`) with a total size of `244889600 B`. This is an ideal use case as there
251*22ce4affSfengbojiangare many long distance matches within the maximum window size of `128 MiB` (each
252*22ce4affSfengbojiangversion is less than `128 MiB`).
253*22ce4affSfengbojiang
254*22ce4affSfengbojiangCompression Speed vs Ratio | Decompression Speed
255*22ce4affSfengbojiang---------------------------|---------------------
256*22ce4affSfengbojiang![Compression Speed vs Ratio](https://raw.githubusercontent.com/facebook/zstd/v1.3.3/doc/images/ldmCspeed.png "Compression Speed vs Ratio") | ![Decompression Speed](https://raw.githubusercontent.com/facebook/zstd/v1.3.3/doc/images/ldmDspeed.png "Decompression Speed")
257*22ce4affSfengbojiang
258*22ce4affSfengbojiang| Method | Compression ratio | Compression speed | Decompression speed  |
259*22ce4affSfengbojiang|:-------|------------------:|-------------------------:|---------------------------:|
260*22ce4affSfengbojiang| `zstd -1`  | `5.065`    | `284.8 MB/s`  | `759.3 MB/s`  |
261*22ce4affSfengbojiang| `zstd -5`  | `5.826`    | `124.9 MB/s`  | `674.0 MB/s`  |
262*22ce4affSfengbojiang| `zstd -10` | `6.504`    | `29.5 MB/s`   | `771.3 MB/s`  |
263*22ce4affSfengbojiang| `zstd -1 --long` | `17.426` | `220.6 MB/s` | `1638.4 MB/s` |
264*22ce4affSfengbojiang| `zstd -5 --long` | `19.661` | `165.5 MB/s` | `1530.6 MB/s` |
265*22ce4affSfengbojiang| `zstd -10 --long`| `21.949` |  `75.6 MB/s` | `1632.6 MB/s` |
266*22ce4affSfengbojiang
267*22ce4affSfengbojiangOn this file, the compression ratio improves significantly with minimal impact
268*22ce4affSfengbojiangon compression speed, and the decompression speed doubles.
269*22ce4affSfengbojiang
270*22ce4affSfengbojiangOn the other extreme, compressing a file with few long distance matches (such as
271*22ce4affSfengbojiangthe [Silesia compression corpus]) will likely lead to a deterioration in
272*22ce4affSfengbojiangcompression speed (for lower levels) with minimal change in compression ratio.
273*22ce4affSfengbojiang
274*22ce4affSfengbojiangThe below table illustrates this on the [Silesia compression corpus].
275*22ce4affSfengbojiang
276*22ce4affSfengbojiang[Silesia compression corpus]: http://sun.aei.polsl.pl/~sdeor/index.php?page=silesia
277*22ce4affSfengbojiang
278*22ce4affSfengbojiang| Method | Compression ratio | Compression speed | Decompression speed  |
279*22ce4affSfengbojiang|:-------|------------------:|------------------:|---------------------:|
280*22ce4affSfengbojiang| `zstd -1`        | `2.878` | `231.7 MB/s`      | `594.4 MB/s`   |
281*22ce4affSfengbojiang| `zstd -1 --long` | `2.929` | `106.5 MB/s`      | `517.9 MB/s`   |
282*22ce4affSfengbojiang| `zstd -5`        | `3.274` | `77.1 MB/s`       | `464.2 MB/s`   |
283*22ce4affSfengbojiang| `zstd -5 --long` | `3.319` | `51.7 MB/s`       | `371.9 MB/s`   |
284*22ce4affSfengbojiang| `zstd -10`       | `3.523` | `16.4 MB/s`       | `489.2 MB/s`   |
285*22ce4affSfengbojiang| `zstd -10 --long`| `3.566` | `16.2 MB/s`       | `415.7 MB/s`   |
286*22ce4affSfengbojiang
287*22ce4affSfengbojiang
288*22ce4affSfengbojiang### zstdgrep
289*22ce4affSfengbojiang
290*22ce4affSfengbojiang`zstdgrep` is a utility which makes it possible to `grep` directly a `.zst` compressed file.
291*22ce4affSfengbojiangIt's used the same way as normal `grep`, for example :
292*22ce4affSfengbojiang`zstdgrep pattern file.zst`
293*22ce4affSfengbojiang
294*22ce4affSfengbojiang`zstdgrep` is _not_ compatible with dictionary compression.
295*22ce4affSfengbojiang
296*22ce4affSfengbojiangTo search into a file compressed with a dictionary,
297*22ce4affSfengbojiangit's necessary to decompress it using `zstd` or `zstdcat`,
298*22ce4affSfengbojiangand then pipe the result to `grep`. For example  :
299*22ce4affSfengbojiang`zstdcat -D dictionary -qc -- file.zst | grep pattern`
300