Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 1 | .TH "ZSTD" "1" "March 2023" "zstd 1.5.5" "User Commands" |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 2 | .SH "NAME" |
Sean Purcell | 5935c99 | 2017-04-17 16:05:20 -0700 | [diff] [blame] | 3 | \fBzstd\fR \- zstd, zstdmt, unzstd, zstdcat \- Compress or decompress \.zst files |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 4 | .SH "SYNOPSIS" |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 5 | .TS |
| 6 | allbox; |
| 7 | \fBzstd\fR [\fIOPTIONS\fR] [\- \fIINPUT\-FILE\fR] [\-o \fIOUTPUT\-FILE\fR] |
| 8 | .TE |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 9 | .P |
Sean Purcell | 5935c99 | 2017-04-17 16:05:20 -0700 | [diff] [blame] | 10 | \fBzstdmt\fR is equivalent to \fBzstd \-T0\fR |
Sean Purcell | 5935c99 | 2017-04-17 16:05:20 -0700 | [diff] [blame] | 11 | .P |
Yann Collet | 0a189b6 | 2017-03-16 16:33:53 -0700 | [diff] [blame] | 12 | \fBunzstd\fR is equivalent to \fBzstd \-d\fR |
Yann Collet | 0a189b6 | 2017-03-16 16:33:53 -0700 | [diff] [blame] | 13 | .P |
| 14 | \fBzstdcat\fR is equivalent to \fBzstd \-dcf\fR |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 15 | .SH "DESCRIPTION" |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 16 | \fBzstd\fR is a fast lossless compression algorithm and data compression tool, with command line syntax similar to \fBgzip\fR(1) and \fBxz\fR(1)\. It is based on the \fBLZ77\fR family, with further FSE & huff0 entropy stages\. \fBzstd\fR offers highly configurable compression speed, from fast modes at > 200 MB/s per core, to strong modes with excellent compression ratios\. It also features a very fast decoder, with speeds > 500 MB/s per core\. |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 17 | .P |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 18 | \fBzstd\fR command line syntax is generally similar to gzip, but features the following differences: |
| 19 | .IP "\[ci]" 4 |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 20 | Source files are preserved by default\. It\'s possible to remove them automatically by using the \fB\-\-rm\fR command\. |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 21 | .IP "\[ci]" 4 |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 22 | When compressing a single file, \fBzstd\fR displays progress notifications and result summary by default\. Use \fB\-q\fR to turn them off\. |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 23 | .IP "\[ci]" 4 |
Yann Collet | 0a189b6 | 2017-03-16 16:33:53 -0700 | [diff] [blame] | 24 | \fBzstd\fR displays a short help page when command line is an error\. Use \fB\-q\fR to turn it off\. |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 25 | .IP "\[ci]" 4 |
| 26 | \fBzstd\fR does not accept input from console, though it does accept \fBstdin\fR when it\'s not the console\. |
| 27 | .IP "\[ci]" 4 |
| 28 | \fBzstd\fR does not store the input\'s filename or attributes, only its contents\. |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 29 | .IP "" 0 |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 30 | .P |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 31 | \fBzstd\fR processes each \fIfile\fR according to the selected operation mode\. If no \fIfiles\fR are given or \fIfile\fR is \fB\-\fR, \fBzstd\fR reads from standard input and writes the processed data to standard output\. \fBzstd\fR will refuse to write compressed data to standard output if it is a terminal: it will display an error message and skip the file\. Similarly, \fBzstd\fR will refuse to read compressed data from standard input if it is a terminal\. |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 32 | .P |
| 33 | Unless \fB\-\-stdout\fR or \fB\-o\fR is specified, \fIfiles\fR are written to a new file whose name is derived from the source \fIfile\fR name: |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 34 | .IP "\[ci]" 4 |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 35 | When compressing, the suffix \fB\.zst\fR is appended to the source filename to get the target filename\. |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 36 | .IP "\[ci]" 4 |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 37 | When decompressing, the \fB\.zst\fR suffix is removed from the source filename to get the target filename |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 38 | .IP "" 0 |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 39 | .SS "Concatenation with \.zst Files" |
| 40 | It is possible to concatenate multiple \fB\.zst\fR files\. \fBzstd\fR will decompress such agglomerated file as if it was a single \fB\.zst\fR file\. |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 41 | .SH "OPTIONS" |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 42 | .SS "Integer Suffixes and Special Values" |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 43 | In most places where an integer argument is expected, an optional suffix is supported to easily indicate large integers\. There must be no space between the integer and the suffix\. |
Yann Collet | 22de81e | 2016-10-28 13:58:31 -0700 | [diff] [blame] | 44 | .TP |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 45 | \fBKiB\fR |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 46 | Multiply the integer by 1,024 (2\e^10)\. \fBKi\fR, \fBK\fR, and \fBKB\fR are accepted as synonyms for \fBKiB\fR\. |
Yann Collet | 22de81e | 2016-10-28 13:58:31 -0700 | [diff] [blame] | 47 | .TP |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 48 | \fBMiB\fR |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 49 | Multiply the integer by 1,048,576 (2\e^20)\. \fBMi\fR, \fBM\fR, and \fBMB\fR are accepted as synonyms for \fBMiB\fR\. |
| 50 | .SS "Operation Mode" |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 51 | If multiple operation mode options are given, the last one takes effect\. |
Yann Collet | 22de81e | 2016-10-28 13:58:31 -0700 | [diff] [blame] | 52 | .TP |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 53 | \fB\-z\fR, \fB\-\-compress\fR |
| 54 | Compress\. This is the default operation mode when no operation mode option is specified and no other operation mode is implied from the command name (for example, \fBunzstd\fR implies \fB\-\-decompress\fR)\. |
Yann Collet | 22de81e | 2016-10-28 13:58:31 -0700 | [diff] [blame] | 55 | .TP |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 56 | \fB\-d\fR, \fB\-\-decompress\fR, \fB\-\-uncompress\fR |
| 57 | Decompress\. |
Yann Collet | 22de81e | 2016-10-28 13:58:31 -0700 | [diff] [blame] | 58 | .TP |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 59 | \fB\-t\fR, \fB\-\-test\fR |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 60 | Test the integrity of compressed \fIfiles\fR\. This option is equivalent to \fB\-\-decompress \-\-stdout > /dev/null\fR, decompressed data is discarded and checksummed for errors\. No files are created or removed\. |
Yann Collet | 22de81e | 2016-10-28 13:58:31 -0700 | [diff] [blame] | 61 | .TP |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 62 | \fB\-b#\fR |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 63 | Benchmark file(s) using compression level \fI#\fR\. See \fIBENCHMARK\fR below for a description of this operation\. |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 64 | .TP |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 65 | \fB\-\-train FILES\fR |
| 66 | Use \fIFILES\fR as a training set to create a dictionary\. The training set should contain a lot of small files (> 100)\. See \fIDICTIONARY BUILDER\fR below for a description of this operation\. |
Yann Collet | 2d08b09 | 2016-02-16 14:42:08 +0100 | [diff] [blame] | 67 | .TP |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 68 | \fB\-l\fR, \fB\-\-list\fR |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 69 | Display information related to a zstd compressed file, such as size, ratio, and checksum\. Some of these fields may not be available\. This command\'s output can be augmented with the \fB\-v\fR modifier\. |
| 70 | .SS "Operation Modifiers" |
| 71 | .IP "\[ci]" 4 |
| 72 | \fB\-#\fR: selects \fB#\fR compression level [1\-19] (default: 3) |
| 73 | .IP "\[ci]" 4 |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 74 | \fB\-\-ultra\fR: unlocks high compression levels 20+ (maximum 22), using a lot more memory\. Note that decompression will also require more memory when using these levels\. |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 75 | .IP "\[ci]" 4 |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 76 | \fB\-\-fast[=#]\fR: switch to ultra\-fast compression levels\. If \fB=#\fR is not present, it defaults to \fB1\fR\. The higher the value, the faster the compression speed, at the cost of some compression ratio\. This setting overwrites compression level if one was set previously\. Similarly, if a compression level is set after \fB\-\-fast\fR, it overrides it\. |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 77 | .IP "\[ci]" 4 |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 78 | \fB\-T#\fR, \fB\-\-threads=#\fR: Compress using \fB#\fR working threads (default: 1)\. If \fB#\fR is 0, attempt to detect and use the number of physical CPU cores\. In all cases, the nb of threads is capped to \fBZSTDMT_NBWORKERS_MAX\fR, which is either 64 in 32\-bit mode, or 256 for 64\-bit environments\. This modifier does nothing if \fBzstd\fR is compiled without multithread support\. |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 79 | .IP "\[ci]" 4 |
| 80 | \fB\-\-single\-thread\fR: Use a single thread for both I/O and compression\. As compression is serialized with I/O, this can be slightly slower\. Single\-thread mode features significantly lower memory usage, which can be useful for systems with limited amount of memory, such as 32\-bit systems\. |
| 81 | .IP |
| 82 | Note 1: this mode is the only available one when multithread support is disabled\. |
| 83 | .IP |
| 84 | Note 2: this mode is different from \fB\-T1\fR, which spawns 1 compression thread in parallel with I/O\. Final compressed result is also slightly different from \fB\-T1\fR\. |
| 85 | .IP "\[ci]" 4 |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 86 | \fB\-\-auto\-threads={physical,logical} (default: physical)\fR: When using a default amount of threads via \fB\-T0\fR, choose the default based on the number of detected physical or logical cores\. |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 87 | .IP "\[ci]" 4 |
| 88 | \fB\-\-adapt[=min=#,max=#]\fR: \fBzstd\fR will dynamically adapt compression level to perceived I/O conditions\. Compression level adaptation can be observed live by using command \fB\-v\fR\. Adaptation can be constrained between supplied \fBmin\fR and \fBmax\fR levels\. The feature works when combined with multi\-threading and \fB\-\-long\fR mode\. It does not work with \fB\-\-single\-thread\fR\. It sets window size to 8 MiB by default (can be changed manually, see \fBwlog\fR)\. Due to the chaotic nature of dynamic adaptation, compressed result is not reproducible\. |
| 89 | .IP |
| 90 | \fINote\fR: at the time of this writing, \fB\-\-adapt\fR can remain stuck at low speed when combined with multiple worker threads (>=2)\. |
| 91 | .IP "\[ci]" 4 |
| 92 | \fB\-\-long[=#]\fR: enables long distance matching with \fB#\fR \fBwindowLog\fR, if \fB#\fR is not present it defaults to \fB27\fR\. This increases the window size (\fBwindowLog\fR) and memory usage for both the compressor and decompressor\. This setting is designed to improve the compression ratio for files with long matches at a large distance\. |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 93 | .IP |
| 94 | Note: If \fBwindowLog\fR is set to larger than 27, \fB\-\-long=windowLog\fR or \fB\-\-memory=windowSize\fR needs to be passed to the decompressor\. |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 95 | .IP "\[ci]" 4 |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 96 | \fB\-D DICT\fR: use \fBDICT\fR as Dictionary to compress or decompress FILE(s) |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 97 | .IP "\[ci]" 4 |
| 98 | \fB\-\-patch\-from FILE\fR: Specify the file to be used as a reference point for zstd\'s diff engine\. This is effectively dictionary compression with some convenient parameter selection, namely that \fIwindowSize\fR > \fIsrcSize\fR\. |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 99 | .IP |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 100 | Note: cannot use both this and \fB\-D\fR together\. |
| 101 | .IP |
| 102 | Note: \fB\-\-long\fR mode will be automatically activated if \fIchainLog\fR < \fIfileLog\fR (\fIfileLog\fR being the \fIwindowLog\fR required to cover the whole file)\. You can also manually force it\. |
| 103 | .IP |
| 104 | Note: for all levels, you can use \fB\-\-patch\-from\fR in \fB\-\-single\-thread\fR mode to improve compression ratio at the cost of speed\. |
| 105 | .IP |
| 106 | Note: for level 19, you can get increased compression ratio at the cost of speed by specifying \fB\-\-zstd=targetLength=\fR to be something large (i\.e\. 4096), and by setting a large \fB\-\-zstd=chainLog=\fR\. |
| 107 | .IP "\[ci]" 4 |
| 108 | \fB\-\-rsyncable\fR: \fBzstd\fR will periodically synchronize the compression state to make the compressed file more rsync\-friendly\. There is a negligible impact to compression ratio, and a potential impact to compression speed, perceptible at higher speeds, for example when combining \fB\-\-rsyncable\fR with many parallel worker threads\. This feature does not work with \fB\-\-single\-thread\fR\. You probably don\'t want to use it with long range mode, since it will decrease the effectiveness of the synchronization points, but your mileage may vary\. |
| 109 | .IP "\[ci]" 4 |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 110 | \fB\-C\fR, \fB\-\-[no\-]check\fR: add integrity check computed from uncompressed data (default: enabled) |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 111 | .IP "\[ci]" 4 |
| 112 | \fB\-\-[no\-]content\-size\fR: enable / disable whether or not the original size of the file is placed in the header of the compressed file\. The default option is \fB\-\-content\-size\fR (meaning that the original size will be placed in the header)\. |
| 113 | .IP "\[ci]" 4 |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 114 | \fB\-\-no\-dictID\fR: do not store dictionary ID within frame header (dictionary compression)\. The decoder will have to rely on implicit knowledge about which dictionary to use, it won\'t be able to check if it\'s correct\. |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 115 | .IP "\[ci]" 4 |
| 116 | \fB\-M#\fR, \fB\-\-memory=#\fR: Set a memory usage limit\. By default, \fBzstd\fR uses 128 MiB for decompression as the maximum amount of memory the decompressor is allowed to use, but you can override this manually if need be in either direction (i\.e\. you can increase or decrease it)\. |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 117 | .IP |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 118 | This is also used during compression when using with \fB\-\-patch\-from=\fR\. In this case, this parameter overrides that maximum size allowed for a dictionary\. (128 MiB)\. |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 119 | .IP |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 120 | Additionally, this can be used to limit memory for dictionary training\. This parameter overrides the default limit of 2 GiB\. zstd will load training samples up to the memory limit and ignore the rest\. |
| 121 | .IP "\[ci]" 4 |
| 122 | \fB\-\-stream\-size=#\fR: Sets the pledged source size of input coming from a stream\. This value must be exact, as it will be included in the produced frame header\. Incorrect stream sizes will cause an error\. This information will be used to better optimize compression parameters, resulting in better and potentially faster compression, especially for smaller source sizes\. |
| 123 | .IP "\[ci]" 4 |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 124 | \fB\-\-size\-hint=#\fR: When handling input from a stream, \fBzstd\fR must guess how large the source size will be when optimizing compression parameters\. If the stream size is relatively small, this guess may be a poor one, resulting in a higher compression ratio than expected\. This feature allows for controlling the guess when needed\. Exact guesses result in better compression ratios\. Overestimates result in slightly degraded compression ratios, while underestimates may result in significant degradation\. |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 125 | .IP "\[ci]" 4 |
| 126 | \fB\-o FILE\fR: save result into \fBFILE\fR\. |
| 127 | .IP "\[ci]" 4 |
| 128 | \fB\-f\fR, \fB\-\-force\fR: disable input and output checks\. Allows overwriting existing files, input from console, output to stdout, operating on links, block devices, etc\. During decompression and when the output destination is stdout, pass\-through unrecognized formats as\-is\. |
| 129 | .IP "\[ci]" 4 |
| 130 | \fB\-c\fR, \fB\-\-stdout\fR: write to standard output (even if it is the console); keep original files unchanged\. |
| 131 | .IP "\[ci]" 4 |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 132 | \fB\-\-[no\-]sparse\fR: enable / disable sparse FS support, to make files with many zeroes smaller on disk\. Creating sparse files may save disk space and speed up decompression by reducing the amount of disk I/O\. default: enabled when output is into a file, and disabled when output is stdout\. This setting overrides default and can force sparse mode over stdout\. |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 133 | .IP "\[ci]" 4 |
| 134 | \fB\-\-[no\-]pass\-through\fR enable / disable passing through uncompressed files as\-is\. During decompression when pass\-through is enabled, unrecognized formats will be copied as\-is from the input to the output\. By default, pass\-through will occur when the output destination is stdout and the force (\fB\-f\fR) option is set\. |
| 135 | .IP "\[ci]" 4 |
| 136 | \fB\-\-rm\fR: remove source file(s) after successful compression or decompression\. This command is silently ignored if output is \fBstdout\fR\. If used in combination with \fB\-o\fR, triggers a confirmation prompt (which can be silenced with \fB\-f\fR), as this is a destructive operation\. |
| 137 | .IP "\[ci]" 4 |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 138 | \fB\-k\fR, \fB\-\-keep\fR: keep source file(s) after successful compression or decompression\. This is the default behavior\. |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 139 | .IP "\[ci]" 4 |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 140 | \fB\-r\fR: operate recursively on directories\. It selects all files in the named directory and all its subdirectories\. This can be useful both to reduce command line typing, and to circumvent shell expansion limitations, when there are a lot of files and naming breaks the maximum size of a command line\. |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 141 | .IP "\[ci]" 4 |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 142 | \fB\-\-filelist FILE\fR read a list of files to process as content from \fBFILE\fR\. Format is compatible with \fBls\fR output, with one file per line\. |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 143 | .IP "\[ci]" 4 |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 144 | \fB\-\-output\-dir\-flat DIR\fR: resulting files are stored into target \fBDIR\fR directory, instead of same directory as origin file\. Be aware that this command can introduce name collision issues, if multiple files, from different directories, end up having the same name\. Collision resolution ensures first file with a given name will be present in \fBDIR\fR, while in combination with \fB\-f\fR, the last file will be present instead\. |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 145 | .IP "\[ci]" 4 |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 146 | \fB\-\-output\-dir\-mirror DIR\fR: similar to \fB\-\-output\-dir\-flat\fR, the output files are stored underneath target \fBDIR\fR directory, but this option will replicate input directory hierarchy into output \fBDIR\fR\. |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 147 | .IP |
| 148 | If input directory contains "\.\.", the files in this directory will be ignored\. If input directory is an absolute directory (i\.e\. "/var/tmp/abc"), it will be stored into the "output\-dir/var/tmp/abc"\. If there are multiple input files or directories, name collision resolution will follow the same rules as \fB\-\-output\-dir\-flat\fR\. |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 149 | .IP "\[ci]" 4 |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 150 | \fB\-\-format=FORMAT\fR: compress and decompress in other formats\. If compiled with support, zstd can compress to or decompress from other compression algorithm formats\. Possibly available options are \fBzstd\fR, \fBgzip\fR, \fBxz\fR, \fBlzma\fR, and \fBlz4\fR\. If no such format is provided, \fBzstd\fR is the default\. |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 151 | .IP "\[ci]" 4 |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 152 | \fB\-h\fR/\fB\-H\fR, \fB\-\-help\fR: display help/long help and exit |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 153 | .IP "\[ci]" 4 |
| 154 | \fB\-V\fR, \fB\-\-version\fR: display version number and exit\. Advanced: \fB\-vV\fR also displays supported formats\. \fB\-vvV\fR also displays POSIX support\. \fB\-q\fR will only display the version number, suitable for machine reading\. |
| 155 | .IP "\[ci]" 4 |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 156 | \fB\-v\fR, \fB\-\-verbose\fR: verbose mode, display more information |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 157 | .IP "\[ci]" 4 |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 158 | \fB\-q\fR, \fB\-\-quiet\fR: suppress warnings, interactivity, and notifications\. specify twice to suppress errors too\. |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 159 | .IP "\[ci]" 4 |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 160 | \fB\-\-no\-progress\fR: do not display the progress bar, but keep all other messages\. |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 161 | .IP "\[ci]" 4 |
| 162 | \fB\-\-show\-default\-cparams\fR: shows the default compression parameters that will be used for a particular input file, based on the provided compression level and the input size\. If the provided file is not a regular file (e\.g\. a pipe), this flag will output the parameters used for inputs of unknown size\. |
| 163 | .IP "\[ci]" 4 |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 164 | \fB\-\-\fR: All arguments after \fB\-\-\fR are treated as files |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 165 | .IP "" 0 |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 166 | .SS "gzip Operation Modifiers" |
| 167 | When invoked via a \fBgzip\fR symlink, \fBzstd\fR will support further options that intend to mimic the \fBgzip\fR behavior: |
| 168 | .TP |
| 169 | \fB\-n\fR, \fB\-\-no\-name\fR |
| 170 | do not store the original filename and timestamps when compressing a file\. This is the default behavior and hence a no\-op\. |
| 171 | .TP |
| 172 | \fB\-\-best\fR |
| 173 | alias to the option \fB\-9\fR\. |
| 174 | .SS "Environment Variables" |
| 175 | Employing environment variables to set parameters has security implications\. Therefore, this avenue is intentionally limited\. Only \fBZSTD_CLEVEL\fR and \fBZSTD_NBTHREADS\fR are currently supported\. They set the compression level and number of threads to use during compression, respectively\. |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 176 | .P |
| 177 | \fBZSTD_CLEVEL\fR can be used to set the level between 1 and 19 (the "normal" range)\. If the value of \fBZSTD_CLEVEL\fR is not a valid integer, it will be ignored with a warning message\. \fBZSTD_CLEVEL\fR just replaces the default compression level (\fB3\fR)\. |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 178 | .P |
| 179 | \fBZSTD_NBTHREADS\fR can be used to set the number of threads \fBzstd\fR will attempt to use during compression\. If the value of \fBZSTD_NBTHREADS\fR is not a valid unsigned integer, it will be ignored with a warning message\. \fBZSTD_NBTHREADS\fR has a default value of (\fB1\fR), and is capped at ZSTDMT_NBWORKERS_MAX==200\. \fBzstd\fR must be compiled with multithread support for this to have any effect\. |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 180 | .P |
| 181 | They can both be overridden by corresponding command line arguments: \fB\-#\fR for compression level and \fB\-T#\fR for number of compression threads\. |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 182 | .SH "DICTIONARY BUILDER" |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 183 | \fBzstd\fR offers \fIdictionary\fR compression, which greatly improves efficiency on small files and messages\. It\'s possible to train \fBzstd\fR with a set of samples, the result of which is saved into a file called a \fBdictionary\fR\. Then, during compression and decompression, reference the same dictionary, using command \fB\-D dictionaryFileName\fR\. Compression of small files similar to the sample set will be greatly improved\. |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 184 | .TP |
| 185 | \fB\-\-train FILEs\fR |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 186 | Use FILEs as training set to create a dictionary\. The training set should ideally contain a lot of samples (> 100), and weight typically 100x the target dictionary size (for example, ~10 MB for a 100 KB dictionary)\. \fB\-\-train\fR can be combined with \fB\-r\fR to indicate a directory rather than listing all the files, which can be useful to circumvent shell expansion limits\. |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 187 | .IP |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 188 | Since dictionary compression is mostly effective for small files, the expectation is that the training set will only contain small files\. In the case where some samples happen to be large, only the first 128 KiB of these samples will be used for training\. |
| 189 | .IP |
| 190 | \fB\-\-train\fR supports multithreading if \fBzstd\fR is compiled with threading support (default)\. Additional advanced parameters can be specified with \fB\-\-train\-fastcover\fR\. The legacy dictionary builder can be accessed with \fB\-\-train\-legacy\fR\. The slower cover dictionary builder can be accessed with \fB\-\-train\-cover\fR\. Default \fB\-\-train\fR is equivalent to \fB\-\-train\-fastcover=d=8,steps=4\fR\. |
Evan Witt | 7993493 | 2023-09-06 22:46:11 +0000 | [diff] [blame] | 191 | .TP |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 192 | \fB\-o FILE\fR |
| 193 | Dictionary saved into \fBFILE\fR (default name: dictionary)\. |
Yann Collet | 2d08b09 | 2016-02-16 14:42:08 +0100 | [diff] [blame] | 194 | .TP |
Yann Collet | 96aa301 | 2017-03-24 16:04:29 -0700 | [diff] [blame] | 195 | \fB\-\-maxdict=#\fR |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 196 | Limit dictionary to specified size (default: 112640 bytes)\. As usual, quantities are expressed in bytes by default, and it\'s possible to employ suffixes (like \fBKB\fR or \fBMB\fR) to specify larger values\. |
Yann Collet | 290aaa7 | 2016-05-30 21:18:52 +0200 | [diff] [blame] | 197 | .TP |
Yann Collet | 9f8ed23 | 2018-01-27 22:23:26 -0800 | [diff] [blame] | 198 | \fB\-#\fR |
| 199 | Use \fB#\fR compression level during training (optional)\. Will generate statistics more tuned for selected compression level, resulting in a \fIsmall\fR compression ratio improvement for this level\. |
Yann Collet | 9f8ed23 | 2018-01-27 22:23:26 -0800 | [diff] [blame] | 200 | .TP |
Nick Terrell | c233bdb | 2017-09-22 14:04:39 -0700 | [diff] [blame] | 201 | \fB\-B#\fR |
Yann Collet | 999f877 | 2021-09-22 14:18:24 -0700 | [diff] [blame] | 202 | Split input files into blocks of size # (default: no split) |
Nick Terrell | c233bdb | 2017-09-22 14:04:39 -0700 | [diff] [blame] | 203 | .TP |
Yann Collet | abc694f | 2021-12-20 14:24:06 -0800 | [diff] [blame] | 204 | \fB\-M#\fR, \fB\-\-memory=#\fR |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 205 | Limit the amount of sample data loaded for training (default: 2 GB)\. Note that the default (2 GB) is also the maximum\. This parameter can be useful in situations where the training set size is not well controlled and could be potentially very large\. Since speed of the training process is directly correlated to the size of the training sample set, a smaller sample set leads to faster training\. |
| 206 | .IP |
| 207 | In situations where the training set is larger than maximum memory, the CLI will randomly select samples among the available ones, up to the maximum allowed memory budget\. This is meant to improve dictionary relevance by mitigating the potential impact of clustering, such as selecting only files from the beginning of a list sorted by modification date, or sorted by alphabetical order\. The randomization process is deterministic, so training of the same list of files with the same parameters will lead to the creation of the same dictionary\. |
Yann Collet | abc694f | 2021-12-20 14:24:06 -0800 | [diff] [blame] | 208 | .TP |
Yann Collet | 96aa301 | 2017-03-24 16:04:29 -0700 | [diff] [blame] | 209 | \fB\-\-dictID=#\fR |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 210 | A dictionary ID is a locally unique ID\. The decoder will use this value to verify it is using the right dictionary\. By default, zstd will create a 4\-bytes random number ID\. It\'s possible to provide an explicit number ID instead\. It\'s up to the dictionary manager to not assign twice the same ID to 2 different dictionaries\. Note that short numbers have an advantage: an ID < 256 will only need 1 byte in the compressed frame header, and an ID < 65536 will only need 2 bytes\. This compares favorably to 4 bytes default\. |
| 211 | .IP |
| 212 | Note that RFC8878 reserves IDs less than 32768 and greater than or equal to 2\e^31, so they should not be used in public\. |
Yann Collet | 2d08b09 | 2016-02-16 14:42:08 +0100 | [diff] [blame] | 213 | .TP |
Yann Collet | 1f16245 | 2019-07-24 16:04:37 -0700 | [diff] [blame] | 214 | \fB\-\-train\-cover[=k#,d=#,steps=#,split=#,shrink[=#]]\fR |
| 215 | Select parameters for the default dictionary builder algorithm named cover\. If \fId\fR is not specified, then it tries \fId\fR = 6 and \fId\fR = 8\. If \fIk\fR is not specified, then it tries \fIsteps\fR values in the range [50, 2000]\. If \fIsteps\fR is not specified, then the default value of 40 is used\. If \fIsplit\fR is not specified or split <= 0, then the default value of 100 is used\. Requires that \fId\fR <= \fIk\fR\. If \fIshrink\fR flag is not used, then the default value for \fIshrinkDict\fR of 0 is used\. If \fIshrink\fR is not specified, then the default value for \fIshrinkDictMaxRegression\fR of 1 is used\. |
Nick Terrell | f376d47 | 2017-05-01 23:40:20 -0700 | [diff] [blame] | 216 | .IP |
Yann Collet | 1f16245 | 2019-07-24 16:04:37 -0700 | [diff] [blame] | 217 | Selects segments of size \fIk\fR with highest score to put in the dictionary\. The score of a segment is computed by the sum of the frequencies of all the subsegments of size \fId\fR\. Generally \fId\fR should be in the range [6, 8], occasionally up to 16, but the algorithm will run faster with d <= \fI8\fR\. Good values for \fIk\fR vary widely based on the input data, but a safe range is [2 * \fId\fR, 2000]\. If \fIsplit\fR is 100, all input samples are used for both training and testing to find optimal \fId\fR and \fIk\fR to build dictionary\. Supports multithreading if \fBzstd\fR is compiled with threading support\. Having \fIshrink\fR enabled takes a truncated dictionary of minimum size and doubles in size until compression ratio of the truncated dictionary is at most \fIshrinkDictMaxRegression%\fR worse than the compression ratio of the largest dictionary\. |
Nick Terrell | f376d47 | 2017-05-01 23:40:20 -0700 | [diff] [blame] | 218 | .IP |
| 219 | Examples: |
Nick Terrell | f376d47 | 2017-05-01 23:40:20 -0700 | [diff] [blame] | 220 | .IP |
| 221 | \fBzstd \-\-train\-cover FILEs\fR |
Nick Terrell | f376d47 | 2017-05-01 23:40:20 -0700 | [diff] [blame] | 222 | .IP |
| 223 | \fBzstd \-\-train\-cover=k=50,d=8 FILEs\fR |
Nick Terrell | f376d47 | 2017-05-01 23:40:20 -0700 | [diff] [blame] | 224 | .IP |
| 225 | \fBzstd \-\-train\-cover=d=8,steps=500 FILEs\fR |
Nick Terrell | f376d47 | 2017-05-01 23:40:20 -0700 | [diff] [blame] | 226 | .IP |
| 227 | \fBzstd \-\-train\-cover=k=50 FILEs\fR |
Yann Collet | 45010da | 2018-09-19 17:37:22 -0700 | [diff] [blame] | 228 | .IP |
| 229 | \fBzstd \-\-train\-cover=k=50,split=60 FILEs\fR |
Yann Collet | 1f16245 | 2019-07-24 16:04:37 -0700 | [diff] [blame] | 230 | .IP |
| 231 | \fBzstd \-\-train\-cover=shrink FILEs\fR |
Yann Collet | 1f16245 | 2019-07-24 16:04:37 -0700 | [diff] [blame] | 232 | .IP |
| 233 | \fBzstd \-\-train\-cover=shrink=2 FILEs\fR |
Nick Terrell | b4016ff | 2017-02-03 16:42:07 -0800 | [diff] [blame] | 234 | .TP |
Jennifer Liu | 9d6ed9d | 2018-08-23 12:06:20 -0700 | [diff] [blame] | 235 | \fB\-\-train\-fastcover[=k#,d=#,f=#,steps=#,split=#,accel=#]\fR |
Yann Collet | 45010da | 2018-09-19 17:37:22 -0700 | [diff] [blame] | 236 | Same as cover but with extra parameters \fIf\fR and \fIaccel\fR and different default value of split If \fIsplit\fR is not specified, then it tries \fIsplit\fR = 75\. If \fIf\fR is not specified, then it tries \fIf\fR = 20\. Requires that 0 < \fIf\fR < 32\. If \fIaccel\fR is not specified, then it tries \fIaccel\fR = 1\. Requires that 0 < \fIaccel\fR <= 10\. Requires that \fId\fR = 6 or \fId\fR = 8\. |
Jennifer Liu | 9d6ed9d | 2018-08-23 12:06:20 -0700 | [diff] [blame] | 237 | .IP |
Yann Collet | 45010da | 2018-09-19 17:37:22 -0700 | [diff] [blame] | 238 | \fIf\fR is log of size of array that keeps track of frequency of subsegments of size \fId\fR\. The subsegment is hashed to an index in the range [0,2^\fIf\fR \- 1]\. It is possible that 2 different subsegments are hashed to the same index, and they are considered as the same subsegment when computing frequency\. Using a higher \fIf\fR reduces collision but takes longer\. |
Jennifer Liu | 9d6ed9d | 2018-08-23 12:06:20 -0700 | [diff] [blame] | 239 | .IP |
| 240 | Examples: |
Jennifer Liu | 9d6ed9d | 2018-08-23 12:06:20 -0700 | [diff] [blame] | 241 | .IP |
| 242 | \fBzstd \-\-train\-fastcover FILEs\fR |
Jennifer Liu | 9d6ed9d | 2018-08-23 12:06:20 -0700 | [diff] [blame] | 243 | .IP |
| 244 | \fBzstd \-\-train\-fastcover=d=8,f=15,accel=2 FILEs\fR |
Jennifer Liu | 9d6ed9d | 2018-08-23 12:06:20 -0700 | [diff] [blame] | 245 | .TP |
Nick Terrell | f376d47 | 2017-05-01 23:40:20 -0700 | [diff] [blame] | 246 | \fB\-\-train\-legacy[=selectivity=#]\fR |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 247 | Use legacy dictionary builder algorithm with the given dictionary \fIselectivity\fR (default: 9)\. The smaller the \fIselectivity\fR value, the denser the dictionary, improving its efficiency but reducing its achievable maximum size\. \fB\-\-train\-legacy=s=#\fR is also accepted\. |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 248 | .IP |
Nick Terrell | f376d47 | 2017-05-01 23:40:20 -0700 | [diff] [blame] | 249 | Examples: |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 250 | .IP |
Nick Terrell | f376d47 | 2017-05-01 23:40:20 -0700 | [diff] [blame] | 251 | \fBzstd \-\-train\-legacy FILEs\fR |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 252 | .IP |
Nick Terrell | f376d47 | 2017-05-01 23:40:20 -0700 | [diff] [blame] | 253 | \fBzstd \-\-train\-legacy=selectivity=8 FILEs\fR |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 254 | .SH "BENCHMARK" |
Nick Terrell | b4016ff | 2017-02-03 16:42:07 -0800 | [diff] [blame] | 255 | .TP |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 256 | \fB\-b#\fR |
| 257 | benchmark file(s) using compression level # |
Nick Terrell | b4016ff | 2017-02-03 16:42:07 -0800 | [diff] [blame] | 258 | .TP |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 259 | \fB\-e#\fR |
| 260 | benchmark file(s) using multiple compression levels, from \fB\-b#\fR to \fB\-e#\fR (inclusive) |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 261 | .TP |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 262 | \fB\-i#\fR |
ne-sted | 50aea2f | 2018-01-24 14:59:44 +0200 | [diff] [blame] | 263 | minimum evaluation time, in seconds (default: 3s), benchmark mode only |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 264 | .TP |
Yann Collet | bb0aaf9 | 2017-06-12 05:19:15 -0700 | [diff] [blame] | 265 | \fB\-B#\fR, \fB\-\-block\-size=#\fR |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 266 | cut file(s) into independent chunks of size # (default: no chunking) |
Yann Collet | 22de81e | 2016-10-28 13:58:31 -0700 | [diff] [blame] | 267 | .TP |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 268 | \fB\-\-priority=rt\fR |
| 269 | set process priority to real\-time |
Yann Collet | 2fd7654 | 2017-11-24 17:20:54 -0800 | [diff] [blame] | 270 | .P |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 271 | \fBOutput Format:\fR CompressionLevel#Filename: InputSize \-> OutputSize (CompressionRatio), CompressionSpeed, DecompressionSpeed |
Yann Collet | 2fd7654 | 2017-11-24 17:20:54 -0800 | [diff] [blame] | 272 | .P |
| 273 | \fBMethodology:\fR For both compression and decompression speed, the entire input is compressed/decompressed in\-memory to measure speed\. A run lasts at least 1 sec, so when files are small, they are compressed/decompressed several times per run, in order to improve measurement accuracy\. |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 274 | .SH "ADVANCED COMPRESSION OPTIONS" |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 275 | ### \-B#: Specify the size of each compression job\. This parameter is only available when multi\-threading is enabled\. Each compression job is run in parallel, so this value indirectly impacts the nb of active threads\. Default job size varies depending on compression level (generally \fB4 * windowSize\fR)\. \fB\-B#\fR makes it possible to manually select a custom size\. Note that job size must respect a minimum value which is enforced transparently\. This minimum is either 512 KB, or \fBoverlapSize\fR, whichever is largest\. Different job sizes will lead to non\-identical compressed frames\. |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 276 | .SS "\-\-zstd[=options]:" |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 277 | \fBzstd\fR provides 22 predefined regular compression levels plus the fast levels\. This compression level is translated internally into a number of specific parameters that actually control the behavior of the compressor\. (You can see the result of this translation with \fB\-\-show\-default\-cparams\fR\.) These specific parameters can be overridden with advanced compression options\. The \fIoptions\fR are provided as a comma\-separated list\. You may specify only the options you want to change and the rest will be taken from the selected or default compression level\. The list of available \fIoptions\fR: |
Yann Collet | 2d08b09 | 2016-02-16 14:42:08 +0100 | [diff] [blame] | 278 | .TP |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 279 | \fBstrategy\fR=\fIstrat\fR, \fBstrat\fR=\fIstrat\fR |
| 280 | Specify a strategy used by a match finder\. |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 281 | .IP |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 282 | There are 9 strategies numbered from 1 to 9, from fastest to strongest: 1=\fBZSTD_fast\fR, 2=\fBZSTD_dfast\fR, 3=\fBZSTD_greedy\fR, 4=\fBZSTD_lazy\fR, 5=\fBZSTD_lazy2\fR, 6=\fBZSTD_btlazy2\fR, 7=\fBZSTD_btopt\fR, 8=\fBZSTD_btultra\fR, 9=\fBZSTD_btultra2\fR\. |
Przemyslaw Skibinski | 2531442 | 2016-12-14 16:10:13 +0100 | [diff] [blame] | 283 | .TP |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 284 | \fBwindowLog\fR=\fIwlog\fR, \fBwlog\fR=\fIwlog\fR |
| 285 | Specify the maximum number of bits for a match distance\. |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 286 | .IP |
Nick Terrell | c233bdb | 2017-09-22 14:04:39 -0700 | [diff] [blame] | 287 | The higher number of increases the chance to find a match which usually improves compression ratio\. It also increases memory requirements for the compressor and decompressor\. The minimum \fIwlog\fR is 10 (1 KiB) and the maximum is 30 (1 GiB) on 32\-bit platforms and 31 (2 GiB) on 64\-bit platforms\. |
Nick Terrell | c233bdb | 2017-09-22 14:04:39 -0700 | [diff] [blame] | 288 | .IP |
| 289 | Note: If \fBwindowLog\fR is set to larger than 27, \fB\-\-long=windowLog\fR or \fB\-\-memory=windowSize\fR needs to be passed to the decompressor\. |
Przemyslaw Skibinski | 2531442 | 2016-12-14 16:10:13 +0100 | [diff] [blame] | 290 | .TP |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 291 | \fBhashLog\fR=\fIhlog\fR, \fBhlog\fR=\fIhlog\fR |
| 292 | Specify the maximum number of bits for a hash table\. |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 293 | .IP |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 294 | Bigger hash tables cause fewer collisions which usually makes compression faster, but requires more memory during compression\. |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 295 | .IP |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 296 | The minimum \fIhlog\fR is 6 (64 entries / 256 B) and the maximum is 30 (1B entries / 4 GiB)\. |
Przemyslaw Skibinski | 2531442 | 2016-12-14 16:10:13 +0100 | [diff] [blame] | 297 | .TP |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 298 | \fBchainLog\fR=\fIclog\fR, \fBclog\fR=\fIclog\fR |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 299 | Specify the maximum number of bits for the secondary search structure, whose form depends on the selected \fBstrategy\fR\. |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 300 | .IP |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 301 | Higher numbers of bits increases the chance to find a match which usually improves compression ratio\. It also slows down compression speed and increases memory requirements for compression\. This option is ignored for the \fBZSTD_fast\fR \fBstrategy\fR, which only has the primary hash table\. |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 302 | .IP |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 303 | The minimum \fIclog\fR is 6 (64 entries / 256 B) and the maximum is 29 (512M entries / 2 GiB) on 32\-bit platforms and 30 (1B entries / 4 GiB) on 64\-bit platforms\. |
Przemyslaw Skibinski | 2531442 | 2016-12-14 16:10:13 +0100 | [diff] [blame] | 304 | .TP |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 305 | \fBsearchLog\fR=\fIslog\fR, \fBslog\fR=\fIslog\fR |
| 306 | Specify the maximum number of searches in a hash chain or a binary tree using logarithmic scale\. |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 307 | .IP |
| 308 | More searches increases the chance to find a match which usually increases compression ratio but decreases compression speed\. |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 309 | .IP |
Yann Collet | d246477 | 2020-02-26 14:29:30 -0800 | [diff] [blame] | 310 | The minimum \fIslog\fR is 1 and the maximum is \'windowLog\' \- 1\. |
Przemyslaw Skibinski | 2531442 | 2016-12-14 16:10:13 +0100 | [diff] [blame] | 311 | .TP |
Yann Collet | e874dac | 2018-11-20 14:56:07 -0800 | [diff] [blame] | 312 | \fBminMatch\fR=\fImml\fR, \fBmml\fR=\fImml\fR |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 313 | Specify the minimum searched length of a match in a hash table\. |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 314 | .IP |
| 315 | Larger search lengths usually decrease compression ratio but improve decompression speed\. |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 316 | .IP |
Yann Collet | e874dac | 2018-11-20 14:56:07 -0800 | [diff] [blame] | 317 | The minimum \fImml\fR is 3 and the maximum is 7\. |
Przemyslaw Skibinski | 2531442 | 2016-12-14 16:10:13 +0100 | [diff] [blame] | 318 | .TP |
Yann Collet | f22b371 | 2020-05-14 16:17:03 -0700 | [diff] [blame] | 319 | \fBtargetLength\fR=\fItlen\fR, \fBtlen\fR=\fItlen\fR |
Yann Collet | b824d21 | 2018-05-12 10:21:30 -0700 | [diff] [blame] | 320 | The impact of this field vary depending on selected strategy\. |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 321 | .IP |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 322 | For \fBZSTD_btopt\fR, \fBZSTD_btultra\fR and \fBZSTD_btultra2\fR, it specifies the minimum match length that causes match finder to stop searching\. A larger \fBtargetLength\fR usually improves compression ratio but decreases compression speed\. |
| 323 | .IP |
| 324 | For \fBZSTD_fast\fR, it triggers ultra\-fast mode when > 0\. The value represents the amount of data skipped between match sampling\. Impact is reversed: a larger \fBtargetLength\fR increases compression speed but decreases compression ratio\. |
Yann Collet | b824d21 | 2018-05-12 10:21:30 -0700 | [diff] [blame] | 325 | .IP |
| 326 | For all other strategies, this field has no impact\. |
Yann Collet | b824d21 | 2018-05-12 10:21:30 -0700 | [diff] [blame] | 327 | .IP |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 328 | The minimum \fItlen\fR is 0 and the maximum is 128 KiB\. |
Przemyslaw Skibinski | 2531442 | 2016-12-14 16:10:13 +0100 | [diff] [blame] | 329 | .TP |
Yann Collet | 805c5a3 | 2017-04-01 00:36:31 -0700 | [diff] [blame] | 330 | \fBoverlapLog\fR=\fIovlog\fR, \fBovlog\fR=\fIovlog\fR |
Yann Collet | a36330a | 2017-04-03 14:57:24 -0700 | [diff] [blame] | 331 | Determine \fBoverlapSize\fR, amount of data reloaded from previous job\. This parameter is only available when multithreading is enabled\. Reloading more data improves compression ratio, but decreases speed\. |
Yann Collet | 805c5a3 | 2017-04-01 00:36:31 -0700 | [diff] [blame] | 332 | .IP |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 333 | The minimum \fIovlog\fR is 0, and the maximum is 9\. 1 means "no overlap", hence completely independent jobs\. 9 means "full overlap", meaning up to \fBwindowSize\fR is reloaded from previous job\. Reducing \fIovlog\fR by 1 reduces the reloaded amount by a factor 2\. For example, 8 means "windowSize/2", and 6 means "windowSize/8"\. Value 0 is special and means "default": \fIovlog\fR is automatically determined by \fBzstd\fR\. In which case, \fIovlog\fR will range from 6 to 9, depending on selected \fIstrat\fR\. |
Stella Lau | 643d28c | 2017-09-05 11:05:57 -0700 | [diff] [blame] | 334 | .TP |
Yann Collet | e874dac | 2018-11-20 14:56:07 -0800 | [diff] [blame] | 335 | \fBldmHashLog\fR=\fIlhlog\fR, \fBlhlog\fR=\fIlhlog\fR |
Stella Lau | 643d28c | 2017-09-05 11:05:57 -0700 | [diff] [blame] | 336 | Specify the maximum size for a hash table used for long distance matching\. |
Stella Lau | 643d28c | 2017-09-05 11:05:57 -0700 | [diff] [blame] | 337 | .IP |
| 338 | This option is ignored unless long distance matching is enabled\. |
Stella Lau | 643d28c | 2017-09-05 11:05:57 -0700 | [diff] [blame] | 339 | .IP |
| 340 | Bigger hash tables usually improve compression ratio at the expense of more memory during compression and a decrease in compression speed\. |
Stella Lau | 643d28c | 2017-09-05 11:05:57 -0700 | [diff] [blame] | 341 | .IP |
Yann Collet | d246477 | 2020-02-26 14:29:30 -0800 | [diff] [blame] | 342 | The minimum \fIlhlog\fR is 6 and the maximum is 30 (default: 20)\. |
Stella Lau | 643d28c | 2017-09-05 11:05:57 -0700 | [diff] [blame] | 343 | .TP |
Yann Collet | e874dac | 2018-11-20 14:56:07 -0800 | [diff] [blame] | 344 | \fBldmMinMatch\fR=\fIlmml\fR, \fBlmml\fR=\fIlmml\fR |
Stella Lau | 643d28c | 2017-09-05 11:05:57 -0700 | [diff] [blame] | 345 | Specify the minimum searched length of a match for long distance matching\. |
Stella Lau | 643d28c | 2017-09-05 11:05:57 -0700 | [diff] [blame] | 346 | .IP |
| 347 | This option is ignored unless long distance matching is enabled\. |
Stella Lau | 643d28c | 2017-09-05 11:05:57 -0700 | [diff] [blame] | 348 | .IP |
| 349 | Larger/very small values usually decrease compression ratio\. |
Stella Lau | 643d28c | 2017-09-05 11:05:57 -0700 | [diff] [blame] | 350 | .IP |
Yann Collet | e874dac | 2018-11-20 14:56:07 -0800 | [diff] [blame] | 351 | The minimum \fIlmml\fR is 4 and the maximum is 4096 (default: 64)\. |
Stella Lau | 643d28c | 2017-09-05 11:05:57 -0700 | [diff] [blame] | 352 | .TP |
Yann Collet | e874dac | 2018-11-20 14:56:07 -0800 | [diff] [blame] | 353 | \fBldmBucketSizeLog\fR=\fIlblog\fR, \fBlblog\fR=\fIlblog\fR |
Stella Lau | 643d28c | 2017-09-05 11:05:57 -0700 | [diff] [blame] | 354 | Specify the size of each bucket for the hash table used for long distance matching\. |
Stella Lau | 643d28c | 2017-09-05 11:05:57 -0700 | [diff] [blame] | 355 | .IP |
| 356 | This option is ignored unless long distance matching is enabled\. |
Stella Lau | 643d28c | 2017-09-05 11:05:57 -0700 | [diff] [blame] | 357 | .IP |
| 358 | Larger bucket sizes improve collision resolution but decrease compression speed\. |
Stella Lau | 643d28c | 2017-09-05 11:05:57 -0700 | [diff] [blame] | 359 | .IP |
Yann Collet | d246477 | 2020-02-26 14:29:30 -0800 | [diff] [blame] | 360 | The minimum \fIlblog\fR is 1 and the maximum is 8 (default: 3)\. |
Stella Lau | 643d28c | 2017-09-05 11:05:57 -0700 | [diff] [blame] | 361 | .TP |
Yann Collet | 41c7d0b | 2018-11-21 14:36:57 -0800 | [diff] [blame] | 362 | \fBldmHashRateLog\fR=\fIlhrlog\fR, \fBlhrlog\fR=\fIlhrlog\fR |
Stella Lau | 643d28c | 2017-09-05 11:05:57 -0700 | [diff] [blame] | 363 | Specify the frequency of inserting entries into the long distance matching hash table\. |
Stella Lau | 643d28c | 2017-09-05 11:05:57 -0700 | [diff] [blame] | 364 | .IP |
| 365 | This option is ignored unless long distance matching is enabled\. |
Stella Lau | 643d28c | 2017-09-05 11:05:57 -0700 | [diff] [blame] | 366 | .IP |
| 367 | Larger values will improve compression speed\. Deviating far from the default value will likely result in a decrease in compression ratio\. |
Stella Lau | 643d28c | 2017-09-05 11:05:57 -0700 | [diff] [blame] | 368 | .IP |
Yann Collet | e874dac | 2018-11-20 14:56:07 -0800 | [diff] [blame] | 369 | The default value is \fBwlog \- lhlog\fR\. |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 370 | .SS "Example" |
Yann Collet | b824d21 | 2018-05-12 10:21:30 -0700 | [diff] [blame] | 371 | The following parameters sets advanced compression options to something similar to predefined level 19 for files bigger than 256 KB: |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 372 | .P |
Yann Collet | e874dac | 2018-11-20 14:56:07 -0800 | [diff] [blame] | 373 | \fB\-\-zstd\fR=wlog=23,clog=23,hlog=22,slog=6,mml=3,tlen=48,strat=6 |
Elliott Hughes | 44aba64 | 2023-09-12 20:18:59 +0000 | [diff] [blame] | 374 | .SH "SEE ALSO" |
| 375 | \fBzstdgrep\fR(1), \fBzstdless\fR(1), \fBgzip\fR(1), \fBxz\fR(1) |
| 376 | .P |
| 377 | The \fIzstandard\fR format is specified in Y\. Collet, "Zstandard Compression and the \'application/zstd\' Media Type", https://www\.ietf\.org/rfc/rfc8878\.txt, Internet RFC 8878 (February 2021)\. |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 378 | .SH "BUGS" |
| 379 | Report bugs at: https://github\.com/facebook/zstd/issues |
Sean Purcell | 72a243e | 2017-03-16 15:33:21 -0700 | [diff] [blame] | 380 | .SH "AUTHOR" |
Yann Collet | 4856a00 | 2015-01-24 01:58:16 +0100 | [diff] [blame] | 381 | Yann Collet |