All of lore.kernel.org
 help / color / mirror / Atom feed
* Easy trick to reduce kernel footprint
@ 2005-06-05 22:35 Willy Tarreau
  2005-06-05 23:41 ` Christian Leber
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Willy Tarreau @ 2005-06-05 22:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: mpm

Hi,

Here's a simple trick for all those who try to squeeze their kernels to the
absolute smallest size.

I recently discovered p7zip which comes with the LZMA compression algorithm,
which is somewhat better than gzip and bzip2 on most datasets, and I also
noticed that this tool provides support for gzip and bzip2 outputs. So I tried
to produce some of those standard outputs, and observed a slight gain compared
to the default tools. The reason is that we can change the number of passes and
the dictionnary size.

So as an experiment, I used it to compress my kernel+initramfs and I could
gain about 2% (23 kB) which is not bad at all for embedded systems. Don't
ask about the '.' after '-si' in the '7za' command line, it's just that the
tool expects a file name, and I didn't managed to fix it, the source is some
sort of obfuscated c++ code (who said "pleonasm" ?) ported from windows, but
at least it works.  Out of curiosity, I also tried both bzip2 and the LZMA
algorithm, although that's not fair because the decompressor code would have
to be changed to support them.

Size of the 2.6.12-rc4-mm2 vmlinux compiled without the initramfs image :

  bash-3.00$ size vmlinux 
     text    data     bss     dec     hex filename
  1024458  123712   73580 1221750  12a476 vmlinux

Size of the initramfs :
  -rw-rw-r--  1 willy users 1014272 2005-05-27 16:31 usr/initramfs_data.cpio

Now the resulting bzImage size with various compression methods

     size  command
  1197277  make
  1197275  make cmd_gzip="gzip -9c <\$< >\$@"
  1173550  make cmd_gzip="7za a -tgzip -mx9 -mpass=4 -so -si . <\$< >\$@"
  1207599  make cmd_gzip="bzip2 -c9 <\$< >\$@"
  1051705  make cmd_gzip="rm -f \$@;7za a -t7z -mx9 -md=64m -si \$@ < \$<"

Surprizingly, bzip2 makes a bigger kernel. The gzip implementation in 7za
saves 23 kB (2%) on the overall image without touching any code. The LZMA
implementation could save 145 kB (12%), but would require a different
extraction code (I've already seen patches to bring LZMA support on 2.4).

Note: I don't know who implemented the if_changed macro in the makefile which
allows us to pass cmd_gzip here, but it was an excellent idea.

Regards,
Willy


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2005-06-06 20:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-05 22:35 Easy trick to reduce kernel footprint Willy Tarreau
2005-06-05 23:41 ` Christian Leber
2005-06-06  1:02 ` Wakko Warner
2005-06-06  4:11   ` Willy Tarreau
2005-06-06 11:07     ` Wakko Warner
2005-06-06 11:43       ` Willy Tarreau
2005-06-06 20:16         ` Wakko Warner
2005-06-06  1:10 ` Christian Leber
2005-06-06  7:47 ` Jörn Engel
2005-06-06  5:55   ` Oliver Leitner
2005-06-06  8:19   ` Willy Tarreau
2005-06-06  9:46     ` Jörn Engel
2005-06-06  8:31   ` Christian Leber

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.