Zip vs. Bzip2

While investigating an unrelated issue on our backup server, I came across an interesting discussion about gzip vs. bzip2. I was surprised to read on how much slower bzip2 is.  I even tested it on our server.  And as expected, I saw the huge difference.

$ du -sh home
819M  home

$ time tar czf test.tar.gz home
real	3m29.741s
user	1m4.026s
sys	0m5.629s

$ time tar cjf test.tar.bz2 home
real	11m38.751s
user	6m19.259s
sys	0m7.237s

$ ll test.tar*
-rw-r--r-- 1 leonid users 365987716 2010-06-29 13:08 test.tar.bz2
-rw-r--r-- 1 leonid users 390655750 2010-06-29 12:56 test.tar.gz

For such a small difference in size, the compression time difference is huge! Of course, I should play with more parameters, repeat the tests several times, and test the decompression time too. But the above test is still a good indication. Way too many scripts out there use the default parameters and substitute gzip with gzip2 without any testing. That’s obviously asking for trouble.

Leave a Comment