Faster Compression by zstd

less than 1 minute read

Published:

Recently I was required to transfer a bulk of data containing millions of sparse files, where the archive and compression algorithms became a must yet bottleneck to my server. A compression algorithm with full parallelism, zstd, can better address the problem. Some tips are recorded in post.

Installation

zstd suggests install via self building.

$ wget https://github.com/facebook/zstd/releases/download/v1.5.2/zstd-1.5.2.tar.gz
$ tar -xf zstd-1.5.2.tar.gz && cd zstd-1.5.2
$ sudo make         # compile
$ sudo make install

Enable Parallelism

zstd provides elaborated commandline options. Using man zstd to have a check.

For parallelism we can simply pass --fast= option into zstd cli.

$ zstd --fast=1  # default speed
$ zstd --fast=15 # maximum speed

Use with tar Archiver

zstd is a compression implementation supports co-working with tar archiver.

$ tar -I "zstd --fast=15" -cvf dest.tar.zst srcdir # compression
$ tar -I "zstd --fast=15" -xvf src.tar.zst         # decompression