InfoQ Homepage News Caching Clang-Based C++ Compiler Zapcc Open-Sourced

# Caching Clang-Based C++ Compiler Zapcc Open-Sourced

This item in japanese

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 it 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.

Style

## Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.