Thanks for the tips.
I've been using compile from scratch distros for a while and that has taught me quite a few things about how to get that extra performance out of the code without compromising stability - so here goes:
Basicly what you want to do is to export CFLAGS and CXXFLAGS with some interesting flags.
The complete list for GCC3.1 is here
http://gcc.gnu.org/onlinedocs/gcc-3....mize%20Options
I use GCC3.1 as the exsample, mostly because that the version I use, and because most major distros are switching to it as we speak.
Here goes the most interesting flags:
-march=cputype {i386,i486,i586,i686,k6-2,k6-3,athlon,athlon-mp,athlon-tbird,athlon-xp,pentium4}
Enables architecture specific compilation, makes code speedy
Is it safe?
This is generally considered safe'ish - my personal experince tells me that I have yet to see problems regarding -march, but if an application refuses to compile you can use step down to a lower cputype like i386.
-fomit-frame-pointer
Disables the frame-pointer which normally occupices a register, this is used for debugging, and since you are mostly likely not to debug, you might as well use the extra register to gain some speed (also known as "the magic flag" do to the impressive speed gain)
Is it safe?
This is considered safe'ish - personal experience tells me that this is fairly safe - I have yet to see any problem and the smoothness my system gets with it is well worth the risk.
-O2 (note capital letter o, not zero)
please refer to the documentation as this is rather complex. instead let's debate the use of -O2 vs -O3. If you read the manual you will see that -O3 is simply stated as "optimize even more - plus turns on -finline-functions" - now why don't we use -O3 then.
We don't do this because -O3 does in fact produce faster code, but the binary it produces will be much larger, and that will make loading slower. Thus -O2 will feel faster. Also any good programmer will manually inline important functions, so instead of letting GCC inline the entire thing (as it tends to) let's rely on the ability of clever coders.
is this safe?
-O2 is generally considered safer than -O3 - as -O2 generally is the default let's label this as safe - Personal experience tells me that -O2 feels faster than -O3, and it poses less problems.
-frerun-cse-after-loop and -frerun-loop-opt
These flags will optimize loops, will result in faster running code.
Is this safe?
Safe'ish - Personal experience: I've never experienced any problems with these flags
-fexpensive-optimizations
Performs a number of minor optimizations that are relatively expensive.
Is this safe?
safe'ish : personal experience : Personal experience: I have yet to see any problems with this.
-falign-functions=n
Aligns the start of functions to the next power-of-two greater than n, skipping up to n bytes, should affect load time of the functions.
is this safe?
Safe'ish - Personal experience: I have yet to see any problems with this, and combined with loop optimizing this to some degree speeds up loading. - for me n=4 seems good.
---
I have my entire Gentoo Linux system running with these flags, and while I don't experience any problems with this you might and if this leads to crashing, then step optimizations down and don't blame me. and remember that optimizing binutils, GCC and glibc is considered unsafe.
Thanks for the tips.
Bookmarks