At night due to the need to deal with disk alarm, the log compression, in this compression used gzip and XZ software to compress the text, the results of compression is very surprising.
The reason for the curiosity about XZ is that when you download the kernel source code, you can often see the. xz format package, and its size is smaller than the. GZ and. bz2 format files. Let's start with a brief introduction to Gzip and XZ:
- Gzip:gzip was originally created by Jean-loup Gailly and Mark Adler for file compression of Unⅸ systems. We often use files with the. gz suffix in Linux, which are in gzip format. Nowadays it has become a very popular data compression format, or a file format, used on the Internet. More detailed information about gzip can be found in the Baidu Encyclopedia.
- XZ:XZ is a compressed file format that uses Lzma SDK compression and the target file is 30% smaller than the gzip compressed file (. gz or tgz), which is 15% smaller than bz2. A more detailed introduction can be found in Wikipedia.
Here due to the limited disk space, we use the 9 parameter to compress, using the highest compression ratio per compression, using the fame as follows:
- Gzip:gzip-9-C source_filename > source_filename.gz
- Xz:xz-9-C source_filename > Source_filename.xz
The final test results are as follows:
You can see the source file iqas-2015-07-28 size of 35G, after gzip compression, the final file is 4.6G size, compression ratio of about 1:8, this is a good result, but then look at the XZ compressed after the size of the file is 401M, This is an order of magnitude smaller than gzip, and the compression ratio is close to 1:90, which saves a lot of space for text storage. However, it is important to note that the XZ 9-level compression is time-consuming and memory-intensive, and if time and memory are sufficient, you can consider this method, and if the time and memory are tight, then we recommend using gzip.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
A simple comparison of the compression software gzip and XZ