I’m playing with gzip / pigz to concatenate files and forward output into the archive. The weird things I observe are:
- gzip generates the same size of archive on levels -6 (default) and -9 (–best or maximum compression)
- pigz also generates the same size of archive on levels -6 and -9
- pigz generates larger archive comparing to gzip
Steps to reproduce (on Ubuntu 24.04):
# create 2 dummy files for tryouts:
base64 /dev/urandom | head -c 1024000000 > file1.txt
base64 /dev/urandom | head -c 1024000000 > file2.txt
# try various combinations for archiving:
# default gzip
cat file1.txt file2.txt | gzip -v > combined_default.txt.gz
# max compression gzip
cat file1.txt file2.txt | gzip -v -9 > combined_max.txt.gz
# parallel default compression
cat file1.txt file2.txt | pigz -v -p4 > combined_parralel_default.txt.gz
# parallel, max compression
cat file1.txt file2.txt | pigz -v -9 -p4 > combined_parralel_max.txt.gz
# list all files
ls -l
The output is :
-rw-r--r-- 1 username username 1556350976 Jun 16 13:11 combined_default.txt.gz
-rw-r--r-- 1 username username 1556350976 Jun 16 13:13 combined_max.txt.gz
-rw-r--r-- 1 username username 1558037995 Jun 16 13:15 combined_parralel_default.txt.gz
-rw-r--r-- 1 username username 1558037995 Jun 16 13:14 combined_parralel_max.txt.gz
-rw-r--r-- 1 username username 1024000000 Jun 16 13:07 file1.txt
-rw-r--r-- 1 username username 1024000000 Jun 16 13:07 file2.txt
Please, help me to understand:
- why specifying the compression level doesn’t affect the size of the final archive?
- why pigz generates a larger archive while it is described as the parallel implementation of gzip and this imply obtaining the same result?