View previous topic :: View next topic |
Author |
Message |
/usr/Bananaman n00b
Joined: 03 Nov 2002 Posts: 26
|
Posted: Wed Dec 04, 2002 10:48 am Post subject: To -Os or not to -Os? |
|
|
How come everyone on the forums seems to love optimizations with -03 -pipe -fomit....etc X 4 lines?...Is there actually noticable performance enhancements? Nobody really talks about -Os? which seems a little strange...I would have thought this would be a better switch to be flicking - I think I read somewhere that the gentoo sources are compiled with this? - yet in CFlags Central all the go is -03 etc....?
Anyhoo, My real question is does anyone know about -Os? I've been compiling with -Os and I'd like to know if the switches that you would normally use with -03 (like -fomit-frame-pointer) would make -Os more responsive? The reason I ask is because I like a quick responsive system - and programs compiled with -Os seem to load pretty damn quick! or would these switches just bloat out the compile? |
|
Back to top |
|
|
zhenlin Veteran
Joined: 09 Nov 2002 Posts: 1361
|
Posted: Wed Dec 04, 2002 2:45 pm Post subject: |
|
|
-Os -- optimize for size:
man gcc:
Code: |
-Os Optimize for size. -Os enables all -O2 optimizations that do not typically increase code size. It also performs further optimizations
designed to reduce code size.
|
-Os shrinks the size of the program in order to make it load into memory fast, the additional optimization flags bloat the program in order to make it run fast after loading into memory. |
|
Back to top |
|
|
Lovechild Advocate
Joined: 17 May 2002 Posts: 2858 Location: Århus, Denmark
|
Posted: Wed Dec 04, 2002 3:09 pm Post subject: |
|
|
I used to think that smaller binaries loaded faster, but I found that lib. lookup count makes more of a difference than binary size. So optimize the hell out of it and use ELF prelinking, get the best of both worlds. |
|
Back to top |
|
|
zypher Retired Dev
Joined: 10 Jun 2002 Posts: 416 Location: Cologne, ger.
|
Posted: Wed Dec 04, 2002 7:50 pm Post subject: |
|
|
I have two systems here, one Duron 700@900/512MB and one PII300/96MB.
Both of them running gentoo.-1.4-r1 compiled with -0s -pipe -ffast-math.
In my personal view and feeling the difference is noticeable on the pII-Laptop (small though).
The Duron does not seem to be more responsive (lots of mem, UDMA100-Hdds). And -O3 -flotsaflags was not faster on that machine.
YMMV as always, but I'll stay with the -Os flag.
And btw, check out freebench (iirc), there you can check your settings. _________________ linux user 65882 |
|
Back to top |
|
|
AlterEgo Veteran
Joined: 25 Apr 2002 Posts: 1619
|
Posted: Wed Dec 04, 2002 8:21 pm Post subject: |
|
|
I think zypher's got it right:
on a big and modern PC the difference is too small to be noticed: you'd probably need the linux equivalent of Bapco's Sysmark or PCMark to be able to measure the difference.
I use:
CFLAGS="-march=athlon-xp -mmmx -m3dnow -msse -mfpmath=sse -O3 -pipe -fomit-frame-pointer -funroll-loops -fforce-addr -frerun-cse-after-loop -frerun-loop-opt -falign-functions=4"
Say it's 2% faster than:
CFLAGS="-march=athlon-xp -mmmx -m3dnow -msse -O2
it certainly takes close to twice as long to compile stuff.
Therefore, altogether, it just might be a very bad "investment" to use these high optimizations (I'm forgetting the occasional ebuild breaking under high optimizations).
The good thing is: it's all up to your own choice and taste. |
|
Back to top |
|
|
/usr/Bananaman n00b
Joined: 03 Nov 2002 Posts: 26
|
Posted: Thu Dec 05, 2002 7:21 am Post subject: *lol* |
|
|
Thanks for clearing that up guyz!
For my slower machine I'm going to keep compiling with -Os and the usual flags I used to use (which was my q) and I'll switch my main computer back to -03 -flotsflags... |
|
Back to top |
|
|
/usr/Bananaman n00b
Joined: 03 Nov 2002 Posts: 26
|
Posted: Thu Dec 05, 2002 7:52 am Post subject: |
|
|
If anyone is interested this site cleared up a little bit for me http://www.goof.com/pcg/os2/tips.html I know it says for os2 but it talks about gcc and explainsa couple of useful tags including extras to use with -Os |
|
Back to top |
|
|
|