[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Compiling packages for the standard distribution with -Os instead of -O2



Hi there.

I think that this may be interesting to anybody that has to work with
computers that are not the latest/more recent as most people in richer
countries seem to have.

It seems to be that a good amount of people upgrade their computers in a
regular basis and, then, don't notice how things can get slower in
"weaker" computers.

Those of us that live in a country where the already installed base of
computers is not recent have to live with software that is ever growing
in terms of both RAM and CPU cycles and this leaves less computing power
for the applications needed to run.

One way to mitigate the memory consumption is to, among other things,
compile packages with optimization of GCC set to -Os, instead of -O2,
which seems to work at least for some programs (the Linux kernel,
mozilla-firefox and my own home-grown programs).

Just to see the effects of compiling programs with -Os, I tried to get
the sources for firefox 1.5 from testing (which is what I use by
default) and compiled it with -Os, instead of -O2. The program was much
more responsive, with less use of swap (sorry, I don't have numbers
right now) and the installed size of my own compiled package was 2MB
less than that of the stock Debian package.

As I don't like the behaviour of firefox 1.5 [1], I promptly downloaded
the source for firefox 1.0.4-2sarge6, tried to recompile it -Os, but had
problems FTBFS [2]. I then created a chroot of sarge, installed gcc-3.4
and compiled firefox 1.0.4-2sarge6 with -Os. I still see around 2MB of
economy in size:

 * here is what my copy of dpkg --status mozilla-firefox says:
   Installed-Size: 21260 [3];
 * here is the same information taken from
   <http://packages.debian.org/stable/web/mozilla-firefox>:
   The installed size is 24400.

So, I would like to ask the developers about the feasibility of getting
packages compiled with -Os instead of -O2 for the default distribution
[4].

This could be a small change that could make a lot of people happier,
since the packages would be smaller and consume a tiny bit less
bandwidth on the mirrors, potentially without any loss of functionality,
less space used on disk and, potentially less problems with small caches
(like the cache-starved CPUs that I happen to see in my country).

Well, that is it. is this unfeasible? Would it not be desired for some
reason? Please, note that I am not demanding that the packages be
compiled this way. Just asking for some discussion and enlightenment.



Thanks for any comments, Rogério Brito.

[1] If I have many tabs opened in Firefox 1.5 and I control-scroll the
    mouse to resize the text, Firefox 1.5 operates burning a lot of CPU
    cycles without any feedback for the user and this lasts for quite a
    good amount of seconds on my slower computers. This doesn't happen
    with Firefox 1.0, where the resizing is instantaneous.

[2] Bear in mind that the compiler used in testing is gcc 4.0.3, while
    sarge's default is 3.3.x.

[3] I use 4kb blocks on my i386 system, which seems to be the default
    for not-so-new installations, and, I suppose, both developer's
    machines and buildds;

[4] Of course, for packages requiring being compiled with -O3, it may or
    may not be a gain to compile with -Os and this would have to be studied
    on a case by case analysis.
-- 
Rogério Brito : rbrito@ime.usp.br : http://www.ime.usp.br/~rbrito
Homepage of the algorithms package : http://algorithms.berlios.de
Homepage on freshmeat:  http://freshmeat.net/projects/algorithms/



Reply to: