Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
To -Os or not to -Os?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
/usr/Bananaman
n00b
n00b


Joined: 03 Nov 2002
Posts: 26

PostPosted: Wed Dec 04, 2002 10:48 am    Post subject: To -Os or not to -Os? Reply with quote

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
View user's profile Send private message
zhenlin
Veteran
Veteran


Joined: 09 Nov 2002
Posts: 1361

PostPosted: Wed Dec 04, 2002 2:45 pm    Post subject: Reply with quote

-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
View user's profile Send private message
Lovechild
Advocate
Advocate


Joined: 17 May 2002
Posts: 2858
Location: Århus, Denmark

PostPosted: Wed Dec 04, 2002 3:09 pm    Post subject: Reply with quote

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
View user's profile Send private message
zypher
Retired Dev
Retired Dev


Joined: 10 Jun 2002
Posts: 416
Location: Cologne, ger.

PostPosted: Wed Dec 04, 2002 7:50 pm    Post subject: Reply with quote

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
View user's profile Send private message
AlterEgo
Veteran
Veteran


Joined: 25 Apr 2002
Posts: 1619

PostPosted: Wed Dec 04, 2002 8:21 pm    Post subject: Reply with quote

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
View user's profile Send private message
/usr/Bananaman
n00b
n00b


Joined: 03 Nov 2002
Posts: 26

PostPosted: Thu Dec 05, 2002 7:21 am    Post subject: *lol* Reply with quote

: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
View user's profile Send private message
/usr/Bananaman
n00b
n00b


Joined: 03 Nov 2002
Posts: 26

PostPosted: Thu Dec 05, 2002 7:52 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum