[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[sheflug] [Fwd: Re: CFLAG Question]
I sent this to the list on the 22nd of February, but it didn't get
through. Here it is again.
Seb
-------- Forwarded Message --------
> From: Seb James <seb [at] esfnet.co.uk>
> To: sheflug <sheflug [at] sheflug.co.uk>
> Subject: Re: [sheflug] CFLAG Question
> Date: Wed, 22 Feb 2006 10:18:33 +0000
>
> On Tue, 2006-02-21 at 22:13 +0000, James Rogers wrote:
> > Wonkey Donkey wrote:
> > > Ok, first off, the distro is Gentoo, and the machine has a P4 3.2 Northwood
> > > CPU and 2Gb of very low latency ram.
> > >
> > > The machine is currently building the toolchain for Gentoo, and is using a
> > > quite normal set of CLAGS, except for the fact that -O2 is now -O3. (I'm
> > > running this purely as a test, its not a production machine or anything).
> > > Everything I have read about it seems to suggest that the higher the -O
> > > value, the better optimised the resulting code will be, but at the expense
> > > of compilation time and memory usage.
> > >
> > > Compared with my usual -O2 setting, this thing is taking an absolute age to
> > > compile and build. I did expect extra time being needed of course, but I'm
> > > wondering just how beneficial the end result may be and if it is worth
> > > bothering with -O3.
> > >
> > > As a general question, am I likely to see a significant speed improvement
> > > once the machine is built and rebooted ? I don't mind the extra time if its
> > > going to be worthwhile; but to give you an idea of the differences I'm
> > > seeing right now, GCC usually takes around 25 minutes, whereas with -O3 it
> > > took almost an hour. Glibc is currently running and has taken well in excess
> > > of an hour already; it usually takes around 40 minutes.
> > >
> > > Is a system built with -O3 going to be so much more improved than with -O2,
> > > and if not, can anybody suggest in simple terms why there is such a
> > > difference in compile times for such a small difference in the end result ?
> > >
> > > Thanks.
> > >
> > > Steve.
> > >
> >
> > IMHO -O3 isn't worth it, for most apps. Beyond -O2 it's only really
> > worth it for maths/physics simulations etc where the bottleneck is the CPU.
> > Personally i run -Os which is -O2 but then optimized for smaller binary
> > size and is thought of highly on gentoo.org forums.
>
> This makes sense. The bottleneck in speed as far as your usual desktop
> user experience is most likely how long it takes to start the program.
> That is governed by a combination of processor speed to run through the
> program start up logic, but crucially by the time it takes to read the
> program from hard disk into RAM - which has to happen first. -Os will
> result in smaller binaries which take less time to load into RAM.
>
> As to which optimization is the best... Well it completely depends on
> the application but I personally gave up worrying which optimizations I
> use for my Gentoo system a long time ago.
>
> In fact here they are:
>
> CFLAGS="-g -march=athlon-xp -mmmx -m3dnow"
>
> No optimizations at all! I do like Gentoo though - because it gives me a
> toolchain and all the headers for my programs by default. On redhat I
> always had to mess around installing the dev packages. As shown above by
> my CFLAGS, I can also compile debugging symbols into my system to find
> out when things are acting up.
>
> That said, I use -Os for the binaries which we build into our embedded
> Linux and I think it's the most useful all round optimization.
>
> Seb
>
--
Embedded Software Foundry Ltd. 'Embedded Linux Development'
Tel: +44 (0)845 4580277 Web: http://www.esfnet.co.uk/
Axiom Tech Open Source Member: http://www.axiomtech.co.uk/
Gpg key: http://www.esfnet.co.uk/ssl/seb.gpg
___________________________________________________________________
Sheffield Linux User's Group -
http://www.sheflug.co.uk/mailfaq.html
GNU the choice of a complete generation.