zstd/programs
2017-08-31 18:08:37 -07:00
..
windres fixed g++ prototype mismatch 2017-06-04 23:52:00 -07:00
.gitignore cli : Display supported formats on -vV command 2017-08-19 13:33:50 -07:00
bench.c Merge branch 'longRangeMatcher' into dev 2017-08-31 18:08:37 -07:00
bench.h updated a bunch of headers 2017-08-18 16:52:05 -07:00
BUCK Add BUCK files for Nuclide support 2017-01-27 10:43:12 -08:00
datagen.c updated a bunch of headers 2017-08-18 16:52:05 -07:00
datagen.h updated a bunch of headers 2017-08-18 16:52:05 -07:00
dibio.c updated a bunch of headers 2017-08-18 16:52:05 -07:00
dibio.h updated a bunch of headers 2017-08-18 16:52:05 -07:00
fileio.c Remove formatting-only changes 2017-08-23 10:24:19 -07:00
fileio.h Remove test parameter 2017-08-21 10:09:06 -07:00
Makefile changed target allarch into allzstd 2017-08-31 14:30:52 -07:00
platform.h fixed a few headers that were too hastily copy/pasted during last license change 2017-08-21 11:24:32 -07:00
README.md cli : Display supported formats on -vV command 2017-08-19 13:33:50 -07:00
util.h improved console log of utils.h 2017-08-31 16:58:47 -07:00
zstd.1 cli : Display supported formats on -vV command 2017-08-19 13:33:50 -07:00
zstd.1.md cli : Display supported formats on -vV command 2017-08-19 13:33:50 -07:00
zstdcli.c Remove test parameter 2017-08-21 10:09:06 -07:00
zstdgrep added zstdgrep 2016-12-02 15:57:07 -08:00
zstdless zstdless: add shebang and quote $@ 2016-12-22 17:40:10 -05:00

Command Line Interface for Zstandard library

Command Line Interface (CLI) can be created using the make command without any additional parameters. There are however other Makefile targets that create different variations of CLI:

  • zstd : default CLI supporting gzip-like arguments; includes dictionary builder, benchmark, and support for decompression of legacy zstd formats
  • zstd_nolegacy : Same as zstd but without support for legacy zstd formats
  • zstd-small : CLI optimized for minimal size; no dictionary builder, no benchmark, and no support for legacy zstd formats
  • zstd-compress : version of CLI which can only compress into zstd format
  • zstd-decompress : version of CLI which can only decompress zstd format

Compilation variables

zstd scope can be altered by modifying the following compilation variables :

  • HAVE_THREAD : multithreading is automatically enabled when pthread is detected. It's possible to disable multithread support, by setting HAVE_THREAD=0 . Example : make zstd HAVE_THREAD=0 It's also possible to force compilation with multithread support, using HAVE_THREAD=1. In which case, linking stage will fail if pthread library cannot be found. This might be useful to prevent silent feature disabling.

  • HAVE_ZLIB : zstd can compress and decompress files in .gz format. This is ordered through command --format=gzip. Alternatively, symlinks named gzip or gunzip will mimic intended behavior. .gz support is automatically enabled when zlib library is detected at build time. It's possible to disable .gz support, by setting HAVE_ZLIB=0. Example : make zstd HAVE_ZLIB=0 It's also possible to force compilation with zlib support, using HAVE_ZLIB=1. In which case, linking stage will fail if zlib library cannot be found. This might be useful to prevent silent feature disabling.

  • HAVE_LZMA : zstd can compress and decompress files in .xz and .lzma formats. This is ordered through commands --format=xz and --format=lzma respectively. Alternatively, symlinks named xz, unxz, lzma, or unlzma will mimic intended behavior. .xz and .lzma support is automatically enabled when lzma library is detected at build time. It's possible to disable .xz and .lzma support, by setting HAVE_LZMA=0 . Example : make zstd HAVE_LZMA=0 It's also possible to force compilation with lzma support, using HAVE_LZMA=1. In which case, linking stage will fail if lzma library cannot be found. This might be useful to prevent silent feature disabling.

  • ZSTD_LEGACY_SUPPORT : zstd can decompress files compressed by older versions of zstd. Starting v0.8.0, all versions of zstd produce frames compliant with the specification, and are therefore compatible. But older versions (< v0.8.0) produced different, incompatible, frames. By default, zstd supports decoding legacy formats >= v0.4.0 (ZSTD_LEGACY_SUPPORT=4). This can be altered by modifying this compilation variable. ZSTD_LEGACY_SUPPORT=1 means "support all formats >= v0.1.0". ZSTD_LEGACY_SUPPORT=2 means "support all formats >= v0.2.0", and so on. ZSTD_LEGACY_SUPPORT=0 means DO NOT support any legacy format. if ZSTD_LEGACY_SUPPORT >= 8, it's the same as 0, since there is no legacy format after 7. Note : zstd only supports decoding older formats, and cannot generate any legacy format.

