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).
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
.
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.
News
-
Thousands of Linux Servers Infected with Stealth Malware Since 2021
Perfctl is capable of remaining undetected, which makes it dangerous and hard to mitigate.
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.
-
Hacker Successfully Runs Linux on a CPU from the Early ‘70s
From the office of "Look what I can do," Dmitry Grinberg was able to get Linux running on a processor that was created in 1971.
-
OSI and LPI Form Strategic Alliance
With a goal of strengthening Linux and open source communities, this new alliance aims to nurture the growth of more highly skilled professionals.
-
Fedora 41 Beta Available with Some Interesting Additions
If you're a Fedora fan, you'll be excited to hear the beta version of the latest release is now available for testing and includes plenty of updates.
-
AlmaLinux Unveils New Hardware Certification Process
The AlmaLinux Hardware Certification Program run by the Certification Special Interest Group (SIG) aims to ensure seamless compatibility between AlmaLinux and a wide range of hardware configurations.
-
Wind River Introduces eLxr Pro Linux Solution
eLxr Pro offers an end-to-end Linux solution backed by expert commercial support.
-
Juno Tab 3 Launches with Ubuntu 24.04
Anyone looking for a full-blown Linux tablet need look no further. Juno has released the Tab 3.
-
New KDE Slimbook Plasma Available for Preorder
Powered by an AMD Ryzen CPU, the latest KDE Slimbook laptop is powerful enough for local AI tasks.