[cfe-dev] Clang versus GCC speed

Daniel Dunbar daniel at zuster.org
Sat Nov 21 21:28:49 PST 2009


Hi David,

This is interesting stuff, can you provide more concrete tests cases &
numbers? For example, it would be interesting to break down the
numbers just to verify that the extra time is in Sema (compare -MM
numbers (which is ~= -Eonly) to -fsyntax-only to -S).

On Fri, Nov 20, 2009 at 1:04 PM, David Chisnall <csdavec at swan.ac.uk> wrote:
>
> On 20 Nov 2009, at 18:55, Douglas Gregor wrote:
>
>> On Nov 20, 2009, at 10:36 AM, David Chisnall wrote:
>>> I just did some tests with Objective-C programs and found
>>> clang much slower than GCC 4.2, with an optimized build of LLVM and
>>> Clang and a stock build of GCC.
>>
>>
>> This isn't what we're seeing. We're seeing Clang being consistently
>> faster than GCC 4.2.
>>
>> Are you certain that you built LLVM and Clang in Release-Asserts?
>> Debug builds are horribly slow, and Release builds are still a bit
>> slower than Release-Asserts builds.
>
> I was using the wrong binary.  Running the tests again, there's about
> a 10% variation in speeds each time I run clang and gcc, but they both
> end up being approximately the same speed.  Using -fsyntax-only on
> GNUstep's Cocoa.h takes slightly longer with clang than GCC on
> average, although the fastest result for clang is slightly better than
> the slowest result for gcc.
>
> Are your tests relative to Apple's GCC?  It's a lot slower than FSF
> GCC for Objective-C, at least - not sure why, but FSF GCC can usually
> compile a couple of files before Apple GCC reports the first warning
> in one.
>
> With a Release-Asserts build, clang is very slightly slower than the
> GCC 4.2.1 build included with the FreeBSD 8 base system for Objective-
> C (although it does produce warnings that GCC doesn't produce and
> supports a few more language features).
>
> I took the preprocessed Cocoa.h from GNUstep to a Mac and ran clang
> and gcc -fsyntax-only and, indeed Apple's GCC takes a bit more than
> twice as long to run.  The same file on FreeBSD takes about the same
> time between FSF GCC and Clang (Release-Asserts build).  I'm not sure
> if this is just an Objective-C thing, or if Apple's GCC is much slower
> for C too.

It's hard to evaluate this -- Apple GCC has many other changes so this
could be almost anything (e.g., better optimization by GCC of GCC
itself, or alternately FreeBSD GCC compiling Clang worse). I'm
curious, but I'm also only really interested in making Clang faster,
so if you wanted to investigate more it would probably make sense to
see if Clang is doing something "bad" on FreeBSD, or if Clang is
somehow slower on FreeBSD than it should be (compare on equivalent
hardware?). It would also make sense to evaluate C compile time first
before looking at Obj-C; do a benchmark compile of gcc, say.

In my tests on Linux, Clang was substantially faster at building stuff
(I sent the Blender compile time numbers to the list, and that was
something like 50% faster IIRC) than GCC, so I don't have any reason
to believe the performance difference is Apple specific.

 - Daniel

> David
>
> -- Sent from my Difference Engine
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>




More information about the cfe-dev mailing list