Improve compile performance when using Clang 3.6

Hi Everyone,

I just downloaded and built Clang 3.6. It appears performance has
dropped considerably from Clang 3.2 through 3.5 (I've been
building/using it for that long).

Is there anything obvious I am missing that might affect the
performance between 3.5 and 3.6? Like is something enabled that used
to be disabled or missing?

Otherwise, below is what a typical compiler invocation looks like. In
the past, it performed fine. Does it set off any red flags for anyone?

For completeness, I'm trying to run self tests under the sanitizers.
I'm interested in the dynamic analysis at this point, and not static
analysis provided by ccc-analyze and friends.

Thanks in advance.

Hi Everyone,

I just downloaded and built Clang 3.6. It appears performance has
dropped considerably from Clang 3.2 through 3.5 (I've been
building/using it for that long).

Is there anything obvious I am missing that might affect the
performance between 3.5 and 3.6? Like is something enabled that used
to be disabled or missing?

Otherwise, below is what a typical compiler invocation looks like. In
the past, it performed fine. Does it set off any red flags for anyone?

For completeness, I'm trying to run self tests under the sanitizers.
I'm interested in the dynamic analysis at this point, and not static
analysis provided by ccc-analyze and friends.

Interesting. Could you share the performance numbers, and try to figure out
which specific sanitizer
is causing a problem (i.e. try to compare just -fsanitize=address, and then
various flavors of -fsanitize=undefined
one by one: -fsanitize=shift, -fsanitize=null etc.). We are not aware of
known performance degradation under
sanitizers in 3.6 release.

Hi Alexey,

Is there anything obvious I am missing that might affect the
performance between 3.5 and 3.6? Like is something enabled that used
to be disabled or missing?

Otherwise, below is what a typical compiler invocation looks like. In
the past, it performed fine. Does it set off any red flags for anyone?

For completeness, I'm trying to run self tests under the sanitizers.
I'm interested in the dynamic analysis at this point, and not static
analysis provided by ccc-analyze and friends.

Interesting. Could you share the performance numbers, and try to figure out
which specific sanitizer
is causing a problem (i.e. try to compare just -fsanitize=address, and then
various flavors of -fsanitize=undefined
one by one: -fsanitize=shift, -fsanitize=null etc.). We are not aware of
known performance degradation under
sanitizers in 3.6 release.

Yes, will do.

I should have the performance data between 3.5 and 3.6 later tonight.
I blew out my Clang 3.5 install, so I need to fetch it and build it
again.

Jeff

Hi Alexey,

Is there anything obvious I am missing that might affect the
performance between 3.5 and 3.6? Like is something enabled that used
to be disabled or missing?

...
Interesting. Could you share the performance numbers, and try to figure out
which specific sanitizer
is causing a problem (i.e. try to compare just -fsanitize=address, and then
various flavors of -fsanitize=undefined
one by one: -fsanitize=shift, -fsanitize=null etc.). We are not aware of
known performance degradation under
sanitizers in 3.6 release.

Here are the performance numbers that I am experiencing. All tests
were run on the same machine (OS X 10.8.5, fully patched).

3.4.2: ~5 minutes
3.5: ~7 minutes, 30 seconds
3.6: ~9 minutes

I'm used to building with Clang 3.3 and 3.4, so I wanted to include
one of those versions. With 3.6, the time has nearly doubled.

Are the numbers above on par with what you would expect?

Jeff

***** Crypto++ *****

If interested, you can checkout Crypto++ with:

    svn checkout p/cryptopp/code - Revision 610: /trunk/c5 cryptopp

Tweaks to the GNUmakefile include: -g3 -Os -fPIC -stdlib=libc++
-fsanitize=address -fsanitize=undefined

A full GNUmakefile diff is available at GNUmakefile Diff - Pastebin.com.

***** Clang 3.4.2 *****

Elapsed time: 01:17:06 - 01:12:05 ~= 5 minutes.

$ export CXX=/usr/local/bin/clang++
$ $CXX --version
clang version 3.4.2 (tags/RELEASE_34/dot2-final)
Target: x86_64-apple-darwin12.6.0
Thread model: posix
$ date && make static && date
Thu Apr 2 01:12:05 EDT 2015
/usr/local/bin/clang++ -DNDEBUG -g3 -Os -fPIC -stdlib=libc++
-fsanitize=address -fsanitize=undefined -Wall
-Wno-tautological-compare -Wno-unused-value -Wno-unused-variable
-Wno-unused-parameter -Wno-unused-function -I/usr/lib/c++/v1
-DCRYPTOPP_DISABLE_ASM -pipe -c 3way.cpp
/usr/local/bin/clang++ -DNDEBUG -g3 -Os -fPIC -stdlib=libc++
-fsanitize=address -fsanitize=undefined -Wall
-Wno-tautological-compare -Wno-unused-value -Wno-unused-variable
-Wno-unused-parameter -Wno-unused-function -I/usr/lib/c++/v1
-DCRYPTOPP_DISABLE_ASM -pipe -c adler32.cpp
...
/usr/local/bin/clang++ -DNDEBUG -g3 -Os -fPIC -stdlib=libc++
-fsanitize=address -fsanitize=undefined -Wall
-Wno-tautological-compare -Wno-unused-value -Wno-unused-variable
-Wno-unused-parameter -Wno-unused-function -I/usr/lib/c++/v1
-DCRYPTOPP_DISABLE_ASM -pipe -c zlib.cpp
libtool -static -o libcryptopp.a 3way.o adler32.o algebra.o algparam.o
arc4.o asn.o authenc.o base32.o base64.o ...
ranlib libcryptopp.a
Thu Apr 2 01:17:06 EDT 2015

