xref: /freebsd/sys/contrib/zstd/programs/README.md (revision 5ff13fbc199bdf5f0572845351c68ee5ca828e71)
10c16b537SWarner LoshCommand Line Interface for Zstandard library
20c16b537SWarner Losh============================================
30c16b537SWarner Losh
40c16b537SWarner LoshCommand Line Interface (CLI) can be created using the `make` command without any additional parameters.
50c16b537SWarner LoshThere are however other Makefile targets that create different variations of CLI:
6f7cd7fe5SConrad Meyer- `zstd` : default CLI supporting gzip-like arguments; includes dictionary builder, benchmark, and supports decompression of legacy zstd formats
70c16b537SWarner Losh- `zstd_nolegacy` : Same as `zstd` but without support for legacy zstd formats
80c16b537SWarner Losh- `zstd-small` : CLI optimized for minimal size; no dictionary builder, no benchmark, and no support for legacy zstd formats
90c16b537SWarner Losh- `zstd-compress` : version of CLI which can only compress into zstd format
100c16b537SWarner Losh- `zstd-decompress` : version of CLI which can only decompress zstd format
110c16b537SWarner Losh
120c16b537SWarner Losh
1337f1f268SConrad Meyer### Compilation variables
1419fcbaf1SConrad Meyer`zstd` scope can be altered by modifying the following `make` variables :
150c16b537SWarner Losh
160c16b537SWarner Losh- __HAVE_THREAD__ : multithreading is automatically enabled when `pthread` is detected.
1719fcbaf1SConrad Meyer  It's possible to disable multithread support, by setting `HAVE_THREAD=0`.
1819fcbaf1SConrad Meyer  Example : `make zstd HAVE_THREAD=0`
1919fcbaf1SConrad Meyer  It's also possible to force multithread support, using `HAVE_THREAD=1`.
2019fcbaf1SConrad Meyer  In which case, linking stage will fail if neither `pthread` nor `windows.h` library can be found.
2119fcbaf1SConrad Meyer  This is useful to ensure this feature is not silently disabled.
220c16b537SWarner Losh
230c16b537SWarner Losh- __ZSTD_LEGACY_SUPPORT__ : `zstd` can decompress files compressed by older versions of `zstd`.
240c16b537SWarner Losh  Starting v0.8.0, all versions of `zstd` produce frames compliant with the [specification](../doc/zstd_compression_format.md), and are therefore compatible.
250c16b537SWarner Losh  But older versions (< v0.8.0) produced different, incompatible, frames.
260c16b537SWarner Losh  By default, `zstd` supports decoding legacy formats >= v0.4.0 (`ZSTD_LEGACY_SUPPORT=4`).
270c16b537SWarner Losh  This can be altered by modifying this compilation variable.
280c16b537SWarner Losh  `ZSTD_LEGACY_SUPPORT=1` means "support all formats >= v0.1.0".
290c16b537SWarner Losh  `ZSTD_LEGACY_SUPPORT=2` means "support all formats >= v0.2.0", and so on.
300c16b537SWarner Losh  `ZSTD_LEGACY_SUPPORT=0` means _DO NOT_ support any legacy format.
310c16b537SWarner Losh  if `ZSTD_LEGACY_SUPPORT >= 8`, it's the same as `0`, since there is no legacy format after `7`.
320c16b537SWarner Losh  Note : `zstd` only supports decoding older formats, and cannot generate any legacy format.
330c16b537SWarner Losh
3419fcbaf1SConrad Meyer- __HAVE_ZLIB__ : `zstd` can compress and decompress files in `.gz` format.
3519fcbaf1SConrad Meyer  This is ordered through command `--format=gzip`.
3619fcbaf1SConrad Meyer  Alternatively, symlinks named `gzip` or `gunzip` will mimic intended behavior.
3719fcbaf1SConrad Meyer  `.gz` support is automatically enabled when `zlib` library is detected at build time.
3819fcbaf1SConrad Meyer  It's possible to disable `.gz` support, by setting `HAVE_ZLIB=0`.
3919fcbaf1SConrad Meyer  Example : `make zstd HAVE_ZLIB=0`
404d3f1eafSConrad Meyer  It's also possible to force compilation with zlib support, using `HAVE_ZLIB=1`.
4119fcbaf1SConrad Meyer  In which case, linking stage will fail if `zlib` library cannot be found.
4219fcbaf1SConrad Meyer  This is useful to prevent silent feature disabling.
4319fcbaf1SConrad Meyer
4419fcbaf1SConrad Meyer- __HAVE_LZMA__ : `zstd` can compress and decompress files in `.xz` and `.lzma` formats.
4519fcbaf1SConrad Meyer  This is ordered through commands `--format=xz` and `--format=lzma` respectively.
4619fcbaf1SConrad Meyer  Alternatively, symlinks named `xz`, `unxz`, `lzma`, or `unlzma` will mimic intended behavior.
4719fcbaf1SConrad Meyer  `.xz` and `.lzma` support is automatically enabled when `lzma` library is detected at build time.
4819fcbaf1SConrad Meyer  It's possible to disable `.xz` and `.lzma` support, by setting `HAVE_LZMA=0`.
4919fcbaf1SConrad Meyer  Example : `make zstd HAVE_LZMA=0`
5019fcbaf1SConrad Meyer  It's also possible to force compilation with lzma support, using `HAVE_LZMA=1`.
5119fcbaf1SConrad Meyer  In which case, linking stage will fail if `lzma` library cannot be found.
5219fcbaf1SConrad Meyer  This is useful to prevent silent feature disabling.
5319fcbaf1SConrad Meyer
5419fcbaf1SConrad Meyer- __HAVE_LZ4__ : `zstd` can compress and decompress files in `.lz4` formats.
5519fcbaf1SConrad Meyer  This is ordered through commands `--format=lz4`.
5619fcbaf1SConrad Meyer  Alternatively, symlinks named `lz4`, or `unlz4` will mimic intended behavior.
5719fcbaf1SConrad Meyer  `.lz4` support is automatically enabled when `lz4` library is detected at build time.
5819fcbaf1SConrad Meyer  It's possible to disable `.lz4` support, by setting `HAVE_LZ4=0` .
5919fcbaf1SConrad Meyer  Example : `make zstd HAVE_LZ4=0`
6019fcbaf1SConrad Meyer  It's also possible to force compilation with lz4 support, using `HAVE_LZ4=1`.
6119fcbaf1SConrad Meyer  In which case, linking stage will fail if `lz4` library cannot be found.
6219fcbaf1SConrad Meyer  This is useful to prevent silent feature disabling.
6319fcbaf1SConrad Meyer
6437f1f268SConrad Meyer- __ZSTD_NOBENCH__ : `zstd` cli will be compiled without its integrated benchmark module.
6537f1f268SConrad Meyer  This can be useful to produce smaller binaries.
6637f1f268SConrad Meyer  In this case, the corresponding unit can also be excluded from compilation target.
6737f1f268SConrad Meyer
6837f1f268SConrad Meyer- __ZSTD_NODICT__ : `zstd` cli will be compiled without support for the integrated dictionary builder.
6937f1f268SConrad Meyer  This can be useful to produce smaller binaries.
7037f1f268SConrad Meyer  In this case, the corresponding unit can also be excluded from compilation target.
7137f1f268SConrad Meyer
7237f1f268SConrad Meyer- __ZSTD_NOCOMPRESS__ : `zstd` cli will be compiled without support for compression.
7337f1f268SConrad Meyer  The resulting binary will only be able to decompress files.
7437f1f268SConrad Meyer  This can be useful to produce smaller binaries.
7537f1f268SConrad Meyer  A corresponding `Makefile` target using this ability is `zstd-decompress`.
7637f1f268SConrad Meyer
7737f1f268SConrad Meyer- __ZSTD_NODECOMPRESS__ : `zstd` cli will be compiled without support for decompression.
7837f1f268SConrad Meyer  The resulting binary will only be able to compress files.
7937f1f268SConrad Meyer  This can be useful to produce smaller binaries.
8037f1f268SConrad Meyer  A corresponding `Makefile` target using this ability is `zstd-compress`.
8137f1f268SConrad Meyer
820f743729SConrad Meyer- __BACKTRACE__ : `zstd` can display a stack backtrace when execution
830f743729SConrad Meyer  generates a runtime exception. By default, this feature may be
840f743729SConrad Meyer  degraded/disabled on some platforms unless additional compiler directives are
850f743729SConrad Meyer  applied. When triaging a runtime issue, enabling this feature can provide
860f743729SConrad Meyer  more context to determine the location of the fault.
870f743729SConrad Meyer  Example : `make zstd BACKTRACE=1`
880f743729SConrad Meyer
890c16b537SWarner Losh
9037f1f268SConrad Meyer### Aggregation of parameters
910c16b537SWarner LoshCLI supports aggregation of parameters i.e. `-b1`, `-e18`, and `-i1` can be joined into `-b1e18i1`.
920c16b537SWarner Losh
930c16b537SWarner Losh
9437f1f268SConrad Meyer### Symlink shortcuts
9519fcbaf1SConrad MeyerIt's possible to invoke `zstd` through a symlink.
9619fcbaf1SConrad MeyerWhen the name of the symlink has a specific value, it triggers an associated behavior.
9719fcbaf1SConrad Meyer- `zstdmt` : compress using all cores available on local system.
9819fcbaf1SConrad Meyer- `zcat` : will decompress and output target file using any of the supported formats. `gzcat` and `zstdcat` are also equivalent.
9919fcbaf1SConrad Meyer- `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.
10019fcbaf1SConrad Meyer- `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.
10119fcbaf1SConrad Meyer- `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.
10219fcbaf1SConrad Meyer- `lz4` : if lz4 support is enabled, will mimic `lz4` by compressing file using `.lz4` format. If lz4 is not supported, triggers an error.
10319fcbaf1SConrad Meyer- `unzstd` and `unlz4` will decompress any of the supported format.
10419fcbaf1SConrad Meyer- `ungz`, `unxz` and `unlzma` will do the same, and will also remove source file by default (use `--keep` to preserve).
10519fcbaf1SConrad Meyer
10619fcbaf1SConrad Meyer
10737f1f268SConrad Meyer### Dictionary builder in Command Line Interface
1080c16b537SWarner LoshZstd offers a training mode, which can be used to tune the algorithm for a selected
1090c16b537SWarner Loshtype of data, by providing it with a few samples. The result of the training is stored
1100c16b537SWarner Loshin a file selected with the `-o` option (default name is `dictionary`),
1110c16b537SWarner Loshwhich can be loaded before compression and decompression.
1120c16b537SWarner Losh
1130c16b537SWarner LoshUsing a dictionary, the compression ratio achievable on small data improves dramatically.
1140c16b537SWarner LoshThese compression gains are achieved while simultaneously providing faster compression and decompression speeds.
1150c16b537SWarner LoshDictionary work if there is some correlation in a family of small data (there is no universal dictionary).
1160c16b537SWarner LoshHence, deploying one dictionary per type of data will provide the greater benefits.
1170c16b537SWarner LoshDictionary gains are mostly effective in the first few KB. Then, the compression algorithm
1180c16b537SWarner Loshwill rely more and more on previously decoded content to compress the rest of the file.
1190c16b537SWarner Losh
1200c16b537SWarner LoshUsage of the dictionary builder and created dictionaries with CLI:
1210c16b537SWarner Losh
1220c16b537SWarner Losh1. Create the dictionary : `zstd --train PathToTrainingSet/* -o dictionaryName`
1230c16b537SWarner Losh2. Compress with the dictionary: `zstd FILE -D dictionaryName`
1240c16b537SWarner Losh3. Decompress with the dictionary: `zstd --decompress FILE.zst -D dictionaryName`
1250c16b537SWarner Losh
1260c16b537SWarner Losh
12737f1f268SConrad Meyer### Benchmark in Command Line Interface
1280c16b537SWarner LoshCLI includes in-memory compression benchmark module for zstd.
1290c16b537SWarner LoshThe benchmark is conducted using given filenames. The files are read into memory and joined together.
1300c16b537SWarner LoshIt makes benchmark more precise as it eliminates I/O overhead.
1310c16b537SWarner LoshMultiple filenames can be supplied, as multiple parameters, with wildcards,
1320c16b537SWarner Loshor names of directories can be used as parameters with `-r` option.
1330c16b537SWarner Losh
1340c16b537SWarner LoshThe benchmark measures ratio, compressed size, compression and decompression speed.
1350c16b537SWarner LoshOne can select compression levels starting from `-b` and ending with `-e`.
1360c16b537SWarner LoshThe `-i` parameter selects minimal time used for each of tested levels.
1370c16b537SWarner Losh
1380c16b537SWarner Losh
13937f1f268SConrad Meyer### Usage of Command Line Interface
1400c16b537SWarner LoshThe full list of options can be obtained with `-h` or `-H` parameter:
1410c16b537SWarner Losh```
1420c16b537SWarner LoshUsage :
1430c16b537SWarner Losh      zstd [args] [FILE(s)] [-o file]
1440c16b537SWarner Losh
1450c16b537SWarner LoshFILE    : a filename
1460c16b537SWarner Losh          with no FILE, or when FILE is - , read standard input
1470c16b537SWarner LoshArguments :
1480c16b537SWarner Losh -#     : # compression level (1-19, default: 3)
1490c16b537SWarner Losh -d     : decompression
150f7cd7fe5SConrad Meyer -D DICT: use DICT as Dictionary for compression or decompression
151f7cd7fe5SConrad Meyer -o file: result stored into `file` (only 1 output file)
152f7cd7fe5SConrad Meyer -f     : overwrite output without prompting, also (de)compress links
1530c16b537SWarner Losh--rm    : remove source file(s) after successful de/compression
1540c16b537SWarner Losh -k     : preserve source file(s) (default)
1550c16b537SWarner Losh -h/-H  : display help/long help and exit
1560c16b537SWarner Losh
1570c16b537SWarner LoshAdvanced arguments :
1580c16b537SWarner Losh -V     : display Version number and exit
159*5ff13fbcSAllan Jude -c     : write to standard output (even if it is the console)
1600c16b537SWarner Losh -v     : verbose mode; specify multiple times to increase verbosity
1610c16b537SWarner Losh -q     : suppress warnings; specify twice to suppress errors too
162f7cd7fe5SConrad Meyer--no-progress : do not display the progress counter
163f7cd7fe5SConrad Meyer -r     : operate recursively on directories
164f7cd7fe5SConrad Meyer--filelist FILE : read list of files to operate upon from FILE
165f7cd7fe5SConrad Meyer--output-dir-flat DIR : processed files are stored into DIR
166f7cd7fe5SConrad Meyer--output-dir-mirror DIR : processed files are stored into DIR respecting original directory structure
167f7cd7fe5SConrad Meyer--[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).
168f7cd7fe5SConrad Meyer--      : All arguments after "--" are treated as files
169f7cd7fe5SConrad Meyer
170f7cd7fe5SConrad MeyerAdvanced compression arguments :
1710c16b537SWarner Losh--ultra : enable levels beyond 19, up to 22 (requires more memory)
17237f1f268SConrad Meyer--long[=#]: enable long distance matching with given window log (default: 27)
17337f1f268SConrad Meyer--fast[=#]: switch to very fast compression levels (default: 1)
17437f1f268SConrad Meyer--adapt : dynamically adapt compression level to I/O conditions
175*5ff13fbcSAllan Jude--patch-from=FILE : specify the file to be used as a reference point for zstd's diff engine
17637f1f268SConrad Meyer -T#    : spawns # compression threads (default: 1, 0==# cores)
17737f1f268SConrad Meyer -B#    : select size of each job (default: 0==automatic)
178f7cd7fe5SConrad Meyer--single-thread : use a single thread for both I/O and compression (result slightly different than -T1)
17937f1f268SConrad Meyer--rsyncable : compress using a rsync-friendly method (-B sets block size)
180f7cd7fe5SConrad Meyer--exclude-compressed: only compress files that are not already compressed
181f7cd7fe5SConrad Meyer--stream-size=# : specify size of streaming input from `stdin`
182f7cd7fe5SConrad Meyer--size-hint=# optimize compression parameters for streaming input of approximately this size
183f7cd7fe5SConrad Meyer--target-compressed-block-size=# : generate compressed block of approximately targeted size
184f7cd7fe5SConrad Meyer--no-dictID : don't write dictID into header (dictionary compression only)
18537f1f268SConrad Meyer--[no-]compress-literals : force (un)compressed literals
18637f1f268SConrad Meyer--format=zstd : compress files to the .zst format (default)
1870c16b537SWarner Losh--format=gzip : compress files to the .gz format
188f7cd7fe5SConrad Meyer--format=xz : compress files to the .xz format
189f7cd7fe5SConrad Meyer--format=lzma : compress files to the .lzma format
190f7cd7fe5SConrad Meyer--format=lz4 : compress files to the .lz4 format
191f7cd7fe5SConrad Meyer
192f7cd7fe5SConrad MeyerAdvanced decompression arguments :
193f7cd7fe5SConrad Meyer -l     : print information about zstd compressed files
1940c16b537SWarner Losh--test  : test compressed file integrity
1950c16b537SWarner Losh -M#    : Set a memory usage limit for decompression
196f7cd7fe5SConrad Meyer--[no-]sparse : sparse mode (default: disabled)
1970c16b537SWarner Losh
1980c16b537SWarner LoshDictionary builder :
1990c16b537SWarner Losh--train ## : create a dictionary from a training set of files
2004d3f1eafSConrad Meyer--train-cover[=k=#,d=#,steps=#,split=#,shrink[=#]] : use the cover algorithm with optional args
20137f1f268SConrad Meyer--train-fastcover[=k=#,d=#,f=#,steps=#,split=#,accel=#,shrink[=#]] : use the fast cover algorithm with optional args
2020c16b537SWarner Losh--train-legacy[=s=#] : use the legacy algorithm with selectivity (default: 9)
203f7cd7fe5SConrad Meyer -o DICT : DICT is dictionary name (default: dictionary)
2040c16b537SWarner Losh--maxdict=# : limit dictionary to specified size (default: 112640)
2050c16b537SWarner Losh--dictID=# : force dictionary ID to specified value (default: random)
2060c16b537SWarner Losh
2070c16b537SWarner LoshBenchmark arguments :
20819fcbaf1SConrad Meyer -b#    : benchmark file(s), using # compression level (default: 3)
209f7cd7fe5SConrad Meyer -e#    : test all compression levels successively from -b# to -e# (default: 1)
2100c16b537SWarner Losh -i#    : minimum evaluation time in seconds (default: 3s)
2110c16b537SWarner Losh -B#    : cut file into independent blocks of size # (default: no block)
212f7cd7fe5SConrad Meyer -S     : output one benchmark result per input file (default: consolidated result)
2130c16b537SWarner Losh--priority=rt : set process priority to real-time
2140c16b537SWarner Losh```
2150c16b537SWarner Losh
21637f1f268SConrad Meyer### Passing parameters through Environment Variables
21737f1f268SConrad MeyerThere is no "generic" way to pass "any kind of parameter" to `zstd` in a pass-through manner.
21837f1f268SConrad MeyerUsing environment variables for this purpose has security implications.
219f7cd7fe5SConrad MeyerTherefore, this avenue is intentionally restricted and only supports `ZSTD_CLEVEL` and `ZSTD_NBTHREADS`.
220f7cd7fe5SConrad Meyer
221f7cd7fe5SConrad Meyer`ZSTD_CLEVEL` can be used to modify the default compression level of `zstd`
222f7cd7fe5SConrad Meyer(usually set to `3`) to another value between 1 and 19 (the "normal" range).
223f7cd7fe5SConrad Meyer
224f7cd7fe5SConrad Meyer`ZSTD_NBTHREADS` can be used to specify a number of threads
225f7cd7fe5SConrad Meyerthat `zstd` will use for compression, which by default is `1`.
226f7cd7fe5SConrad MeyerThis functionality only exists when `zstd` is compiled with multithread support.
227f7cd7fe5SConrad Meyer`0` means "use as many threads as detected cpu cores on local system".
228*5ff13fbcSAllan JudeThe max # of threads is capped at `ZSTDMT_NBWORKERS_MAX`,
229*5ff13fbcSAllan Judewhich is either 64 in 32-bit mode, or 256 for 64-bit environments.
230f7cd7fe5SConrad Meyer
231f7cd7fe5SConrad MeyerThis functionality can be useful when `zstd` CLI is invoked in a way that doesn't allow passing arguments.
232f7cd7fe5SConrad MeyerOne such scenario is `tar --zstd`.
233f7cd7fe5SConrad MeyerAs `ZSTD_CLEVEL` and `ZSTD_NBTHREADS` only replace the default compression level
234f7cd7fe5SConrad Meyerand number of threads respectively, they can both be overridden by corresponding command line arguments:
235f7cd7fe5SConrad Meyer`-#` for compression level and `-T#` for number of threads.
236f7cd7fe5SConrad Meyer
23737f1f268SConrad Meyer
23837f1f268SConrad Meyer### Long distance matching mode
2390c16b537SWarner LoshThe long distance matching mode, enabled with `--long`, is designed to improve
2400c16b537SWarner Loshthe compression ratio for files with long matches at a large distance (up to the
2410c16b537SWarner Loshmaximum window size, `128 MiB`) while still maintaining compression speed.
2420c16b537SWarner Losh
2430c16b537SWarner LoshEnabling this mode sets the window size to `128 MiB` and thus increases the memory
2440c16b537SWarner Loshusage for both the compressor and decompressor. Performance in terms of speed is
2450c16b537SWarner Loshdependent on long matches being found. Compression speed may degrade if few long
2460c16b537SWarner Loshmatches are found. Decompression speed usually improves when there are many long
2470c16b537SWarner Loshdistance matches.
2480c16b537SWarner Losh
2490c16b537SWarner LoshBelow are graphs comparing the compression speed, compression ratio, and
2500c16b537SWarner Loshdecompression speed with and without long distance matching on an ideal use
2510c16b537SWarner Loshcase: a tar of four versions of clang (versions `3.4.1`, `3.4.2`, `3.5.0`,
2520c16b537SWarner Losh`3.5.1`) with a total size of `244889600 B`. This is an ideal use case as there
2530c16b537SWarner Loshare many long distance matches within the maximum window size of `128 MiB` (each
2540c16b537SWarner Loshversion is less than `128 MiB`).
2550c16b537SWarner Losh
2560c16b537SWarner LoshCompression Speed vs Ratio | Decompression Speed
2570c16b537SWarner Losh---------------------------|---------------------
2580f743729SConrad Meyer![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")
2590c16b537SWarner Losh
2600c16b537SWarner Losh| Method | Compression ratio | Compression speed | Decompression speed  |
2610c16b537SWarner Losh|:-------|------------------:|-------------------------:|---------------------------:|
2620c16b537SWarner Losh| `zstd -1`  | `5.065`    | `284.8 MB/s`  | `759.3 MB/s`  |
2630c16b537SWarner Losh| `zstd -5`  | `5.826`    | `124.9 MB/s`  | `674.0 MB/s`  |
2640c16b537SWarner Losh| `zstd -10` | `6.504`    | `29.5 MB/s`   | `771.3 MB/s`  |
2650c16b537SWarner Losh| `zstd -1 --long` | `17.426` | `220.6 MB/s` | `1638.4 MB/s` |
2660c16b537SWarner Losh| `zstd -5 --long` | `19.661` | `165.5 MB/s` | `1530.6 MB/s` |
2670c16b537SWarner Losh| `zstd -10 --long`| `21.949` |  `75.6 MB/s` | `1632.6 MB/s` |
2680c16b537SWarner Losh
2690c16b537SWarner LoshOn this file, the compression ratio improves significantly with minimal impact
2700c16b537SWarner Loshon compression speed, and the decompression speed doubles.
2710c16b537SWarner Losh
2720c16b537SWarner LoshOn the other extreme, compressing a file with few long distance matches (such as
2730c16b537SWarner Loshthe [Silesia compression corpus]) will likely lead to a deterioration in
2740c16b537SWarner Loshcompression speed (for lower levels) with minimal change in compression ratio.
2750c16b537SWarner Losh
2760c16b537SWarner LoshThe below table illustrates this on the [Silesia compression corpus].
2770c16b537SWarner Losh
2780c16b537SWarner Losh[Silesia compression corpus]: http://sun.aei.polsl.pl/~sdeor/index.php?page=silesia
2790c16b537SWarner Losh
2800c16b537SWarner Losh| Method | Compression ratio | Compression speed | Decompression speed  |
2810f743729SConrad Meyer|:-------|------------------:|------------------:|---------------------:|
2820c16b537SWarner Losh| `zstd -1`        | `2.878` | `231.7 MB/s`      | `594.4 MB/s`   |
2830c16b537SWarner Losh| `zstd -1 --long` | `2.929` | `106.5 MB/s`      | `517.9 MB/s`   |
2840c16b537SWarner Losh| `zstd -5`        | `3.274` | `77.1 MB/s`       | `464.2 MB/s`   |
2850c16b537SWarner Losh| `zstd -5 --long` | `3.319` | `51.7 MB/s`       | `371.9 MB/s`   |
2860c16b537SWarner Losh| `zstd -10`       | `3.523` | `16.4 MB/s`       | `489.2 MB/s`   |
2870c16b537SWarner Losh| `zstd -10 --long`| `3.566` | `16.2 MB/s`       | `415.7 MB/s`   |
2880f743729SConrad Meyer
2890f743729SConrad Meyer
29037f1f268SConrad Meyer### zstdgrep
2910f743729SConrad Meyer
2920f743729SConrad Meyer`zstdgrep` is a utility which makes it possible to `grep` directly a `.zst` compressed file.
2930f743729SConrad MeyerIt's used the same way as normal `grep`, for example :
2940f743729SConrad Meyer`zstdgrep pattern file.zst`
2950f743729SConrad Meyer
2960f743729SConrad Meyer`zstdgrep` is _not_ compatible with dictionary compression.
2970f743729SConrad Meyer
2980f743729SConrad MeyerTo search into a file compressed with a dictionary,
2990f743729SConrad Meyerit's necessary to decompress it using `zstd` or `zstdcat`,
3000f743729SConrad Meyerand then pipe the result to `grep`. For example  :
3010f743729SConrad Meyer`zstdcat -D dictionary -qc -- file.zst | grep pattern`
302