Clang'ed FreeBSD: Builds Quicker, Uses Way Less RAM

Written by Michael Larabel in BSD on 5 September 2012 at 02:16 PM EDT. 25 Comments
BSD
A FreeBSD developer has carried out a series of performance tests to explore the impact that LLVM/Clang as the default FreeBSD compiler has on FreeBSD 10 in its current form. The Clang compiler performance was compared to GCC 4.2.1 and GCC 4.7.1. Clang mostly comes out ahead of GCC on FreeBSD.

With the yet-to-be-released FreeBSD 10, Clang is the default compiler with GCC being deprecated from this popular BSD operating system. The simple conclusion from Dimitry Andric that did the compiler testing on FreeBSD 10.0-CURRENT is that Clang compiles mostly faster than GCC (sometimes by a wide margin) and that Clang uses "significantly less" memory during the compilation process.

This testing was looking at the compilation speed as opposed to the speed of the result binaries, which is where Phoronix compiler benchmarks are mostly focused on.

Below are the key remarks from Dimitry's FreeBSD 10 amd64 compiler testing between GCC and LLVM/Clang.
Summary:
--------
For building this specific large C++ program, gcc 4.2.1 is ~86% slower than clang 3.1 in real time, ~82% slower in user time, and ~176% slower in system time. The maximum resident set size during building is ~217% larger, and it causes ~279% more page reclaims.

Though gcc 4.7.1 is faster than its older version, it is still ~68% slower than clang 3.1 in real time, ~64% slower in user time, and ~161% slower in system time. The maximum resident set size during building is ~220% larger, and it causes ~208% more page reclaims.

Finally, clang 3.2 is ~3% slower than clang 3.1 in both real time and user time, and ~2% slower in system time. The maximum resident set size and the number of page reclaims during building are approximately equal.

Conclusion:
-----------
Clang 3.1 is clearly the fastest compiler for building this specific large C++ program, with clang 3.2 trailing closely behind. Both are significantly faster, and use much less memory than either version of gcc.
So the Clang C/C++ compiler is doing very good in the FreeBSD world for building packages faster while using less memory. The only negative news towards Clang from these results is that the currently-in-development LLVM 3.2 is slightly slower than LLVM 3.1, but hopefully the build-time performance regressions can be worked out prior to the official 3.2 release and isn't becoming a trend of Clang slowing down as more functionality is introduced into the Apple-sponsored compiler.

The compiler testing data in full is available from this mailing list post.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week