Quantcast
Channel: Hacker News
Viewing all articles
Browse latest Browse all 25817

Zapcc – A faster C++ compiler

$
0
0

I just joined the private beta program of zapcc. Zapcc is a c++ compiler, based on clang which aims at being much faster than other C++ compilers. How they are doing this is using a caching server that saves some of the compiler structures, which should speed up compilation a lot.

Every C++ developer knows that compilation time can quickly be an issue when programs are getting very big and especially when working with template-heavy code.

To benchmark this new compiler, I use my Expression Template Library (ETL). This is a purely header-only library with lots of templates. There are lots of test cases which is what I'm going to compile. I'm going to compare against Clang-3.7 and gcc-4.9.3.

I have configured zapcc to let is use 2Go RAM per caching server, which is the maximum allowed. Moreover, I killed the servers before each tests.

Debug build

Let's start with a debug build. In that configuration, there is no optimization going on and several of the features of the library (GPU, BLAS, ...) are disabled. This is the fastest way to compile ETL. I gathered this result on a 4 core, 8 threads, Intel processor, with an SSD.

The following table presents the results with different number of threads and the difference of zapcc compared to the other compilers:

Compiler-j1-j2-j4-j6-j8
g++-4.9.3350s185s104s94s91s
clang++-3.7513s271s153s145s138s
zapcc++158s87s47s44s42s
Speedup VS Clang3.243.1033.253.293.28
Speedup VS GCC2.212.122.212.132.16

The result is pretty clear! zapcc is around three times faster than clang and aroundtwo times faster than GCC. This is pretty impressive!

For those that think than clang is always faster than GCC, keep in mind that this is not the case for template-heavy code such as this library. In all my tests, clang has always been slower and much memory hungrier than gcc on template-heavy C++ code. And sometimes the difference is very significant.

Interestingly, we can also see that going past the physical cores is not really interesting on this computer. On some computer, the speedups are interesting, but not on this one. Always benchmark!

Release build

We have seen the results on a debug build, let's now compare on something a bit more timely, a release build with all options of ETL enabled (GPU, BLAS, ...), which should make it significantly longer to compile.

Again, the table:

Compiler-j1-j2-j4-j6-j8
g++-4.9.3628s336s197s189s184s
clang++-3.7663s388s215s212s205s
zapcc++515s281s173s168s158s
Speedup VS Clang1.281.381.241.261.29
Speedup VS GCC1.211.301.131.121.16

This time, we can see that the difference is much lower. Zapcc is between 1.2 and 1.4 times faster than clang and between 1.1 and 1.3 times faster than gcc. This shows that most of the speedups from zapcc are in the front end of the compiler. This is not a lot but still significant over long builds, especially if you have few threads where the absolute difference would be higher.

We can also observe that clang is now almost on par with GCC which shows that optimization is faster in clang while front and backend is faster in gcc.

You also have to keep in mind that zapcc memory usage is higher than clang because of all the caching. Moreover, the server are still up in between compilations, so this memory usage stays between builds, which may not be what you want.

Incremental build

Normally, zapcc should shine at incremental building, but I was unable to show any speedup when changing a single without killing the zapcc servers. Maybe I did something wrong in my usage of zapcc.

Conclusion

In conclusion, we can see that zapcc is always faster than both gcc and clang. Moreover, on debug builds, it is much faster than any of the two compilers, being more than 2 times faster than gcc and more than 3 times faster than clang. This is really great. Moreover, I have not see any issue with the tool so far, it can seamlessly replace clang without problem.

It's a bit weird that you cannot allocate more than 2Go to the zapcc servers.

For a program, that's really impressive. I hope that they are continuing the good work and especially that this motivates other compilers to improve the speed of compilation (especially of templates).

If you want more information, you can go to theofficial website of zapcc


Viewing all articles
Browse latest Browse all 25817

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>