So since I run some old/slow hardware, I want to get the max out of
them, speedwise, without upgrading anything on the hardware side. So one
of the things I do is to re-compile the applications/libraries with some
customized CFlags. CFlags allow
you to instruct your compiler (GCC in this case) to optimize the
resulting binary.
As of recently, there are some Archlinux
boxes running here, which makes it pretty easy to recompile everything
from the sources again. Just quickly install
pacbuilder and all the
neccessary compilers/build-utilities and let's get started!
Assuming you've got pacbuilder + the compiler story, open up your
/etc/makepkg.conf and adjust the lines starting with 'CFLAGS' and
'CXXFLAGS' according to your machine-type. Don't worry, you don't need
to know anything ;-) in general you can just use these lines, which
should just work:
[code lang="bash"]
...
CFLAGS="-march=native -mtune=native -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="\${CFLAGS}"
...
[/code]
The 'native' option tunes the GCC options to optimize the resulting
binary specific for your local CPU. This means that the binary might not
run on another box, but therefore is faster in terms of execution speed
on your local one.
And as you know, compiling takes time, especially on older boxes like
mine. Because of that, I've done all the compilation on another machine.
Now the problem with that is, that the march/mtune 'native' option
doesn't work, since there are different CPU types in use. To overcome
this problem, we can set the CFLAGS manually (which was the default way
for GCC before v. 4.2). A good ressource might be the
gentoo-wiki, or we can use
gcc on the target machine using this command to show us the optimized
flags:
[code lang="bash"]
cc -march=native -E -v - </dev/null 2>&1 | grep cc1
[/code]
OK, now that we have these information, we can open up again the
makepkg.conf and now adjust it accordingly, but this time we'll use the
static/hardcoded values instead of the 'dynamic' march=native thingy:
[code lang="bash"]
...
CFLAGS="--march=pentium3 --param l1-cache-size=16 --param
l1-cache-line-size=32 --param l2-cache-size=256 -mtune=generic -O2
-pipe"
CXXFLAGS="\${CFLAGS}"
...
[/code]
Now that the compiler is ready to work, we can issue a pacbuilder
command and recompile everything again. The command below copies the
created packages in the specified folder (--export), is verbose (-v) and
rebuilds every package (--world).
[code lang="bash"]
pacbuilder --export /home/user/data/packages -v --world
[/code]
Notes
In my case I've got a Barebone by Digitallogic with a Pentium III (Coppermine) @ 700MHz, and another one is my eee-pc 4G, which is also quite limited hardware-wise and I felt quite a performance improvement after that. I don't have benchmarks, but that's my subjective impression ;-)
Cheers,
Raphi