MMS • RSS
Article originally posted on InfoQ. Visit InfoQ
Zapcc is a caching C++ compiler based on a fork of Clang/LLVM that claims to be up to 50x faster on recompilations and 2–5x faster on full builds. Developed by Creemple and initially released at the end of 2015, Zapcc is now open-source.
The key idea behind Zapcc compilation speedup is using a compilation server (
zapccs), which stays in memory and receives compilation commands from clients. Zapccs parses C++ header files just once and keeps in memory both all template instantations and generated code. In this regard, Zapcc could be seen as using a sort-of precompiled headers on steroids, but it is able to cache much more information than precompiled headers without actually requiring all the setup for precompiled headers to work.
Zapcc is particularly faster than Clang when dealing with overly complex C++ header files, especially those using templates. So, it is no surprise that Zapcc is 40x faster than Clang when building
boost::math, 4x faster for a WebKit full build, and 2x faster for a Clang full build. Similarly, on incremental recompilations, Zapcc can be up to 50x faster than Clang. On the other hand, when source files are more complex than the header files, Zapcc does not provide much benefit, with plain C projects being Zapcc worst case with no acceleration at all. In fact, Zapcc disables caching for C files.
Run-time performance of code generated by Zapcc is equivalent to the that of code generated by Clang, Creemple claims.
The amount of memory used by
zapccs is an important factor to determine overall performance. Zapcc allows developers to set a memory limit to make
zapccs automatically restart with an empty cache when that limit is reached.
Zapcc will try to start a new server instance if it does not find one available and developers can control the maximum number of concurrent servers using the
-j flag. Depending on the complexity of the project, Zapcc may run faster with fewer servers running with a higher memory limit.
According to its main developer Yaron Keren, Zapcc is a heavily-modified Clang, with over 200k lines changed. This makes quite hard to think that it could some day make it into CLang baseline. Zapcc is meant to be a drop-in replacement for Clang and gcc and aims to integrate with all build systems. It is fully supported on Linux x64.