pzstd man page

zstd, unzstd, zstdcat — Compress or decompress .zst files

Synopsis

zstd [Options] [-|INPUT-FILE] [-o <OUTPUT-FILE>]

unzstd is equivalent to zstd -d
zstdcat is equivalent to zstd -dcf

Description

zstd is a fast lossless compression algorithm and data compression tool, with command line syntax similar to gzip (1) and xz (1) . It is based on the LZ77 family, with further FSE & huff0 entropy stages. zstd 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.

zstd 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 --rm command.
- When compressing a single file, zstd displays progress notifications and result summary by default.
  Use -q to turn them off

zstd compresses or decompresses each file according to the selected operation mode. If no files are given or file is -, zstd reads from standard input and writes the processed data to standard output. zstd will refuse (display an error and skip the file) to write compressed data to standard output if it is a terminal. Similarly, zstd will refuse to read compressed data from standard input if it is a terminal.

Unless --stdout or -o is specified, files are written to a new file whose name is derived from the source file name:

Concatenation with .zst files

It is possible to concatenate .zst files as is. zstd will decompress such files as if they were a single .zst file.

Options

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.

KiB

Multiply the integer by 1,024 (2^10). Ki, K, and KB are accepted as synonyms for KiB.

MiB

Multiply the integer by 1,048,576 (2^20). Mi, M, and MB are accepted as synonyms for MiB.

Operation mode

If multiple operation mode options are given, the last one takes effect.

-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, unzstd implies --decompress).

-d, --decompress, --uncompress

Decompress.

-t, --test

Test the integrity of compressed files. This option is equivalent to --decompress --stdout except that the decompressed data is discarded instead of being written to standard output. No files are created or removed.

-b#

benchmark file(s) using compression level #

--train FILEs

use FILEs as training set to create a dictionary. The training set should contain a lot of small files (> 100).

Operation modifiers

-#

# compression level [1-19] (default:3)

--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.

-D file

use `file` as Dictionary to compress or decompress FILE(s)

--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.

-o file

save result into `file` (only possible with a single INPUT-FILE)

-f, --force

overwrite output without prompting

-c, --stdout

force write to standard output, even if it is the console

--[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.

--rm

remove source file(s) after successful compression or decompression

-k, --keep

keep source file(s) after successful compression or decompression.
This is the default behavior.

-r

operate recursively on directories

-h/-H, --help

display help/long help and exit

-V, --version

display Version number and exit

-v, --verbose

verbose mode

-q, --quiet

suppress warnings, interactivity and notifications.
specify twice to suppress errors too.

-C, --[no-]check

add integrity check computed from uncompressed data (default : enabled)

-t, --test

Test the integrity of compressed files. This option is equivalent to --decompress --stdout > /dev/null.
No files are created or removed.

--

All arguments after -- are treated as files

Parallel Zstd OPTIONS

Additional options for the pzstd utility

-p, --processes

number of threads to use for (de)compression (default:4)

Dictionary Builder

zstd offers dictionary compression, useful for very small files and messages. It's possible to train zstd 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).

--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)

-o file

dictionary saved into `file` (default: dictionary)

--maxdict #

limit dictionary to specified size (default : 112640)

--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.

-s#

dictionary selectivity level (default: 9)
the smaller the value, the denser the dictionary, improving its efficiency but reducing its possible maximum size.

--cover=k=#,d=#

Use alternate dictionary builder algorithm named cover with parameters k and d with d <= k.
Selects segments of size k 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 d.
Generally d should be in the range [6, 24].
Good values for k vary widely based on the input data, but a safe range is [32, 2048].
Example: --train --cover=k=64,d=8 FILEs.

--optimize-cover[=steps=#,k=#,d=#]

If steps is not specified, the default value of 32 is used.
If k is not specified, steps values in [16, 2048] are checked for each value of d.
If d 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 zstd is compiled with threading support.

The parameter k is more sensitve than d, and is faster to optimize over.
Suggested use is to run with a steps <= 32 with neither k nor d set.
Once it completes, use the value of d it selects with a higher steps (in the range [256, 1024]).
zstd --train --optimize-cover FILEs
zstd --train --optimize-cover=d=d,steps=512 FILEs

Benchmark

-b#

benchmark file(s) using compression level #

-e#

benchmark file(s) using multiple compression levels, from -b# to -e# (included).

-i#

minimum evaluation time, in seconds (default : 3s), benchmark mode only

-B#

cut file into independent blocks of size # (default: no block)

Advanced Compression Options

--zstd[=options]

zstd provides 22 predefined compression levels. The selected or default predefined compression level can be changed with advanced compression options. The options 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 options:

strategy=strat
strat=strat

Specify a strategy used by a match finder.

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.

windowLog=wlog
wlog=wlog

Specify the maximum number of bits for a match distance.

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.

The minimum wlog is 10 (1 KiB) and the maximum is 25 (32 MiB) for 32-bit compilation and 27 (128 MiB) for 64-bit compilation.

hashLog=hlog
hlog=hlog

Specify the maximum number of bits for a hash table.

The bigger hash table causes less collisions what usually make compression faster but requires more memory during compression.

The minimum hlog is 6 (64 B) and the maximum is 25 (32 MiB) for 32-bit compilation and 27 (128 MiB) for 64-bit compilation.

chainLog=clog
clog=clog

Specify the maximum number of bits for a hash chain or a binary tree.

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.

The minimum clog is 6 (64 B) and the maximum is 26 (64 MiB) for 32-bit compilation and 28 (256 MiB) for 64-bit compilation.

searchLog=slog
slog=slog

Specify the maximum number of searches in a hash chain or a binary tree using logarithmic scale.

The bigger number of searches increases the chance to find a match what usually improves compression ratio but decreases compression speed.

The minimum slog is 1 and the maximum is 24 for 32-bit compilation and 26 for 64-bit compilation.

searchLength=slen
slen=slen

Specify the minimum searched length of a match in a hash table.

The bigger search length usually decreases compression ratio but improves decompression speed.

The minimum slen is 3 and the maximum is 7.

targetLength=tlen
tlen=tlen

Specify the minimum match length that causes a match finder to interrupt searching of better matches.

The bigger minimum match length usually improves compression ratio but decreases compression speed. This option is used only with ZSTD_btopt and ZSTD_btopt2 strategies.

The minimum tlen is 4 and the maximum is 999.

An example
The following parameters sets advanced compression options to predefined level 19 for files bigger than 256 KB:

--zstd=windowLog=23,chainLog=23,hashLog=22,searchLog=6,searchLength=3,targetLength=48,strategy=6

Bugs

Report bugs at:- https://github.com/facebook/zstd/issues

Author

Yann Collet

Info

2015-08-22 zstd User Commands