Roland's homepage

My random knot in the Web

XZ compression

With the release of FreeBSD 8.1, the xz compression program has been imported into FreeBSD. I decided to do some testing to compare it to the bzip2 format. In this test I’ve used the standard non-multithreaded implementations of these compression programs.

tukaani logo

Tests

First I compressed my procmail logfile (a plain text file) with both bzip2 and xz. The compression comands used were:

time bzip2 -c procmail.log >procmail.log.bz2
9.401u 0.074s 0:09.56 99.0% 37+1512k 237+16io 0pf+0w
time xz -c procmail.log >procmail.log.xz
15.638u 0.112s 0:15.75 99.9% 63+1474k 0+15io 0pf+0w

As shown, xz takes longer to compress the file. The resulting xv compressed file is somewhat smaller than the bzip2 compressed file, but not spectacularly so;

File Uncompressed bzip2 xz
procmail.log 29764113 1983968 1930764
  100% 6.666% 6.487%

Decompression was significantly faster for xz;

> time xz -dc procmail.log.xz >/dev/null
0.256u 0.015s 0:00.28 92.8% 66+1534k 0+0io 2pf+0w
> time bzip2 -dc procmail.log.bz2 >/dev/null
0.866u 0.014s 0:00.88 98.8% 37+1529k 0+0io 0pf+0w

Next up were a couple of UFS2 dumps, which are a mixture of binary and text data.

> time bzip2 -c root-0-20100724.dump >root-0-20100724.dump.bz2
14.605u 0.105s 0:14.91 98.5% 37+1503k 784+238io 0pf+0w
> time xz -c root-0-20100724.dump > root-0-20100724.dump.xz
70.884u 0.240s 1:11.14 99.9% 63+1473k 0+159io 0pf+0w
> time bzip2 -c usr-0-20100724.dump > usr-0-20100724.dump.bz2
1484.101u 12.137s 25:27.87 97.9% 37+1499k 66059+26227io 0pf+0w
> time xz -c usr-0-20100724.dump > usr-0-20100724.dump.xz
4510.041u 19.445s 1:15:37.69 99.8% 63+1474k 66067+21319io 3pf+0w
> time bzip2 -c var-0-20100724.dump >var-0-20100724.dump.bz2
51.057u 0.390s 0:52.57 97.8% 37+1500k 2032+707io 1pf+0w
> time xz -c var-0-20100724.dump > var-0-20100724.dump.xz
149.619u 0.593s 2:30.28 99.9 %63+1474k 1+685io 0pf+0w

Here again xz takes significantly longer to compress, but outperforms bzip2 in terms of compressed size, especially for root-0-20100724.dump, where the difference is really spectacular.

File Uncompressed bzip2 xz
root-0-20100724.dump 99440 30720 20432
  100% 30.893% 20.547%
usr-0-20100724.dump 8417184 3363856 2730224
  100% 39.964% 32.436%
var-0-20100724.dump 258464 90560 87696
  100% 35.038% 33.930%

Decompression times are given below. Again xz is much faster than bzip2 in decompressing data.

> time bzip2 -dc root-0-20100724.dump.bz2 >/dev/null
4.985u 0.052s 0:05.04 99.8% 37+1502k 242+0io 0pf+0w
> time xz -dc root-0-20100724.dump.xz >/dev/null
2.615u 0.052s 0:02.73 97.4% 64+1482k 165+0io 3pf+0w
> time bzip2 -dc usr-0-20100724.dump.bz2 >/dev/null
449.188u 4.511s 7:36.99 99.2% 37+1500k 26356+0io 0pf+0w
> time xz -dc usr-0-20100724.dump.xz > /dev/null
197.313u 3.179s 3:21.98 99.2% 63+1474k 21408+0io 1pf+0w
> time bzip2 -dc var-0-20100724.dump.bz2 >/dev/null
12.407u 0.105s 0:12.51 99.9% 37+1500k 0+0io 0pf+0w
> time xz -dc var-0-20100724.dump.xz >/dev/null
8.077u 0.075s 0:08.15 99.8% 63+1475k 0+0io 0pf+0w

Conclusion

  • bzip2 compresses faster than xz
  • xz compresses better than bzip2, sometimes spectacularly so
  • xz decompresses significantly faster than bzip2

For comments, please send me an e-mail.


Related articles


←  Visit to the JEC in Paris Me at work  →