Between xz, gzip, and bzip2, which compression algorithm gives the smallest file size and fastest speed when compressing fairly large tarballs?
In my stress test, I compressed 464 megabytes of data using the three formats listed. Gzip returned a 364 MB file. Bzip2 returned a 315 MB file. Xz returned a 254 MB file. I also did a simple speed test:
3: Bzip2 (my fan was blowing quite a bit while this was going, indicating that my Athlon II was fairly strained)
Please note that all of these tests were done with the latest version of 7-Zip.
Xz is the best format for well-rounded compression, while Gzip is very good for speed. Bzip2 is decent for its compression ratio, although xz should probably be used in its place.
I did my own benchmark on 1.1GB Linux installation vmdk image:
all compression levels on max, CPU Intel I7 3740QM, Memory 32GB 1600, source and destination on RAM disk
I Generally use rar or 7z for archiving normal files like documents.
update: as tar only preserve normal permissions and not ACLs anyway, also plain .7z plus backup and restoring permissions and ACLs manually via getfacl and sefacl can be used which seems to be best option for both file archiving or system files backup because it will full preserve permissions and ACLs, has checksum, integrity test and encryption capability, only downside is that p7zip is not available everywhere
I think that this article provides very interesting results.
The most size efficient formats are xz and lzma, both with the -e parameter passed.
The fastest algorithm are by far lzop and lz4 which can produce a compression level not very far from gzip in 1.3 seconds while gzip took 8.1 second. The compression ratio is 2.8 for lz4 and 3.7 for gzip.
Here are a few results I extracted from this article :
So if you really desperatly need speed, lz4 is awesome and still provides a 2.8 compression ratio.
If you desperatly need to spare the byte, xz at the maximum compression level (9) does the best job for text files like the kernel source. However, it is very long and takes a lot of memory.
An good one where needed to minimize the impact on time AND space is gzip. This is the one i would use to make manual daily backups of a production environment.