File Compression for Modern Computing
Compression Dictionaries
A dictionary is a file that stores the compression settings for small files. A dictionary is assembled from a group of typical small files that contain similar information, preferably over 100 files. For greatest efficiency, their combined size should be about one hundred times the size of the dictionary produced from them. If the files used are fewer or smaller in size than recommended, zstd
will display a warning but still allow the dictionary to be created (Figure 2).
![](/var/linux_magazin/storage/images/issues/2018/215/command-line-zstd/figure-2/733700-1-eng-US/Figure-2_large.png)
To create a dictionary, use the command:
zstd --train FILES
The dictionary will be saved with the default name dictionary, and a default size of 112,640KB. To give the dictionary its own name, add the name to the train
option; for example, a dictionary called quick would be named using the option --train-quick
. You can also force the dictionary to use the most compressed files by specifying the number of files to use after the name; for example,
--train-quick=k=NUMBER OF FILES
A specific size can be added with the option --maxdict=SIZE
, and a specific ID with --dicID=NUMBER
, which makes communication with the dictionary faster than relying on the name. To use a dictionary, add the option -D FILE
to the command. Nothing in the output will indicate that the dictionary is in use.
In general, the smaller the file, the greater the improvement in compression. According to the man page, a dictionary can only increase the compression of a 64KB file by 10 percent, compared with a 500 percent improvement for a file of less than 1KB.
Benchmarking
To use zstd
to its full potential requires experimentation. To use the advanced compression options, you probably will need to research the compression algorithm. However, with the methods listed here, zstd
is sure to be efficient.
But how efficient? More particularly, how does zstd
compare with other compression tools? zstd
provides its own answer with a small selection of benchmarking options. To start, you can use the option -bLEVEL
to set the compression level to test. Alternately, you can use -bLEVEL
to indicate the start of a range of compression levels and use -eLEVEL
to indicate the end of the range (Figure 3). You can also change the default of three seconds for the length of the testing with -iSECONDS
. Of course, you can also make notes as you gain experience with zstd
.
![](/var/linux_magazin/storage/images/issues/2018/215/command-line-zstd/figure-3/733703-1-eng-US/Figure-3_large.png)
zstd
has been released recently enough that, in many ways, it is still an expert's tool. However, although the documentation can be spotty for the advanced features, there is still enough to make zstd
an alternative tool for any level of user, especially those who want a compression tool designed for modern computing.
Infos
- zstd: https://en.wikipedia.org/wiki/Zstandard
- LZ77 algorithm: https://en.wikipedia.org/wiki/LZ77_and_LZ78
« Previous 1 2
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
![Learn More](https://www.linux-magazine.com/var/linux_magazin/storage/images/media/linux-magazine-eng-us/images/misc/learn-more/834592-1-eng-US/Learn-More_medium.png)
News
-
NVIDIA Released Driver for Upcoming NVIDIA 560 GPU for Linux
Not only has NVIDIA released the driver for its upcoming CPU series, it's the first release that defaults to using open-source GPU kernel modules.
-
OpenMandriva Lx 24.07 Released
If you’re into rolling release Linux distributions, OpenMandriva ROME has a new snapshot with a new kernel.
-
Kernel 6.10 Available for General Usage
Linus Torvalds has released the 6.10 kernel and it includes significant performance increases for Intel Core hybrid systems and more.
-
TUXEDO Computers Releases InfinityBook Pro 14 Gen9 Laptop
Sporting either AMD or Intel CPUs, the TUXEDO InfinityBook Pro 14 is an extremely compact, lightweight, sturdy powerhouse.
-
Google Extends Support for Linux Kernels Used for Android
Because the LTS Linux kernel releases are so important to Android, Google has decided to extend the support period beyond that offered by the kernel development team.
-
Linux Mint 22 Stable Delayed
If you're anxious about getting your hands on the stable release of Linux Mint 22, it looks as if you're going to have to wait a bit longer.
-
Nitrux 3.5.1 Available for Install
The latest version of the immutable, systemd-free distribution includes an updated kernel and NVIDIA driver.
-
Debian 12.6 Released with Plenty of Bug Fixes and Updates
The sixth update to Debian "Bookworm" is all about security mitigations and making adjustments for some "serious problems."
-
Canonical Offers 12-Year LTS for Open Source Docker Images
Canonical is expanding its LTS offering to reach beyond the DEB packages with a new distro-less Docker image.
-
Plasma Desktop 6.1 Released with Several Enhancements
If you're a fan of Plasma Desktop, you should be excited about this new point release.