Difference between revisions of "Software: GZIP vs. BZIP2 vs. XZ - performance"

From Luky-Wiki
Jump to: navigation, search
(Size after compression)
(Size after compression)
Line 35: Line 35:
 
|-
 
|-
 
! source
 
! source
|| 6189107200 (5,8G) || 4294967296 (4,0G) || 760012800 (725M) || 1073741824 (1,0G) || 4294967296 (4,0G)
+
|| 6189107200 (5,8G) || 4294967296 (4,0G) || 760012800 (725M) || 1073741824 (1,0G) || 4294967296 (4,0G) || 739279146 (706M)
 
|-
 
|-
  
 
! gzip -1
 
! gzip -1
|| 5887330412 (5,5G) || 1307236772 (1,3G) || 222544172 (213M) || 1073924290 (1,1G) || 18734949 (18M)
+
|| 5887330412 (5,5G) || 1307236772 (1,3G) || 222544172 (213M) || 1073924290 (1,1G) || 18734949 (18M) || 294669689 (282M)
 
|-
 
|-
 
! gzip -6
 
! gzip -6
|| 5879295258 (5,5G) || 1265502809 (1,2G) || 189164983 (181M) || 1073915726 (1,1G) || 4168175 (4,0M)
+
|| 5879295258 (5,5G) || 1265502809 (1,2G) || 189164983 (181M) || 1073915726 (1,1G) || 4168175 (4,0M) || 257863244 (246M)
 
|-
 
|-
 
! gzip -9
 
! gzip -9
|| 5878183653 (5,5G) || 1263912039 (1,2G) || 187578775 (179M) || 1073915726 (1,1G) || 4168175 (4,0M)
+
|| 5878183653 (5,5G) || 1263912039 (1,2G) || 187578775 (179M) || 1073915726 (1,1G) || 4168175 (4,0M) || 255110366 (244M)
 
|-
 
|-
  
 
! bzip2 -1
 
! bzip2 -1
|| 5845697940 (5,5G) || 1259732950 (1,2G) || 177327051 (170M) || 1082371295 (1,1G) || 26041 (26K)
+
|| 5845697940 (5,5G) || 1259732950 (1,2G) || 177327051 (170M) || 1082371295 (1,1G) || 26041 (26K) || 234198972 (224M)
 
|-
 
|-
 
! bzip2 -6
 
! bzip2 -6
|| 5485927519 (5,2G) || 1235652239 (1,2G) || 156321978 (150M) || 1079336646 (1,1G) || '''4491 (4,4K)'''
+
|| 5485927519 (5,2G) || 1235652239 (1,2G) || 156321978 (150M) || 1079336646 (1,1G) || '''4491 (4,4K)''' || 225847372 (216M)
 
|-
 
|-
 
! bzip2 -9
 
! bzip2 -9
|| '''5430387273 (5,1G)''' || 1231448849 (1,2G) || 152999062 (146M) || 1078496689 (1,1G) || '''3023 (3,0K)'''
+
|| '''5430387273 (5,1G)''' || 1231448849 (1,2G) || 152999062 (146M) || 1078496689 (1,1G) || '''3023 (3,0K)''' || 224565320 (215M)
 
|-
 
|-
  
 
! xz -1
 
! xz -1
|| 5383272868 (5,1G) || 1227513964 (1,2G) || 153319596 (147M) || 1073795128 (1,1G) || 624848 (611K)
+
|| 5383272868 (5,1G) || 1227513964 (1,2G) || 153319596 (147M) || 1073795128 (1,1G) || 624848 (611K) || 235411304 (225M)
 
|-
 
|-
 
! xz -6
 
! xz -6
|| '''5305999740 (5,0G)''' || 1188389560 (1,2G) || '''114173192 (109M)''' || 1073795048 (1,1G) || 624848 (611K)
+
|| '''5305999740 (5,0G)''' || 1188389560 (1,2G) || '''114173192 (109M)''' || 1073795048 (1,1G) || 624848 (611K) || '''175777564 (168M)'''
 
|-
 
|-
 
! xz -9
 
! xz -9
|| '''5264433664 (5,0G)''' || '''1174081380 (1,1G)''' || '''99830680 (96M)''' || 1073795048 (1,1G) || 624848 (611K)
+
|| '''5264433664 (5,0G)''' || '''1174081380 (1,1G)''' || '''99830680 (96M)''' || 1073795048 (1,1G) || 624848 (611K) || '''100893196 (97M)'''
 