Aggregation of parameters

CLI supports aggregation of parameters i.e. -b1, -e18, and -i1 can be joined into -b1e18i1.

Dictionary builder in Command Line Interface

Zstd offers a training mode, which can be used to tune the algorithm for a selected type of data, by providing it with a few samples. The result of the training is stored in a file selected with the -o option (default name is dictionary), which can be loaded before compression and decompression.

Using a dictionary, the compression ratio achievable on small data improves dramatically. These compression gains are achieved while simultaneously providing faster compression and decompression speeds. Dictionary work if there is some correlation in a family of small data (there is no universal dictionary). Hence, deploying one dictionary per type of data will provide the greater benefits. Dictionary gains are mostly effective in the first few KB. Then, the compression algorithm will rely more and more on previously decoded content to compress the rest of the file.

Usage of the dictionary builder and created dictionaries with CLI:

  1. Create the dictionary : zstd --train PathToTrainingSet/* -o dictionaryName
  2. Compress with the dictionary: zstd FILE -D dictionaryName
  3. Decompress with the dictionary: zstd --decompress FILE.zst -D dictionaryName

Benchmark in Command Line Interface

CLI includes in-memory compression benchmark module for zstd. The benchmark is conducted using given filenames. The files are read into memory and joined together. It makes benchmark more precise as it eliminates I/O overhead. Multiple filenames can be supplied, as multiple parameters, with wildcards, or names of directories can be used as parameters with -r option.

The benchmark measures ratio, compressed size, compression and decompression speed. One can select compression levels starting from -b and ending with -e. The -i parameter selects minimal time used for each of tested levels.

Usage of Command Line Interface

The full list of options can be obtained with -h or -H parameter:

Usage :
      zstd [args] [FILE(s)] [-o file]

FILE    : a filename
          with no FILE, or when FILE is - , read standard input
Arguments :
 -#     : # compression level (1-19, default:3)
 -d     : decompression
 -D file: use `file` as Dictionary
 -o file: result stored into `file` (only if 1 input file)
 -f     : overwrite output without prompting and (de)compress links
--rm    : remove source file(s) after successful de/compression
 -k     : preserve source file(s) (default)
 -h/-H  : display help/long help and exit

Advanced arguments :
 -V     : display Version number and exit
 -v     : verbose mode; specify multiple times to increase verbosity
 -q     : suppress warnings; specify twice to suppress errors too
 -c     : force write to standard output, even if it is the console
 -l     : print information about zstd compressed files
--ultra : enable levels beyond 19, up to 22 (requires more memory)
--no-dictID : don't write dictID into header (dictionary compression)
--[no-]check : integrity check (default:enabled)
 -r     : operate recursively on directories
--format=gzip : compress files to the .gz format
--format=xz : compress files to the .xz format
--format=lzma : compress files to the .lzma format
--test  : test compressed file integrity
--[no-]sparse : sparse mode (default:disabled)
 -M#    : Set a memory usage limit for decompression
--      : All arguments after "--" are treated as files

Dictionary builder :
--train ## : create a dictionary from a training set of files
--train-cover[=k=#,d=#,steps=#] : use the cover algorithm with optional args
--train-legacy[=s=#] : use the legacy algorithm with selectivity (default: 9)
 -o file : `file` is dictionary name (default: dictionary)
--maxdict=# : limit dictionary to specified size (default : 112640)
--dictID=# : force dictionary ID to specified value (default: random)

Benchmark arguments :
 -b#    : benchmark file(s), using # compression level (default : 1)
 -e#    : test all compression levels from -bX to # (default: 1)
 -i#    : minimum evaluation time in seconds (default : 3s)
 -B#    : cut file into independent blocks of size # (default: no block)
--priority=rt : set process priority to real-time