***** Clang 3.5 *****

Elapsed time: 00:31:53 - 00:24:36 ~= 7 minutes, 30 seconds.

$ export CXX=/usr/local/bin/clang++
$ $CXX --version
clang version 3.5.0 (tags/RELEASE_350/final)
Target: x86_64-apple-darwin12.6.0
Thread model: posix
$ date && make static && date
Thu Apr 2 00:24:36 EDT 2015
/usr/local/bin/clang++ -DNDEBUG -g3 -Os -fPIC -stdlib=libc++
-fsanitize=address -fsanitize=undefined -Wall
-Wno-tautological-compare -Wno-unused-value -Wno-unused-variable
-Wno-unused-parameter -Wno-unused-function -I/usr/lib/c++/v1
-DCRYPTOPP_DISABLE_ASM -pipe -c 3way.cpp
/usr/local/bin/clang++ -DNDEBUG -g3 -Os -fPIC -stdlib=libc++
-fsanitize=address -fsanitize=undefined -Wall
-Wno-tautological-compare -Wno-unused-value -Wno-unused-variable
-Wno-unused-parameter -Wno-unused-function -I/usr/lib/c++/v1
-DCRYPTOPP_DISABLE_ASM -pipe -c adler32.cpp
...
/usr/local/bin/clang++ -DNDEBUG -g3 -Os -fPIC -stdlib=libc++
-fsanitize=address -fsanitize=undefined -Wall
-Wno-tautological-compare -Wno-unused-value -Wno-unused-variable
-Wno-unused-parameter -Wno-unused-function -I/usr/lib/c++/v1
-DCRYPTOPP_DISABLE_ASM -pipe -c zlib.cpp
libtool -static -o libcryptopp.a 3way.o adler32.o algebra.o algparam.o
arc4.o asn.o authenc.o base32.o base64.o ...
ranlib libcryptopp.a
Thu Apr 2 00:31:53 EDT 2015

***** Clang 3.6 *****

Elapsed time: 2:17:01 - 02:07:53 ~= 9 minutes.

$ export CXX=/usr/local/bin/clang++
$ $CXX --version
clang version 3.6.0 (tags/RELEASE_360/final)
Target: x86_64-apple-darwin12.6.0
Thread model: posix
$ date && make static && date
Thu Apr 2 02:07:53 EDT 2015
/usr/local/bin/clang++ -DNDEBUG -g3 -Os -fPIC -stdlib=libc++
-fsanitize=address -fsanitize=undefined -Wall
-Wno-tautological-compare -Wno-unused-value -Wno-unused-variable
-Wno-unused-parameter -Wno-unused-function -I/usr/lib/c++/v1
-I/usr/lib/c++/v1 -DCRYPTOPP_DISABLE_ASM -pipe -c 3way.cpp
/usr/local/bin/clang++ -DNDEBUG -g3 -Os -fPIC -stdlib=libc++
-fsanitize=address -fsanitize=undefined -Wall
-Wno-tautological-compare -Wno-unused-value -Wno-unused-variable
-Wno-unused-parameter -Wno-unused-function -I/usr/lib/c++/v1
-I/usr/lib/c++/v1 -DCRYPTOPP_DISABLE_ASM -pipe -c adler32.cpp
...
/usr/local/bin/clang++ -DNDEBUG -g3 -Os -fPIC -stdlib=libc++
-fsanitize=address -fsanitize=undefined -Wall
-Wno-tautological-compare -Wno-unused-value -Wno-unused-variable
-Wno-unused-parameter -Wno-unused-function -I/usr/lib/c++/v1
-I/usr/lib/c++/v1 -DCRYPTOPP_DISABLE_ASM -pipe -c zlib.cpp
libtool -static -o libcryptopp.a 3way.o adler32.o algebra.o algparam.o
arc4.o asn.o authenc.o base32.o base64.o ...
ranlib libcryptopp.a
Thu Apr 2 02:17:01 EDT 2015

+Kuba, Anna

Sorry for the late response. Unfortunately, I don’t have a Mac machine to experiment on…
Do you have the numbers for plain -fsanitize=address, or plain -fsanitize=undefined, or
subset of UBSan checks, such as -fsanitize=shift, -fsanitize=alignment, etc?

We haven’t observe visible slowdown recently, however we usually run ASan on Linux, and use at least -O1.
Maybe the situation improved in trunk after recent Anna’s fixes.