|-
 
|-
 
   
 
   

Revision as of 20:41, 27 November 2013

I was part of discussion on G+ recently. Discussion was about best possible compression method for Linux kernel. Later it was extended also to user space compression algorithm. I think it will be interesting to see various compress method and levels on different type of files.

Input data

For test i selected following files:

  • DVD.iso - iso image containing mpeg2 stream (DVD-Video) and jpeg files (pictures)
  • fs.bin - ext4 file system containing "linux.tar" and "random.bin"
  • linux.tar - tarball archive of Linux kernel sources + objects and final kernel / module images
  • random.bin - file containing data from /dev/urandom
  • zero.bin - file containing only 'zero' data (read /dev/zero)
  • sql.dump - text dump of my PostgreSQL database (backup catalog, sql commands)

As a preparation i executed following cycle:

for a in *
do
        for b in 1 6 9
        do
                cat ${a} | gzip  -${b} > ${a}.${b}.gz
                cat ${a} | bzip2 -${b} > ${a}.${b}.bz2
                cat ${a} | xz    -${b} > ${a}.${b}.xz
        done
done

Test methodology

Test is executed on "Intel(R) Atom(TM) CPU 330 @ 1.60GHz". System was running in dual core mode with HT enabled (SMP). There should be no significant difference using one core and "UP" code as compression/decompression is done in one thread. System was configured with 3GB of usable RAM memory and without CPU frequency scaling. At time of test system was idling. Sequential disk read speed is 80 MB/sec so it should not affect testing. I used /dev/null as target for compression and decompression to prevent possible problems with concurrent I/O and cache entries.

Result

Size after compression

Table contain size reported by stat and ls -lh command:

DVD.iso fs.bin linux.tar random.bin zero.bin sql.dump
source 6189107200 (5,8G) 4294967296 (4,0G) 760012800 (725M) 1073741824 (1,0G) 4294967296 (4,0G) 739279146 (706M)
gzip -1 5887330412 (5,5G) 1307236772 (1,3G) 222544172 (213M) 1073924290 (1,1G) 18734949 (18M) 294669689 (282M)
gzip -6 5879295258 (5,5G) 1265502809 (1,2G) 189164983 (181M) 1073915726 (1,1G) 4168175 (4,0M) 257863244 (246M)
gzip -9 5878183653 (5,5G) 1263912039 (1,2G) 187578775 (179M) 1073915726 (1,1G) 4168175 (4,0M) 255110366 (244M)
bzip2 -1 5845697940 (5,5G) 1259732950 (1,2G) 177327051 (170M) 1082371295 (1,1G) 26041 (26K) 234198972 (224M)
bzip2 -6 5485927519 (5,2G) 1235652239 (1,2G) 156321978 (150M) 1079336646 (1,1G) 4491 (4,4K) 225847372 (216M)
bzip2 -9 5430387273 (5,1G) 1231448849 (1,2G) 152999062 (146M) 1078496689 (1,1G) 3023 (3,0K) 224565320 (215M)
xz -1 5383272868 (5,1G) 1227513964 (1,2G) 153319596 (147M) 1073795128 (1,1G) 624848 (611K) 235411304 (225M)
xz -6 5305999740 (5,0G) 1188389560 (1,2G) 114173192 (109M) 1073795048 (1,1G) 624848 (611K) 175777564 (168M)
xz -9 5264433664 (5,0G) 1174081380 (1,1G) 99830680 (96M) 1073795048 (1,1G) 624848 (611K) 100893196 (97M)

Compression

DVD.iso fs.bin linux.tar random.bin zero.bin
source - - - - -
gzip -1 - - - - -
gzip -6 - - - - -
gzip -9 - - - - -
bzip2 -1 - - - - -
bzip2 -6 - - - - -
bzip2 -9 - - - - -
xz -1 - - - - -
xz -6 - - - - -
xz -9 - - - - -

Decompression

DVD.iso fs.bin linux.tar random.bin zero.bin
source - - - - -
gzip -1 - - - - -
gzip -6 - - - - -
gzip -9 - - - - -
bzip2 -1 - - - - -
bzip2 -6 - - - - -
bzip2 -9 - - - - -
xz -1 - - - - -
xz -6 - - - - -
xz -9 - - - - -

Sumary