LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-04-2004, 10:21 PM   #1
qwijibow
LQ Guru
 
Registered: Apr 2003
Location: nottingham england
Distribution: Gentoo
Posts: 2,672

Rep: Reputation: 47
advice on -O optimisations for different parts of gentoo ?


Hello guys and girls.

if for a learning experiance, and a little nerdy fun more that anything else, i want to attempt to get my gentoo operating system running as fast as possible.

i intent to re-install it from scratch, configureing optimisation flags for different areas of the system.

here is my understanding of the optimisation flags...
-O1 = use when compile time is an issue.
-O2 = a nice default middle ground.
-O3 = use when binary size is not an issue.
-Os = use for non cpu intensive programs, for small binary sizes.

i was thinking, that i should compile KDE and the QT library with '-Os' because KDE arely uses much CPU, and having a smaller binary size means KDE, and its programs will load faster.. am i not correct ?

i was also thinking, i should compile Xorg with -O3. because X is very cpu intensive when im running games.

also if possible, i should compile the kernel with -O3.

however, im unsure how to compile things like Glibc 'emerge system'
maybe -O3 for speed, since almost everything uses GLIBC.
or maybe, -Os because although glibc and otther librarys are used by almost everything, they are not used much in cpu intensive loops.... also to make it load faster ?

and most other things with '-O2' for a compromise.

what are your opinions ?
 
Old 08-05-2004, 01:17 AM   #2
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
That's a hell of an undertaking. First and foremost, I wouldn't dare touch the way the kernel is compiled. The kernel is a very touchy thing and optomizations are known to break things.

Also, compiling with optomizations breaks debugging applications for the most part. If you've ever tried to use gdb to figure out why something crashed using a core file from an optomized application you'd know what I mean. If you're not concerned about using debugging applications and you want smaller binary sizes then you can just strip all your binaries (man strip).

I also wouldn't touch glibc with optomizations. I'd look around online for results from other people trying the same things to see if you can find anything useful from other peoples' experiences.
 
Old 08-05-2004, 09:11 AM   #3
qwijibow
LQ Guru
 
Registered: Apr 2003
Location: nottingham england
Distribution: Gentoo
Posts: 2,672

Original Poster
Rep: Reputation: 47
i thought binaries were automatically stripped after compilation ?
 
Old 08-05-2004, 10:03 AM   #4
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
Not always. Some packages will call strip on the binary after compilation, but certainly not all.
 
Old 08-05-2004, 01:22 PM   #5
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 53
hi,
(this is just eduated opinion)
it's not quite that complicated
don't optimize glibc or gcc or they will be broken
do optimize the kernel like crazy even get the patches and compile the kernel with icc if you have P4
beyond that never use -g so you don't get those awfull debugging symbols
and use -O3 on EVERYTHING else along with whatever other flags make your system run best like
-funroll-loops -ftracer -momit-leaf-frame-pointer -fprefetch-loop-arrays
very important to use -march fag for your system
(do basic benchmarking to figure out whats best) and don't rely on gcc mythology (gentoo folks seemed to have developed alot of myth about gcc flags)
basically everything runs faster with agressive optimizations
otherwie it's to do benchmarking app by app and the -Ox flag sets are out and you actually have to try all possible combinations to get what is actually best which is imposible.

the gentoo people often recomand -Os but i think they have not done benchmarking and looked at the results of that or they wouldn't say it. Size really doesn't matter.

also when you are done do prelinking
and everything will be zoom zoom
(some thing either wont compile or won't run right done like this so sometimes you have to redo things with the flags that come in the package)

The kernel is absolutely the most important thing to optomize
 
Old 08-06-2004, 09:52 AM   #6
qwijibow
LQ Guru
 
Registered: Apr 2003
Location: nottingham england
Distribution: Gentoo
Posts: 2,672

Original Poster
Rep: Reputation: 47
thanks....
Prelinking ? whats that. ive never heard of that before.

anyways, thanks.

i did some benchmarking of my own, i used an Artifical inteligence program i wrote. No optimisation caused it to complete in 16 seconds, -O1 knocked it down to 7, -O2 down to 6.5 -O3 down to 6, and -Os down to 6.5.. same as -O2 but a few kilobytes smaller in size.

i was tempted to use -Os to reduce the time it takes to load the binaries off the disk.

so far, ive setup my use flags, to link againsed only what i need, and my CFLAGS are -O3 -march=athlon -pipe -fomit-frame-pointer.

im pretty sure -funroll-loops is part of -O3, (which is why -O3 results in larger binary sizes) anyways, thanks for the help... im currently bootstrapping, and posting this in 'links' its the first time ive used a command line web browser, i have to say im quite impressed. bt having trouble loging onto developerfusion.com
 
Old 08-06-2004, 06:27 PM   #7
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 53
to eliminate any doubt about what is or is not in -O3
also a subject that has drifted into mythology
took at gcc source code file toplev.c
line 4847 and down
the section starts with
Code:
  if (optimize >= 1)
Gentoo Prelink Guide
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Identifying CPU/Architecture for GCC Optimisations detly Linux - Hardware 3 04-27-2005 09:44 PM
Compiling mpeglib without optimisations seb3579 Linux - Software 1 06-21-2004 08:51 PM
Advice wanted before installing Gentoo! ssimontis Linux - Newbie 23 06-05-2004 09:10 AM
Compiler OPtimisations ShockTherapy Slackware 2 04-20-2004 10:19 AM
gentoo emerge...advice, please b0uncer Linux - Software 2 10-19-2003 06:56 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration