You can also perform the same comparison between bzip2 and lzma.
The bzip2 man page shows that a bzip2 archive requires roughly 3700kB of memory when uncompressing if it has been compressed with "-9" force.
On the other side, the xz man page tells that a xz archive requires roughly 3 MB of memory when uncompressing if it has been compressed with "-4" force.
With the below example, compared to the bzip2 compression method, the lzma method :
- saves up to 18% of archive size
- requires less memory for decompression.
Maybe we could imagine the below rules for packaging deb archives :
- "xz -1e" by default
- "xz -4e" for archives which were previously compressed with bzip2
- "xz -9e" for archives whose application requires a lot of memory at runtime
Below are the result of the compression ratios of bzip2 and lzma :
-----------------------------------------------------------------
j@dt:~/tmp$ 7z x /var/cache/apt/archives/linux-image-2.6.32-42-generic_2.6.32-42.95_amd64.deb
7-Zip 9.04 beta Copyright (c) 1999-2009 Igor Pavlov 2009-05-30
p7zip Version 9.04 (locale=fr_FR.UTF-8,Utf16=on,HugeFiles=on,2 CPUs)
You can also perform the same comparison between bzip2 and lzma.
The bzip2 man page shows that a bzip2 archive requires roughly 3700kB of memory when uncompressing if it has been compressed with "-9" force.
On the other side, the xz man page tells that a xz archive requires roughly 3 MB of memory when uncompressing if it has been compressed with "-4" force.
With the below example, compared to the bzip2 compression method, the lzma method :
- saves up to 18% of archive size
- requires less memory for decompression.
Maybe we could imagine the below rules for packaging deb archives :
- "xz -1e" by default
- "xz -4e" for archives which were previously compressed with bzip2
- "xz -9e" for archives whose application requires a lot of memory at runtime
Below are the result of the compression ratios of bzip2 and lzma : ------- ------- ------- ------- ------- ------- ------- ------- -- apt/archives/ linux-image- 2.6.32- 42-generic_ 2.6.32- 42.95_amd64. deb
-------
j@dt:~/tmp$ 7z x /var/cache/
7-Zip 9.04 beta Copyright (c) 1999-2009 Igor Pavlov 2009-05-30 fr_FR.UTF- 8,Utf16= on,HugeFiles= on,2 CPUs)
p7zip Version 9.04 (locale=
Processing archive: /var/cache/ apt/archives/ linux-image- 2.6.32- 42-generic_ 2.6.32- 42.95_amd64. deb
Extracting control.tar.gz
Extracting data.tar.bz2
Everything is Ok
Files: 2 ------- ------- ------- ------- ------- ------- ------- ------- --
Size: 31896829
Compressed: 31897022
j@dt:~/tmp$ bunzip2 -c data.tar.bz2 > data.tar
j@dt:~/tmp$ bzip2 -c9 data.tar > data.tar.bz2-9
j@dt:~/tmp$ lzma -c4 data.tar > data.tar.lzma-4
j@dt:~/tmp$ xz -c4e data.tar > data.tar.xz-4e
j@dt:~/tmp$ xz -c1e data.tar > data.tar.xz-1e
j@dt:~/tmp$ lzma -c1 data.tar > data.tar.lzma-1
j@dt:~/tmp$ ls -lk
total 289852
-rw-r--r-- 1 j j 91 2012-07-25 18:44 control.tar.gz
-rw-r--r-- 1 j j 117370 2012-08-19 14:52 data.tar
-rw-r--r-- 1 j j 31059 2012-07-25 18:44 data.tar.bz2
-rw-r--r-- 1 j j 31059 2012-08-19 15:02 data.tar.bz2-9
-rw-r--r-- 1 j j 29946 2012-08-19 15:28 data.tar.lzma-1
-rw-r--r-- 1 j j 26193 2012-08-19 15:10 data.tar.lzma-4
-rw-r--r-- 1 j j 28509 2012-08-19 15:27 data.tar.xz-1e
-rw-r--r-- 1 j j 25605 2012-08-19 15:14 data.tar.xz-4e
j@dt:~/tmp$
-------