knowledge/technology/files/Zstd Compression.md

7.6 KiB

obj aliases mime extension repo wiki rev
format
zstd
application/zstd zst https://github.com/facebook/zstd https://en.wikipedia.org/wiki/Zstd 2024-03-03

Zstd

Zstandard, also known as zstd, is a fast lossless compression algorithm. It offers both excellent compression ratios and high-speed compression and decompression. Zstandard is designed to be highly versatile, suitable for a wide range of applications from data compression to streaming and archiving.

Features

High Compression Ratios

Zstandard achieves competitive compression ratios compared to other compression algorithms like gzip, lz4, and xz. It offers the flexibility to adjust compression levels according to specific requirements, balancing between speed and compression efficiency.

High-Speed Compression and Decompression

One of the key strengths of Zstandard is its impressive speed. It is optimized for both compression and decompression, making it suitable for scenarios where fast processing is essential, such as real-time data streaming and high-performance computing.

Streaming Compression

Zstandard supports streaming compression and decompression, allowing data to be compressed or decompressed in chunks without needing to hold the entire dataset in memory. This feature is particularly useful for applications dealing with large datasets or continuous streams of data.

Dictionary Compression

Zstandard includes support for dictionary compression, where a predefined dictionary can be used to improve compression ratios for specific types of data. This feature is beneficial for scenarios where the data has a predictable structure or repeating patterns.

Multi-Threading Support

Zstandard utilizes multi-threading to leverage the processing power of modern multi-core CPUs, speeding up compression and decompression tasks even further. This feature enhances performance, especially on systems with multiple CPU cores.

Usage

Usage: zstd [OPTIONS...] [INPUT... | -] [-o OUTPUT]

Options

Option Description
-o OUTPUT Write output to a single file, OUTPUT.
-k, --keep Preserve INPUT file(s). [Default]
--rm Remove INPUT file(s) after successful (de)compression.
-# Desired compression level, where # is a number between 1 and 19; lower numbers provide faster compression, higher numbers yield better compression ratios. [Default: 3]
-d, --decompress Perform decompression.
-D DICT Use DICT as the dictionary for compression or decompression.
-f, --force Disable input and output checks. Allows overwriting existing files, receiving input from the console, printing output to STDOUT, and operating on links, block devices, etc.
-c, --stdout Write to STDOUT (even if it is a console) and keep the INPUT file(s).
-v, --verbose Enable verbose output; pass multiple times to increase verbosity.
-q, --quiet Suppress warnings; pass twice to suppress errors.
--[no-]progress Forcibly show/hide the progress counter. NOTE: Any (de)compressed output to terminal will mix with progress counter text.
-r Operate recursively on directories.
--filelist LIST Read a list of files to operate on from LIST.
--output-dir-flat DIR Store processed files in DIR.
--output-dir-mirror DIR Store processed files in DIR, respecting original directory structure.
--[no-]asyncio Use asynchronous IO. [Default: Enabled]
--[no-]check Add XXH64 integrity checksums during compression. [Default: Add, Validate] If -d is present, ignore/validate checksums during decompression.
--ultra Enable levels beyond 19, up to 22; requires more memory.
--fast[=#] Use to very fast compression levels. [Default: 1]
--long[=#] Enable long distance matching with window log #. [Default: 27]
-T# Spawn # compression threads. [Default: 1; pass 0 for core count.]
-l Print information about Zstandard-compressed files.
--test Test compressed file integrity.
-M# Set the memory usage limit to # megabytes.
--[no-]sparse Enable sparse mode. [Default: Enabled for files, disabled for STDOUT.]
--[no-]pass-through Pass through uncompressed files as-is. [Default: Disabled]