[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sheflug] CFLAG Question]



----- Original Message ----- 
From: "Seb James" <seb [at] esfnet.co.uk>
To: "Sheflug" <sheflug [at] sheflug.co.uk>
Cc: "Wonkey Donkey" <wonkey_donkey [at] blueyonder.co.uk>
Sent: Monday, February 27, 2006 11:30 AM
Subject: [Fwd: Re: [sheflug] 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
>>

Thanks Seb. I've been revisiting these areas of late, hence the reason for 
posting some of this stuff.

The -O3 build that I mentioned the other day went without a hitch. The 
compilation itself was very snappy indeed, but after the initial reboot, I 
got the feeling it was just a tad slower than my previous ones, which 
used -O2.

As for disk space, well I have oodles of that.  I will certainly be staying 
with Gentoo too. Despite them removing the Stage 1 info a while back, it is 
still possible to do it, and its the only method I use.

Steve. 


___________________________________________________________________

Sheffield Linux User's Group -
http://www.sheflug.co.uk/mailfaq.html

  GNU the choice of a complete generation.