CLAMPCHECK(cParams.chainLog, ZSTD_CHAINLOG_MIN, ZSTD_CHAINLOG_MAX);
CLAMPCHECK(cParams.hashLog, ZSTD_HASHLOG_MIN, ZSTD_HASHLOG_MAX);
CLAMPCHECK(cParams.searchLog, ZSTD_SEARCHLOG_MIN, ZSTD_SEARCHLOG_MAX);
- { U32 const searchLengthMin = ((cParams.strategy == ZSTD_fast) | (cParams.strategy == ZSTD_greedy)) ? ZSTD_SEARCHLENGTH_MIN+1 : ZSTD_SEARCHLENGTH_MIN;
- U32 const searchLengthMax = (cParams.strategy == ZSTD_fast) ? ZSTD_SEARCHLENGTH_MAX : ZSTD_SEARCHLENGTH_MAX-1;
- CLAMPCHECK(cParams.searchLength, searchLengthMin, searchLengthMax); }
+ CLAMPCHECK(cParams.searchLength, ZSTD_SEARCHLENGTH_MIN, ZSTD_SEARCHLENGTH_MAX);
CLAMPCHECK(cParams.targetLength, ZSTD_TARGETLENGTH_MIN, ZSTD_TARGETLENGTH_MAX);
- if ((U32)(cParams.strategy) > (U32)ZSTD_btopt2) return ERROR(compressionParameter_unsupported);
+ if ((U32)(cParams.strategy) > (U32)ZSTD_btultra) return ERROR(compressionParameter_unsupported);
return 0;
}
size_t const hSize = ((size_t)1) << cParams.hashLog;
U32 const hashLog3 = (cParams.searchLength>3) ? 0 : MIN(ZSTD_HASHLOG3_MAX, cParams.windowLog);
size_t const h3Size = ((size_t)1) << hashLog3;
+ size_t const entropySpace = hufCTable_size + litlengthCTable_size
+ + offcodeCTable_size + matchlengthCTable_size
+ + entropyScratchSpace_size;
size_t const tableSpace = (chainSize + hSize + h3Size) * sizeof(U32);
- size_t const optSpace = ((MaxML+1) + (MaxLL+1) + (MaxOff+1) + (1<<Litbits))*sizeof(U32)
+ size_t const optBudget = ((MaxML+1) + (MaxLL+1) + (MaxOff+1) + (1<<Litbits))*sizeof(U32)
+ (ZSTD_OPT_NUM+1)*(sizeof(ZSTD_match_t) + sizeof(ZSTD_optimal_t));
- size_t const neededSpace = tableSpace + (256*sizeof(U32)) /* huffTable */ + tokenSpace
- + (((cParams.strategy == ZSTD_btopt) || (cParams.strategy == ZSTD_btultra)) ? optSpace : 0);
- size_t const optSpace = ((cParams.strategy == ZSTD_btopt) || (cParams.strategy == ZSTD_btopt2)) ? optBudget : 0;
++ size_t const optSpace = ((cParams.strategy == ZSTD_btopt) || (cParams.strategy == ZSTD_btultra)) ? optBudget : 0;
+ size_t const neededSpace = entropySpace + tableSpace + tokenSpace + optSpace;
return sizeof(ZSTD_CCtx) + neededSpace;
}
void* ptr;
/* Check if workSpace is large enough, alloc a new one if needed */
- { size_t const optSpace = ((MaxML+1) + (MaxLL+1) + (MaxOff+1) + (1<<Litbits))*sizeof(U32)
- + (ZSTD_OPT_NUM+1)*(sizeof(ZSTD_match_t) + sizeof(ZSTD_optimal_t));
- size_t const neededSpace = tableSpace + (256*sizeof(U32)) /* huffTable */ + tokenSpace
- + (((params.cParams.strategy == ZSTD_btopt) || (params.cParams.strategy == ZSTD_btultra)) ? optSpace : 0);
+ { size_t const entropySpace = hufCTable_size + litlengthCTable_size
+ + offcodeCTable_size + matchlengthCTable_size
+ + entropyScratchSpace_size;
+ size_t const optPotentialSpace = ((MaxML+1) + (MaxLL+1) + (MaxOff+1) + (1<<Litbits)) * sizeof(U32)
+ + (ZSTD_OPT_NUM+1) * (sizeof(ZSTD_match_t)+sizeof(ZSTD_optimal_t));
- size_t const optSpace = ((params.cParams.strategy == ZSTD_btopt) || (params.cParams.strategy == ZSTD_btopt2)) ? optPotentialSpace : 0;
++ size_t const optSpace = ((params.cParams.strategy == ZSTD_btopt) || (params.cParams.strategy == ZSTD_btultra)) ? optPotentialSpace : 0;
+ size_t const neededSpace = entropySpace + optSpace + tableSpace + tokenSpace;
if (zc->workSpaceSize < neededSpace) {
+ DEBUGLOG(5, "Need to update workSpaceSize from %uK to %uK \n",
+ (unsigned)zc->workSpaceSize>>10, (unsigned)neededSpace>>10);
+ zc->workSpaceSize = 0;
ZSTD_free(zc->workSpace, zc->customMem);
zc->workSpace = ZSTD_malloc(neededSpace, zc->customMem);
if (zc->workSpace == NULL) return ERROR(memory_allocation);
zc->dictBase = NULL;
zc->dictLimit = 0;
zc->lowLimit = 0;
- zc->params = params;
- zc->blockSize = blockSize;
- zc->frameContentSize = frameContentSize;
{ int i; for (i=0; i<ZSTD_REP_NUM; i++) zc->rep[i] = repStartValue[i]; }
+ zc->hashLog3 = hashLog3;
+ zc->seqStore.litLengthSum = 0;
- if ((params.cParams.strategy == ZSTD_btopt) || (params.cParams.strategy == ZSTD_btopt2)) {
+ /* ensure entropy tables are close together at the beginning */
+ assert((void*)zc->hufCTable == zc->workSpace);
+ assert((char*)zc->offcodeCTable == (char*)zc->hufCTable + hufCTable_size);
+ assert((char*)zc->matchlengthCTable == (char*)zc->offcodeCTable + offcodeCTable_size);
+ assert((char*)zc->litlengthCTable == (char*)zc->matchlengthCTable + matchlengthCTable_size);
+ assert((char*)zc->entropyScratchSpace == (char*)zc->litlengthCTable + litlengthCTable_size);
+ ptr = (char*)zc->entropyScratchSpace + entropyScratchSpace_size;
+
+ /* opt parser space */
+ if ((params.cParams.strategy == ZSTD_btopt) || (params.cParams.strategy == ZSTD_btultra)) {
+ DEBUGLOG(5, "reserving optimal parser space ");
+ assert(((size_t)ptr & 3) == 0); /* ensure ptr is properly aligned */
zc->seqStore.litFreq = (U32*)ptr;
zc->seqStore.litLengthFreq = zc->seqStore.litFreq + (1<<Litbits);
zc->seqStore.matchLengthFreq = zc->seqStore.litLengthFreq + (MaxLL+1);
static ZSTD_blockCompressor ZSTD_selectBlockCompressor(ZSTD_strategy strat, int extDict)
{
static const ZSTD_blockCompressor blockCompressor[2][8] = {
- { ZSTD_compressBlock_fast, ZSTD_compressBlock_doubleFast, ZSTD_compressBlock_greedy, ZSTD_compressBlock_lazy, ZSTD_compressBlock_lazy2, ZSTD_compressBlock_btlazy2, ZSTD_compressBlock_btopt, ZSTD_compressBlock_btultra },
- { ZSTD_compressBlock_fast_extDict, ZSTD_compressBlock_doubleFast_extDict, ZSTD_compressBlock_greedy_extDict, ZSTD_compressBlock_lazy_extDict,ZSTD_compressBlock_lazy2_extDict, ZSTD_compressBlock_btlazy2_extDict, ZSTD_compressBlock_btopt_extDict, ZSTD_compressBlock_btultra_extDict }
+ { ZSTD_compressBlock_fast, ZSTD_compressBlock_doubleFast, ZSTD_compressBlock_greedy,
+ ZSTD_compressBlock_lazy, ZSTD_compressBlock_lazy2, ZSTD_compressBlock_btlazy2,
- ZSTD_compressBlock_btopt, ZSTD_compressBlock_btopt2 },
++ ZSTD_compressBlock_btopt, ZSTD_compressBlock_btultra },
+ { ZSTD_compressBlock_fast_extDict, ZSTD_compressBlock_doubleFast_extDict, ZSTD_compressBlock_greedy_extDict,
+ ZSTD_compressBlock_lazy_extDict,ZSTD_compressBlock_lazy2_extDict, ZSTD_compressBlock_btlazy2_extDict,
- ZSTD_compressBlock_btopt_extDict, ZSTD_compressBlock_btopt2_extDict }
++ ZSTD_compressBlock_btopt_extDict, ZSTD_compressBlock_btultra_extDict }
};
return blockCompressor[extDict][(U32)strat];
case ZSTD_btlazy2:
case ZSTD_btopt:
- case ZSTD_btopt2:
+ case ZSTD_btultra:
- ZSTD_updateTree(zc, iend-HASH_READ_SIZE, iend, 1 << zc->params.cParams.searchLog, zc->params.cParams.searchLength);
+ if (srcSize >= HASH_READ_SIZE)
+ ZSTD_updateTree(zc, iend-HASH_READ_SIZE, iend, 1 << zc->params.cParams.searchLog, zc->params.cParams.searchLength);
break;
default:
{ 22, 21, 21, 5, 5, 16, ZSTD_btlazy2 }, /* level 15 */
{ 23, 22, 22, 5, 5, 16, ZSTD_btlazy2 }, /* level 16 */
{ 23, 21, 22, 4, 5, 24, ZSTD_btopt }, /* level 17 */
- { 23, 23, 22, 6, 5, 32, ZSTD_btopt }, /* level 18 */
+ { 23, 22, 22, 5, 4, 32, ZSTD_btopt }, /* level 18 */
{ 23, 23, 22, 6, 3, 48, ZSTD_btopt }, /* level 19 */
- { 25, 25, 23, 7, 3, 64, ZSTD_btopt2 }, /* level 20 */
- { 26, 26, 23, 7, 3,256, ZSTD_btopt2 }, /* level 21 */
- { 27, 27, 25, 9, 3,512, ZSTD_btopt2 }, /* level 22 */
+ { 25, 25, 23, 7, 3, 64, ZSTD_btultra }, /* level 20 */
+ { 26, 26, 23, 7, 3,256, ZSTD_btultra }, /* level 21 */
+ { 27, 27, 25, 9, 3,512, ZSTD_btultra }, /* level 22 */
},
{ /* for srcSize <= 256 KB */
/* W, C, H, S, L, T, strat */
- \"
- \" zstd.1: This is a manual page for 'zstd' program. This file is part of the
- \" zstd <http://www.zstd.net/> project.
- \" Author: Yann Collet
- \"
-
- \" No hyphenation
- .hy 0
- .nr HY 0
-
- .TH zstd "1" "2015-08-22" "zstd" "User Commands"
- .SH NAME
- \fBzstd, unzstd, zstdcat\fR - Compress or decompress .zst files
-
- .SH SYNOPSIS
- .TP 5
- \fBzstd\fR [\fBOPTIONS\fR] [-|INPUT-FILE] [-o <OUTPUT-FILE>]
- .PP
- .B unzstd
- is equivalent to
- .BR "zstd \-d"
- .br
- .B zstdcat
- is equivalent to
- .BR "zstd \-dcf"
- .br
-
- .SH DESCRIPTION
- .PP
- \fBzstd\fR is a fast lossless compression algorithm
- and data compression tool,
- with command line syntax similar to \fB gzip (1) \fR and \fB xz (1) \fR .
- It is based on the \fBLZ77\fR family, with further FSE & huff0 entropy stages.
- \fBzstd\fR offers highly configurable compression speed,
- with fast modes at > 200 MB/s per core,
- and strong modes nearing lzma compression ratios.
- It also features a very fast decoder, with speeds > 500 MB/s per core.
-
- \fBzstd\fR command line syntax is generally similar to gzip,
- but features the following differences :
- - Source files are preserved by default.
- It's possible to remove them automatically by using \fB--rm\fR command.
- - When compressing a single file, \fBzstd\fR displays progress notifications and result summary by default.
- Use \fB-q\fR to turn them off
-
- .PP
- .B zstd
- compresses or decompresses each
- .I file
- according to the selected operation mode.
- If no
- .I files
- are given or
- .I file
- is
- .BR \- ,
- .B zstd
- reads from standard input and writes the processed data
- to standard output.
- .B zstd
- will refuse (display an error and skip the
- .IR file )
- to write compressed data to standard output if it is a terminal.
- Similarly,
- .B zstd
- will refuse to read compressed data
- from standard input if it is a terminal.
-
- .PP
- Unless
- .B \-\-stdout
- or
- .B \-o
- is specified,
- .I files
- are written to a new file whose name is derived from the source
- .I file
- name:
- .IP \(bu 3
- When compressing, the suffix
- .B .zst
- is appended to the source filename to get the target filename.
- .IP \(bu 3
- When decompressing, the
- .B .zst
- suffix is removed from the filename to get the target filename.
-
- .SS "Concatenation with .zst files"
- It is possible to concatenate
- .B .zst
- files as is.
- .B zstd
- will decompress such files as if they were a single
- .B .zst
- file.
-
-
-
- .SH OPTIONS
-
+ .
-.TH "ZSTD" "1" "May 2017" "zstd 1.2.0" "User Commands"
++.TH "ZSTD" "1" "May 2017" "zstd 1.3.0" "User Commands"
+ .
+ .SH "NAME"
+ \fBzstd\fR \- zstd, zstdmt, unzstd, zstdcat \- Compress or decompress \.zst files
+ .
+ .SH "SYNOPSIS"
+ \fBzstd\fR [\fIOPTIONS\fR] [\-|\fIINPUT\-FILE\fR] [\-o \fIOUTPUT\-FILE\fR]
+ .
+ .P
+ \fBzstdmt\fR is equivalent to \fBzstd \-T0\fR
+ .
+ .P
+ \fBunzstd\fR is equivalent to \fBzstd \-d\fR
+ .
+ .P
+ \fBzstdcat\fR is equivalent to \fBzstd \-dcf\fR
+ .
+ .SH "DESCRIPTION"
+ \fBzstd\fR is a fast lossless compression algorithm and data compression tool, with command line syntax similar to \fBgzip (1)\fR and \fBxz (1)\fR\. It is based on the \fBLZ77\fR family, with further FSE & huff0 entropy stages\. \fBzstd\fR offers highly configurable compression speed, with fast modes at > 200 MB/s per code, and strong modes nearing lzma compression ratios\. It also features a very fast decoder, with speeds > 500 MB/s per core\.
+ .
+ .P
+ \fBzstd\fR command line syntax is generally similar to gzip, but features the following differences :
+ .
+ .IP "\(bu" 4
+ Source files are preserved by default\. It\'s possible to remove them automatically by using the \fB\-\-rm\fR command\.
+ .
+ .IP "\(bu" 4
+ When compressing a single file, \fBzstd\fR displays progress notifications and result summary by default\. Use \fB\-q\fR to turn them off\.
+ .
+ .IP "\(bu" 4
+ \fBzstd\fR does not accept input from console, but it properly accepts \fBstdin\fR when it\'s not the console\.
+ .
+ .IP "\(bu" 4
+ \fBzstd\fR displays a short help page when command line is an error\. Use \fB\-q\fR to turn it off\.
+ .
+ .IP "" 0
+ .
+ .P
+ \fBzstd\fR compresses or decompresses 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 \fIfile\fR\. Similarly, \fBzstd\fR will refuse to read compressed data from standard input if it is a terminal\.
+ .
+ .P
+ 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:
+ .
+ .IP "\(bu" 4
+ When compressing, the suffix \fB\.zst\fR is appended to the source filename to get the target filename\.
+ .
+ .IP "\(bu" 4
+ When decompressing, the \fB\.zst\fR suffix is removed from the source filename to get the target filename
+ .
+ .IP "" 0
+ .
+ .SS "Concatenation with \.zst files"
+ It is possible to concatenate \fB\.zst\fR files as is\. \fBzstd\fR will decompress such files as if they were a single \fB\.zst\fR file\.
+ .
+ .SH "OPTIONS"
.
.SS "Integer suffixes and special values"
- 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.
- .TP
- .B KiB
- Multiply the integer by 1,024 (2^10).
- .BR Ki ,
- .BR K ,
- and
- .B KB
- are accepted as synonyms for
- .BR KiB .
- .TP
- .B MiB
- Multiply the integer by 1,048,576 (2^20).
- .BR Mi ,
- .BR M ,
- and
- .B MB
- are accepted as synonyms for
- .BR MiB .
-
+ 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\.
+ .
+ .TP
+ \fBKiB\fR
+ Multiply the integer by 1,024 (2^10)\. \fBKi\fR, \fBK\fR, and \fBKB\fR are accepted as synonyms for \fBKiB\fR\.
+ .
+ .TP
+ \fBMiB\fR
+ Multiply the integer by 1,048,576 (2^20)\. \fBMi\fR, \fBM\fR, and \fBMB\fR are accepted as synonyms for \fBMiB\fR\.
.
.SS "Operation mode"
- If multiple operation mode options are given,
- the last one takes effect.
- .TP
- .BR \-z ", " \-\-compress
- 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,
- .B unzstd
- implies
- .BR \-\-decompress ).
- .TP
- .BR \-d ", " \-\-decompress ", " \-\-uncompress
- Decompress.
- .TP
- .BR \-t ", " \-\-test
- Test the integrity of compressed
- .IR files .
- This option is equivalent to
- .B "\-\-decompress \-\-stdout"
- except that the decompressed data is discarded instead of being
- written to standard output.
- No files are created or removed.
- .TP
- .B \-b#
- benchmark file(s) using compression level #
- .TP
- .B \--train FILEs
- use FILEs as training set to create a dictionary. The training set should contain a lot of small files (> 100).
-
+ If multiple operation mode options are given, the last one takes effect\.
+ .
+ .TP
+ \fB\-z\fR, \fB\-\-compress\fR
+ 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)\.
+ .
+ .TP
+ \fB\-d\fR, \fB\-\-decompress\fR, \fB\-\-uncompress\fR
+ Decompress\.
+ .
+ .TP
+ \fB\-t\fR, \fB\-\-test\fR
+ Test the integrity of compressed \fIfiles\fR\. This option is equivalent to \fB\-\-decompress \-\-stdout\fR except that the decompressed data is discarded instead of being written to standard output\. No files are created or removed\.
+ .
+ .TP
+ \fB\-b#\fR
+ Benchmark file(s) using compression level #
+ .
+ .TP
+ \fB\-\-train FILEs\fR
+ Use FILEs as a training set to create a dictionary\. The training set should contain a lot of small files (> 100)\.
.
.SS "Operation modifiers"
+ .
.TP
- .B \-#
- # compression level [1-19] (default:3)
- .TP
- .BR \--ultra
- unlocks high compression levels 20+ (maximum 22), using a lot more memory.
- Note that decompression will also require more memory when using these levels.
- .TP
- .B \-D file
- use `file` as Dictionary to compress or decompress FILE(s)
- .TP
- .BR \--no-dictID
- 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.
- .TP
- .B \-o file
- save result into `file` (only possible with a single INPUT-FILE)
- .TP
- .BR \-f ", " --force
- overwrite output without prompting
- .TP
- .BR \-c ", " --stdout
- force write to standard output, even if it is the console
- .TP
- .BR \--[no-]sparse
- enable / disable sparse FS support, to make files with many zeroes smaller on disk.
- Creating sparse files may save disk space and speed up the 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.
- .TP
- .BR \--rm
- remove source file(s) after successful compression or decompression
- .TP
- .BR \-k ", " --keep
- keep source file(s) after successful compression or decompression.
- This is the default behavior.
- .TP
- .BR \-r
- operate recursively on directories
- .TP
- .BR \-h/\-H ", " --help
- display help/long help and exit
- .TP
- .BR \-V ", " --version
- display Version number and exit
- .TP
- .BR \-v ", " --verbose
- verbose mode
- .TP
- .BR \-q ", " --quiet
- suppress warnings, interactivity and notifications.
- specify twice to suppress errors too.
- .TP
- .BR \-C ", " --[no-]check
- add integrity check computed from uncompressed data (default : enabled)
- .TP
- .BR \-t ", " --test
- Test the integrity of compressed files. This option is equivalent to \fB--decompress --stdout > /dev/null\fR.
- No files are created or removed.
- .TP
- .BR --
- All arguments after -- are treated as files
-
-
- .SH DICTIONARY BUILDER
- .PP
- \fBzstd\fR offers \fIdictionary\fR compression, useful for very small files and messages.
- It's possible to train \fBzstd\fR with some samples, the result of which is saved into a file called `dictionary`.
- Then during compression and decompression, make reference to the same dictionary.
- It will improve compression ratio of small files.
- Typical gains range from ~10% (at 64KB) to x5 better (at <1KB).
- .TP
- .B \--train FILEs
- use FILEs as training set to create a dictionary. The training set should contain a lot of small files (> 100),
- and weight typically 100x the target dictionary size (for example, 10 MB for a 100 KB dictionary)
- .TP
- .B \-o file
- dictionary saved into `file` (default: dictionary)
- .TP
- .B \--maxdict #
- limit dictionary to specified size (default : 112640)
- .TP
- .B \--dictID #
- A dictionary ID is a locally unique ID that a decoder can use to verify it is using the right dictionary.
- By default, zstd will create a 4-bytes random number ID.
- It's possible to give a precise number instead.
- 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.
- However, it's up to the dictionary manager to not assign twice the same ID to 2 different dictionaries.
- .TP
- .B \-s#
- dictionary selectivity level (default: 9)
- the smaller the value, the denser the dictionary, improving its efficiency but reducing its possible maximum size.
- .TP
- .B \--cover=k=#,d=#
- Use alternate dictionary builder algorithm named cover with parameters \fIk\fR and \fId\fR with \fId\fR <= \fIk\fR.
- Selects segments of size \fIk\fR with the 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 of size \fId\fR.
- Generally \fId\fR should be in the range [6, 24].
- Good values for \fIk\fR vary widely based on the input data, but a safe range is [32, 2048].
- Example: \fB--train --cover=k=64,d=8 FILEs\fR.
- .TP
- .B \--optimize-cover[=steps=#,k=#,d=#]
- If \fIsteps\fR is not specified, the default value of 32 is used.
- If \fIk\fR is not specified, \fIsteps\fR values in [16, 2048] are checked for each value of \fId\fR.
- If \fId\fR is not specified, the values checked are [6, 8, ..., 16].
-
- Runs the cover dictionary builder for each parameter set saves the optimal parameters and dictionary.
- Prints the optimal parameters and writes the optimal dictionary to the output file.
- Supports multithreading if \fBzstd\fR is compiled with threading support.
-
- The parameter \fIk\fR is more sensitve than \fId\fR, and is faster to optimize over.
- Suggested use is to run with a \fIsteps\fR <= 32 with neither \fIk\fR nor \fId\fR set.
- Once it completes, use the value of \fId\fR it selects with a higher \fIsteps\fR (in the range [256, 1024]).
- \fBzstd --train --optimize-cover FILEs
- \fBzstd --train --optimize-cover=d=d,steps=512 FILEs
- .TP
-
- .SH BENCHMARK
- .TP
- .B \-b#
- benchmark file(s) using compression level #
- .TP
- .B \-e#
- benchmark file(s) using multiple compression levels, from -b# to -e# (included).
- .TP
- .B \-i#
- minimum evaluation time, in seconds (default : 3s), benchmark mode only
- .TP
- .B \-B#
- cut file into independent blocks of size # (default: no block)
- .B \--priority=rt
- set process priority to real-time
-
- .SH ADVANCED COMPRESSION OPTIONS
- .TP
- .B \--zstd[=\fIoptions\fR]
- .PD
- \fBzstd\fR provides 22 predefined compression levels. The selected or default predefined compression level can be changed with advanced compression options.
- The \fIoptions\fR are provided as a comma-separated list. You may specify only the \fIoptions\fR you want to change and the rest will be taken from the selected or default compression level.
- The list of available \fIoptions\fR:
- .RS
-
- .TP
- .BI strategy= strat
- .PD 0
- .TP
- .BI strat= strat
- .PD
- Specify a strategy used by a match finder.
- .IP ""
- There are 8 strategies numbered from 0 to 7, from faster to stronger:
- 0=ZSTD_fast, 1=ZSTD_dfast, 2=ZSTD_greedy, 3=ZSTD_lazy, 4=ZSTD_lazy2, 5=ZSTD_btlazy2, 6=ZSTD_btopt, 7=ZSTD_btultra.
- .IP ""
-
- .TP
- .BI windowLog= wlog
- .PD 0
- .TP
- .BI wlog= wlog
- .PD
- Specify the maximum number of bits for a match distance.
- .IP ""
- The higher number of bits increases the chance to find a match what usually improves compression ratio.
- It also increases memory requirements for compressor and decompressor.
- .IP ""
- The minimum \fIwlog\fR is 10 (1 KiB) and the maximum is 25 (32 MiB) for 32-bit compilation and 27 (128 MiB) for 64-bit compilation.
- .IP ""
-
- .TP
- .BI hashLog= hlog
- .PD 0
- .TP
- .BI hlog= hlog
- .PD
- Specify the maximum number of bits for a hash table.
- .IP ""
- The bigger hash table causes less collisions what usually make compression faster but requires more memory during compression.
- .IP ""
- The minimum \fIhlog\fR is 6 (64 B) and the maximum is 25 (32 MiB) for 32-bit compilation and 27 (128 MiB) for 64-bit compilation.
-
- .TP
- .BI chainLog= clog
- .PD 0
- .TP
- .BI clog= clog
- .PD
- Specify the maximum number of bits for a hash chain or a binary tree.
- .IP ""
- The higher number of bits increases the chance to find a match what usually improves compression ratio.
- It also slows down compression speed and increases memory requirements for compression.
- This option is ignored for the ZSTD_fast strategy.
- .IP ""
- The minimum \fIclog\fR is 6 (64 B) and the maximum is 26 (64 MiB) for 32-bit compilation and 28 (256 MiB) for 64-bit compilation.
- .IP ""
-
- .TP
- .BI searchLog= slog
- .PD 0
- .TP
- .BI slog= slog
- .PD
- Specify the maximum number of searches in a hash chain or a binary tree using logarithmic scale.
- .IP ""
- The bigger number of searches increases the chance to find a match what usually improves compression ratio but decreases compression speed.
- .IP ""
- The minimum \fIslog\fR is 1 and the maximum is 24 for 32-bit compilation and 26 for 64-bit compilation.
- .IP ""
-
- .TP
- .BI searchLength= slen
- .PD 0
- .TP
- .BI slen= slen
- .PD
- Specify the minimum searched length of a match in a hash table.
- .IP ""
- The bigger search length usually decreases compression ratio but improves decompression speed.
- .IP ""
- The minimum \fIslen\fR is 3 and the maximum is 7.
- .IP ""
-
- .TP
- .BI targetLength= tlen
- .PD 0
- .TP
- .BI tlen= tlen
- .PD
- Specify the minimum match length that causes a match finder to interrupt searching of better matches.
- .IP ""
- The bigger minimum match length usually improves compression ratio but decreases compression speed.
- This option is used only with ZSTD_btopt and ZSTD_btultra strategies.
- .IP ""
- The minimum \fItlen\fR is 4 and the maximum is 999.
- .IP ""
-
- .PP
- .B An example
- .br
- The following parameters sets advanced compression options to predefined level 19 for files bigger than 256 KB:
- .IP ""
- \fB--zstd=\fRwindowLog=23,chainLog=23,hashLog=22,searchLog=6,searchLength=3,targetLength=48,strategy=6
-
- .SH BUGS
- Report bugs at:- https://github.com/facebook/zstd/issues
-
- .SH AUTHOR
+ \fB\-#\fR
+ \fB#\fR compression level [1\-19] (default: 3)
+ .
+ .TP
+ \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\.
+ .
+ .TP
+ \fB\-T#\fR, \fB\-\-threads=#\fR
+ Compress using \fB#\fR threads (default: 1)\. If \fB#\fR is 0, attempt to detect and use the number of physical CPU cores\. This modifier does nothing if \fBzstd\fR is compiled without multithread support\.
+ .
+ .TP
+ \fB\-D file\fR
+ use \fBfile\fR as Dictionary to compress or decompress FILE(s)
+ .
+ .TP
+ \fB\-\-nodictID\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\.
+ .
+ .TP
+ \fB\-o file\fR
+ save result into \fBfile\fR (only possible with a single \fIINPUT\-FILE\fR)
+ .
+ .TP
+ \fB\-f\fR, \fB\-\-force\fR
+ overwrite output without prompting, and (de)compress symbolic links
+ .
+ .TP
+ \fB\-c\fR, \fB\-\-stdout\fR
+ force write to standard output, even if it is the console
+ .
+ .TP
+ \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\.
+ .
+ .TP
+ \fB\-\-rm\fR
+ remove source file(s) after successful compression or decompression
+ .
+ .TP
+ \fB\-k\fR, \fB\-\-keep\fR
+ keep source file(s) after successful compression or decompression\. This is the default behavior\.
+ .
+ .TP
+ \fB\-r\fR
+ operate recursively on dictionaries
+ .
+ .TP
+ \fB\-h\fR/\fB\-H\fR, \fB\-\-help\fR
+ display help/long help and exit
+ .
+ .TP
+ \fB\-V\fR, \fB\-\-version\fR
+ display version number and exit
+ .
+ .TP
+ \fB\-v\fR
+ verbose mode
+ .
+ .TP
+ \fB\-q\fR, \fB\-\-quiet\fR
+ suppress warnings, interactivity, and notifications\. specify twice to suppress errors too\.
+ .
+ .TP
+ \fB\-C\fR, \fB\-\-[no\-]check\fR
+ add integrity check computed from uncompressed data (default : enabled)
+ .
+ .TP
+ \fB\-\-\fR
+ All arguments after \fB\-\-\fR are treated as files
+ .
+ .SH "DICTIONARY BUILDER"
+ \fBzstd\fR offers \fIdictionary\fR compression, useful for very small files and messages\. It\'s possible to train \fBzstd\fR with some samples, the result of which is saved into a file called a \fBdictionary\fR\. Then during compression and decompression, reference the same dictionary\. It will improve compression ratio of small files\. Typical gains range from 10% (at 64KB) to x5 better (at <1KB)\.
+ .
+ .TP
+ \fB\-\-train FILEs\fR
+ Use FILEs as training set to create a dictionary\. The training set should contain a lot of small files (> 100), and weight typically 100x the target dictionary size (for example, 10 MB for a 100 KB dictionary)\.
+ .
+ .IP
+ Supports multithreading if \fBzstd\fR is compiled with threading support\. Additional parameters can be specified with \fB\-\-train\-cover\fR\. The legacy dictionary builder can be accessed with \fB\-\-train\-legacy\fR\. Equivalent to \fB\-\-train\-cover=d=8,steps=4\fR\.
+ .
+ .TP
+ \fB\-o file\fR
+ Dictionary saved into \fBfile\fR (default name: dictionary)\.
+ .
+ .TP
+ \fB\-\-maxdict=#\fR
+ Limit dictionary to specified size (default: 112640)\.
+ .
+ .TP
+ \fB\-\-dictID=#\fR
+ A dictionary ID is a locally unique ID that a decoder can use to verify it is using the right dictionary\. By default, zstd will create a 4\-bytes random number ID\. It\'s possible to give a precise number instead\. 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\. However, it\'s up to the dictionary manager to not assign twice the same ID to 2 different dictionaries\.
+ .
+ .TP
+ \fB\-\-train\-cover[=k#,d=#,steps=#]\fR
+ 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\. Requires that \fId\fR <= \fIk\fR\.
+ .
+ .IP
+ 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]\. Supports multithreading if \fBzstd\fR is compiled with threading support\.
+ .
+ .IP
+ Examples:
+ .
+ .IP
+ \fBzstd \-\-train\-cover FILEs\fR
+ .
+ .IP
+ \fBzstd \-\-train\-cover=k=50,d=8 FILEs\fR
+ .
+ .IP
+ \fBzstd \-\-train\-cover=d=8,steps=500 FILEs\fR
+ .
+ .IP
+ \fBzstd \-\-train\-cover=k=50 FILEs\fR
+ .
+ .TP
+ \fB\-\-train\-legacy[=selectivity=#]\fR
+ 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 possible maximum size\. \fB\-\-train\-legacy=s=#\fR is also accepted\.
+ .
+ .IP
+ Examples:
+ .
+ .IP
+ \fBzstd \-\-train\-legacy FILEs\fR
+ .
+ .IP
+ \fBzstd \-\-train\-legacy=selectivity=8 FILEs\fR
+ .
+ .SH "BENCHMARK"
+ .
+ .TP
+ \fB\-b#\fR
+ benchmark file(s) using compression level #
+ .
+ .TP
+ \fB\-e#\fR
+ benchmark file(s) using multiple compression levels, from \fB\-b#\fR to \fB\-e#\fR (inclusive)
+ .
+ .TP
+ \fB\-i#\fR
+ minimum evaluation time, in seconds (default : 3s), benchmark mode only
+ .
+ .TP
+ \fB\-B#\fR
+ cut file into independent blocks of size # (default: no block)
+ .
+ .TP
+ \fB\-\-priority=rt\fR
+ set process priority to real\-time
+ .
+ .SH "ADVANCED COMPRESSION OPTIONS"
+ .
+ .SS "\-\-zstd[=options]:"
+ \fBzstd\fR provides 22 predefined compression levels\. The selected or default predefined compression level can be changed 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:
+ .
+ .TP
+ \fBstrategy\fR=\fIstrat\fR, \fBstrat\fR=\fIstrat\fR
+ Specify a strategy used by a match finder\.
+ .
+ .IP
+ There are 8 strategies numbered from 0 to 7, from faster to stronger: 0=ZSTD_fast, 1=ZSTD_dfast, 2=ZSTD_greedy, 3=ZSTD_lazy, 4=ZSTD_lazy2, 5=ZSTD_btlazy2, 6=ZSTD_btopt, 7=ZSTD_btopt2\.
+ .
+ .TP
+ \fBwindowLog\fR=\fIwlog\fR, \fBwlog\fR=\fIwlog\fR
+ Specify the maximum number of bits for a match distance\.
+ .
+ .IP
+ 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 27 (128 MiB)\.
+ .
+ .TP
+ \fBhashLog\fR=\fIhlog\fR, \fBhlog\fR=\fIhlog\fR
+ Specify the maximum number of bits for a hash table\.
+ .
+ .IP
+ Bigger hash tables cause less collisions which usually makes compression faster, but requires more memory during compression\.
+ .
+ .IP
+ The minimum \fIhlog\fR is 6 (64 B) and the maximum is 26 (128 MiB)\.
+ .
+ .TP
+ \fBchainLog\fR=\fIclog\fR, \fBclog\fR=\fIclog\fR
+ Specify the maximum number of bits for a hash chain or a binary tree\.
+ .
+ .IP
+ 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 ZSTD_fast strategy\.
+ .
+ .IP
+ The minimum \fIclog\fR is 6 (64 B) and the maximum is 28 (256 MiB)\.
+ .
+ .TP
+ \fBsearchLog\fR=\fIslog\fR, \fBslog\fR=\fIslog\fR
+ Specify the maximum number of searches in a hash chain or a binary tree using logarithmic scale\.
+ .
+ .IP
+ More searches increases the chance to find a match which usually increases compression ratio but decreases compression speed\.
+ .
+ .IP
+ The minimum \fIslog\fR is 1 and the maximum is 26\.
+ .
+ .TP
+ \fBsearchLength\fR=\fIslen\fR, \fBslen\fR=\fIslen\fR
+ Specify the minimum searched length of a match in a hash table\.
+ .
+ .IP
+ Larger search lengths usually decrease compression ratio but improve decompression speed\.
+ .
+ .IP
+ The minimum \fIslen\fR is 3 and the maximum is 7\.
+ .
+ .TP
+ \fBtargetLen\fR=\fItlen\fR, \fBtlen\fR=\fItlen\fR
+ Specify the minimum match length that causes a match finder to stop searching for better matches\.
+ .
+ .IP
+ A larger minimum match length usually improves compression ratio but decreases compression speed\. This option is only used with strategies ZSTD_btopt and ZSTD_btopt2\.
+ .
+ .IP
+ The minimum \fItlen\fR is 4 and the maximum is 999\.
+ .
+ .TP
+ \fBoverlapLog\fR=\fIovlog\fR, \fBovlog\fR=\fIovlog\fR
+ 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\.
+ .
+ .IP
+ The minimum \fIovlog\fR is 0, and the maximum is 9\. 0 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 amount of reload by a factor 2\. Default \fIovlog\fR is 6, which means "reload \fBwindowSize / 8\fR"\. Exception : the maximum compression level (22) has a default \fIovlog\fR of 9\.
+ .
+ .SS "\-B#:"
+ Select the size of each compression job\. This parameter is available only when multi\-threading is enabled\. Default value is \fB4 * windowSize\fR, which means it varies depending on compression level\. \fB\-B#\fR makes it possible to select a custom value\. Note that job size must respect a minimum value which is enforced transparently\. This minimum is either 1 MB, or \fBoverlapSize\fR, whichever is largest\.
+ .
+ .SS "Example"
+ The following parameters sets advanced compression options to those of predefined level 19 for files bigger than 256 KB:
+ .
+ .P
+ \fB\-\-zstd\fR=windowLog=23,chainLog=23,hashLog=22,searchLog=6,searchLength=3,targetLength=48,strategy=6
+ .
+ .SH "BUGS"
+ Report bugs at: https://github\.com/facebook/zstd/issues
+ .
+ .SH "AUTHOR"
Yann Collet