port:libclang (and libLLVM)

René J.V. Bertin rjvbertin at gmail.com
Thu Mar 10 00:31:26 PST 2016


On Wednesday March 09 2016 20:48:19 Jack Howarth wrote:

>>> Frankly I'd be surprised if that leads to a 10% performance difference!
>>
>> Why? My understanding is that the optimizations for -Os are equivalent
>> to -O2 with the emphasis on size reduction. The additional
>> optimizations from -O2 to -O3 would seem sufficient to produce a 10%
>> execution optimization, no?

I think it's an accepted truth that using -O3 instead of -O2 rarely gives that kind of performance benefit, and that it's rather something that you'd reserve for cases where every percent gained counts (and you don't care about code size). That's speaking in general of course. AFAIK, -O3 also activates auto-vectorisation and that can indeed make a huge difference. Except of course the performance you can gain with that is rarely in algorithms that are the real performance bottleneck. A compiler is not the kind of application in which I'd expect to get a lot of benefit from auto-vectorisation.
There's one compiler option that has given me really surprising gains in the past (on top of -O2+ that is): -mdynamic-no-pic . I've seen that give 15% performance increases (thanks once more to Shark for pointing out the option). Of course that was on 32bit PPC hosts. I've never measured the option's effect on x86 and given how on x86_64 it can even be used for relocatable code (shared libraries) I tend to expect that it will no longer make much of a difference.

>The only other difference I see between the fink and MacPorts
>packaging is the use of -DLLVM_ENABLE_RTTI=ON in MacPorts. My
>understanding is that these additional virtual functions can introduce
>overhead in c++.

Yes, you're probably right. Combined with the (supposed) additional overhead of using a shared libLLVM that could well add up to the performance differences I've seen.
Except that I don't know if Apple build with LLVM_ENABLE_RTTI=ON or not; I've never compared Fink's clang builds.

R



More information about the macports-dev mailing list