[mythtv] Compiler Tuning Flags

Daniel Kristjansson danielk at cat.nyu.edu
Mon Jun 20 11:46:48 UTC 2005


On Mon, 2005-06-20 at 07:40 +0100, Ed W wrote:
> >>-Os. For some reason, GCC just does weird things with -Os sometimes. ;)
> >Which is why Myth, by default, doesn't use aggressive compiler options.
> I thought -Os was considered to be the opposite of aggressive?
> The manual suggests that it's kind of like -O2 but with any tests that 
> generate bulky code turned off.
Mostly -Os is just -O2 but without the nop's that make loops and variable
data aligned. But almost all OSS code is compiled and tested at -O2, so
anything you change can break things. 

As for the speed of -Os, it can be faster on 386 and P4 cores, but is
usually slower on 486, Pentium I/II/III, and Pentium-M cores. On most
embedded processors it is faster, and on most server processors it
makes no difference because code alignment is usually mandatory.
Basically, it saves cache at the expense of optional code alignment.
A P4 doesn't care about an code alignment once the code is in the L1
code cache, and almost always code that needs to be fast fits entirely
in the code cache. But all processors with a cache care about code
size, so sometimes -Os code is faster than -O2 code.

> Usually the boys trying to knock holes in gentoo pick out the -Os flag 
> and claim that we should all use that rather than -O2/-O3 because it 
> would make things faster...
The problem with that argument is that:
 1/ -O3 compiled code is almost always faster than -O2 and -Os
 2/ If you want the least irritation you should use whatever compiler
    flags the developers are using, since this will be the most tested
    set of flags, and usually this is "-O2"
 3/ Optimizing code is a reason people start using Gentoo, not why
    they keep using it. For 95% of all applications -O3 makes compiles
    take twice as long for only a 5% speed boost.

The real time savings with gentoo is that you don't enter dependency
hell just because you use a few 3rd party packages, but this is balanced
against needing to compile most of those packages and the fact that it
is a more cutting edge distribution than say debian.
   
BTW I use Gentoo and compile everything I'm not actively developing
with "-O2 -g" so I get nice useful backtraces when some library is
giving me trouble. It makes everything run slower and uses up 5x the
memory and disk space. I also use Mandrake, and recently Fedora.
I left RedHat after 6, 7 and 8 caused me great grief, but Fedora
seems pretty polished compared to those RedHat releases.

But I'll comment no more on distibutions, it's not really relevant
to MythTV, which we hope will run on all of them.

-- Daniel



More information about the mythtv-dev mailing list