Evaluate 7zip compression for use in debs, as an alternative to gzip or bzip2.


7zip is a new compression algorithm that boasts reduced file size over the existing gzip and bzip2 schemes. If this can be used to reduce the size of packages, it frees up space on the CD for more packages.

Use cases


First evaluation of the compression needs to be performed. A selection of different packages should be collated and recompressed with 7zip instead; if a significant size benefit is gained without incurring a significant time or cost benefit for creation or unpacking, then we could consider compressing packages of that type with 7zip instead.

Particular types:

Smurf has performed an entirely unscientific test by recompressing /var/cache/apt/archives/[a-g]* on his laptop and achieved the following results:

 size   directory  decompress in
58176   repo.7z       19 sec
68032       25 sec
75872   repo.gz        4 sec

Test Case

Matt has run the following test sceniro's using the appropriate sample data. Specifically his Debian package pool from his Ubuntu 5.10 ("Breezy Badger" - Release i386 ) installation CD.

  1. Unpackage all Deb packages on the CD (A mix of gzip and bzip2 formats) and repackage using only tar format and no compression. That is 1488 Files adding to 1.5Gb uncompressed. 2.) Repackage these tar only Deb packages using only:
    • a.) Maximum Gzip compression b.) Maximum Bzip2 compression c.) 7zip with default compression d.) 7zip with high level compression e.) 7zip with maximum compression '
    3.) Decompress each of these compressed achieves.

The Results


7zip offers a 24%-27% saving in storage space but is 3 times slower to compress and decompress. A 24% saving would allow a massive 134Mb of addition packages to be added to the standard CD. These would increasing package access and download speed of individual packages. A 3 Fold increase in compression time is considerable but is still pretty fast for individual packages on my machine. Decompression time concerns me more but I believe the this addition 4mins may not be so noticeable by end users considering time required for the rest of the install process.

It is also worthy of mention that at current packages can either be in Gzip or Bzip2 format. Most packages in the sample data where in Gzip format, if all developers where to use Bzip2 format it would free up 40Mb more space on the CD.


I used a test host with an Athlon Xp 2700, 1Gb (2700) ram, and 60Gb 7200rpm disk. This specification with effect the results, which are intended as practical guide lines not theoretical benchmarks.

I'm running Ubuntu Breezy with standard packages, P7zip 4.20, Bzip 1.02, Gzip 1.3.5.



The inclusion of bzip2 support into dpkg introduced a generic compression layer, in lib/compression.c. 7zip support can be added in a similar way:

Data preservation and migration

Packages that would benefit from the conversion would select it when building in their debian/rules as we did for the bzip2 change; they would also Pre-Depend on the appropriate version of dpkg.

Outstanding issues

Reproduction of test results possibly on packages for another architecture.

Feedback from developers about the practicability of the slow compression time. Feedback about the practicability of the slow decompression times.

Is it possible to do a re-compress all the packages for the final release?


Compression algorithms generally perform better the more data you give them, especially 7-zip.  Rather than compress each language pack individually, I decided to try compressing them all as one unit.  I extracted all of the language packs and tared up and compressed the resulting directory tree:

.tar:     184,934,400
.tar.gz:  61,478,589
.tar.bz2: 49,982,949
.tar.7z:  23,081,869

As you can see, 7-zip's compression REALLY improved with the combined data set giving a space savings of 54% over the original .debs, and 43% over individually 7-zipping each package.  Are all of these language packs on the setup/live cds?  If so then compressing them this way would free up 27 MB of space.  I wonder what other packages this could be applied to? 

I think it will require more work to compress multiple packages as one unit ( modifying apt instead of dpkg ), but when you are talking about a 54% space savings instead of ~25%, I think the work is well worth it. I wonder if Matt could do that test again with all the packages on the CD, but instead of 7zipping each tar individually, add them all to one big solid 7z archive? I believe the results would be rather impressive.

Another possibilty is that we could use the different 7z settings (espacially word-size!) as well. An interesting approach would be a developer/packager/community-driven database where people could rate packages like this:

Im sure that when we start to use 7z the 7zip developers will take care of our needs soon.

My simply test (tar file 123699200 Bytes (openoffice bin 1.1.5) -> (123699200/1024)/1024=117,96875 ~ 118MB) :


compresion   :  12.324s; decompresion :  2.090s; size: 42140523 B


compresion   :  40.870s; decompresion : 11.123s; size: 39331698 B


compresion   :1m45.295s; decompresion :  5.478s; size: 28887391 B


compresion   :  21.428s; decompresion :  6.186s; size: 34746350 B

Machine: AMD 64 3200+; 3 disks 80G softRAID5; 2GB RAM

Many aspects of this spec are superceded by dpkg-lzma


Dpkg7Zip (last edited 2008-08-06 17:00:44 by localhost)