12 ms·
Zapcc – A faster C++ compiler
- jeremiep 10y agoI would love to see a comparison of the performance of compiled programs. If zappcc creates slower executables but spitting them out faster, it could be used during development to speed up iterations. And if the executables are faster, I'm very curious as to how they achieved both faster compilation and faster runtimes.
- zbowling 10y agoIn theory the compiled output should be the same as clang (if there are no bugs) being that this is just an optimized clang where compile structures are cached.
- userbinator 10y agoI think a good example of this is tcc, one of the fastest C compilers I've seen --- because it doesn't do much optimisation at all and is single-pass, it can generate code as it parses, but the output is dismally inefficient. Another example of ultrafast compilation is Delphi, but once again the generated code looks more like a dumb line-by-line translation with plenty of redundant and unnecessary instructions (making decompiling interesting in that it easily produces something quite close to the original source.)
- greglindahl 10y agoYou might want to compare tcc to just about any compiler with -O0 -- they're a lot faster if they are allowed to generate slow code. It's also super-straightforward to find compiler bugs, if you're lucky enough that it's an O0 bug!
- olegkikin 10y agoLooks like the speed isn't compromised. Scroll all the way down on this page: http://www.zapcc.com/benchmarks/ http://www.zapcc.com/benchmarks/
- wichtounet 10y agoNormally, it should make almost difference compared to the code generated by the same version of clang on which zapcc is based. It may make a difference in the long term if they don't keep up to date with clang trunk.
- rurban 10y agozapcc uses clang-4. clang-4/zapcc is massively faster than gcc-6 for my usecases, and significantly faster than clang-3.9. perl is 2x faster than with gcc-6 -O3.
- the_duke 10y agoMhm. I'm confused. The value of a caching compiler should really become apparent in incremental builds, as in rebuilding after changing a single file. Yet the author talks about "not seeing any improvements". Like he said, he might be doing something wrong. The speedup observed anyway might come from the compilers having to rebuild/instantiate templated code everytime it's included.
- DannyBee 10y ago"The value of a caching compiler should really become apparent in incremental builds, as in rebuilding after changing a single file. Yet the author talks about "not seeing any improvements"." There are millions of reasons this may not be true in C++. For starters, the use of time and date macros, etc. Without precise dependency tracking of what source lines are dependent on what macros (which is super hard, and i don't think they do), which is not usually what is done (dependency tracking is often much more coarse grained), you may not see an improvement. VisualAge C++ was one of the best incremental C++ implementations i ever saw, and even it did not get to this level.
- pjmlp 10y ago> VisualAge C++ was one of the best incremental C++ implementations i ever saw, and even it did not get to this level. How did it compare with Energize C++? I only know both from magazines during those days, even though someone uploaded an Energize video to YouTube. In regards to VisualAge C++ I think only those of us that were active back then can remeber anything about it. Besides the magazines I had with the product review, I never seen much information being posted on the Internet.
- DannyBee 10y agoI never used Energize C++. I remember looking at the code to visualage C++ when i was at ibm about 12 years ago. It was fairly impressive (it built a database of the program with fairly fine grained dependency tracking), at least to younger me. I don't know if people today would have thought it was a mess or not :)
- deleted 10y ago[deleted]
- dman 10y agoApplied for the beta program day before yesterday, hope I get in.
- mhd 10y ago> In conclusion, we can see that zapcc is always faster than both gcc and clang. For testing his template-heavy library. A very small data set, and while templates are one of the problems when it comes to C++ compilation speed, it's certainly not the only one. Let's see the differences when compiling Firefox or the whole KDE suite.
- olegkikin 10y agoOn the main site they have all kinds of examples. http://www.zapcc.com/benchmarks/ http://www.zapcc.com/benchmarks/
- santaclaus 10y agoWeird that the run-time benchmarks are on different codebases than the compilation benchmarks.
- wichtounet 10y agoYou're right, I should emphasize on this on the conclusion ;)
- santaclaus 10y agoHell, even if this only gives a speedup with template heavy code I'm on board. We use a number of header only, template meta programmed to death libraries (RapidJSON, Eigen, ViennaCL), and compilation speed improvements would be a huge productivity boost.
- david-given 10y agoThis is based on clang --- it's not a new compiler. <tangent> Are the any working open source C++ compilers which aren't based on gcc or clang? I know of TenDRA, which appears to have ceased to exist and was always kind of incomprehensible and non-working and apparently it never got as far as STL support; there Path64, whose github page no longer contains the compiler repo; there's Open64, whose website no longer exists (although there does seem to be a daughter project, OpenUH, which did a release last year)... Is there anything else?
- DannyBee 10y ago"Is there anything else?" For C++? No. Too hard of a language to waste phd students maintaining :) Over the years there have been a few more (openC++ is a good example, ROOT used to be one too), but they are all dead now AFAIK. One reason is that research in compilers is pretty much not in the frontends anymore. For any research still being done that uses C++ as a base, gcc/clang/llvm pretty much work fine. LLVM in particular has an IR that works for most researchers, is not hard to understand, etc. For people who want to try to build larger solutions, they usually start with C (see, for example, libfirm and friends). Commercial folks use EDG or, actually, a lot are also starting to use clang now as a frontend. (IBM was the other major company that had their own C++ parser for a longer time)
- greglindahl 10y agoBack when Path64 was highly funded, it was a nasty treadmill keeping up with g++'s ABI -- it changes every point release.
- MereInterest 10y agoBit of a side-note, but I would disagree about ROOT/CINT ever being a C++ compiler. It was an interpreter for a language that looked somewhat related to C++, if you squint quite a bit. * All variables were hoisted up to function scope. This meant that you couldn't use "int i" in one loop, and "unsigned int i" in the next. This also caused destructors to be incorrectly delayed until the end of the function call. * Use of templates required pre-compiled dictionaries for each type the template might be instantiated for. Any templates occurring in interpreted code would be silently ignored. * Incomplete standard library implementation. std::abs(long) is missing, for example. * const is silently ignored. Not entirely relevant to the current discussion, but good heavens, I am glad that monstrosity is gone.
- jdright 10y agoI prefer external caching/distributed solutions like ccache/sccache/sndbs than these private forks of clang. Less risky and up-to-date.
- thechao 10y agoOne thing that always confused me about ccache was that it doesn't cache lib generation and executable generation. I know that the authors have insisted (until they were blue in the face) that supporting lib/exe caching would require rewriting ccache... I just don't understand why. Once you know about about -frandom=0, and you've removed all aspects of non-determinisim (__TIME__ & co.), then all that's left is the moral equivalent of `dwarfdump -u <exe>` for each compiler, and you're good-to-go for deterministic caching.
- JoshTriplett 10y agoThe architecture of ccache maps preprocessed sources to object files; it uses the compiler to preprocess the source, and it hashes the result, knowing that nothing other than the compiler, command line, and preprocessed source determines the output. Linking involves far more complexity, with the input files harder to determine. There's no equivalent of -E or -fdirectives-only for linking. A ccache for linking would have to identify and hash all library, object file, and linker script inputs, including those pulled in indirectly by linker scripts, in addition to the toolchain, the command line, and any linker plugins. It's absolutely possible, and I'd love to see someone do so, but it seems significantly harder than caching compilation. You'd also want to time the result, and figure out how long the reading and hashing takes compared to linking. ccache misses take only slightly longer than a normal compilation; link-cache misses may take much longer than normal. On top of that, unlike a compilation cache that seems very likely to hit on the 99% of files not changed in a build, a linker cache would only hit when absolutely nothing has changed in the entire build. It might help for a project that links numerous tiny libraries or binaries (which seems relatively uncommon), but for a project that primarily builds a single library or binary, it'd only help if you rebuild entirely identical sources twice. (It might, however, speed up Linux kernel builds if you've only changed the code for a couple of modules and not anything in the core kernel.)
- DannyBee 10y agoSo, while neat, pretty much all of this would be solved by C++ modules and precompiled modules. (and in fact, is, based on what i've seen. But i still hope these guys get to market and make some money before that takes over the world, because i know how hard it is to do what they are doing :P)
- ndesaulniers 10y agoIs google3 converted yet? ;)
- DannyBee 10y agoNot fully, but it's definitely well on the way :)
- hokkos 10y agoFrom here : https://www.zapcc.com/faq/ https://www.zapcc.com/faq/ How will you license Zapcc? Zapcc will be available under a commercial license from Ceemple Software Ltd.
- winter_blue 10y agoIf Clang had used a GPL-like license, Zapcc would have been forced to share all their modifications to Clang with the whole world, and we would've all benefited from it -- and maybe the optimizations would even have been merged back into the mainline of Clang. But as it stands now, this is a closed source product, that you to buy: https://www.zapcc.com/buy-zapcc/ https://www.zapcc.com/buy-zapcc/
- ndesaulniers 10y agoor it may never have been built in the first place
- pjmlp 10y agoAs I mentioned in several other threads, in around 10 years time, the GPL will be sorely missed. The only thing left will be the Linux kernel and a few major projects like Emacs. The circle will be complete and we will be back to the 90's with freeware like licenses.
- qwertyuiop924 10y agoI'm not sure I agree. Maybe for some software, but I wouldn't even think about using a programming language without at least one quality open-source implementation, and I think many developers would agree.
- pjmlp 10y agoMost developers use whatever the company IT department and managers decide they should use. Not everyone has the luxury to switch jobs all the time to use the programming languages they want to use.
- qwertyuiop924 10y agoFair 'nuff. But let me ask you this: will those managers ask them to use a language without a high-quality open-source implementation? And if you look at the most popular languages out there (and even many of the fringe ones) the answer is probably not. Unless they're writing APL.
- halayli 10y agoWhy not use clang's PCH (precompiled headers) feature? http://clang.llvm.org/docs/UsersManual.html#precompiled-headers http://clang.llvm.org/docs/UsersManual.html#precompiled-head...
- ape4 10y agoThis was my question too. Zapcc's faq says: Precompiled headers requires building your project to the exact precompiled headers rules. Most projects do not bother with using precompiled headers. Zapcc works within your existing build. Precompiled headers are currently ignored by Zapcc.
- wichtounet 10y agoUnfortunately, it's quite inconvenient to use precompiled, there are a lot of limitations in each compiler. For instance, only the first header include a source file can be precompiled and other things like that, this is a more general approach. But PCH can bring a really good speedup too and are free ;)
- midnightclubbed 10y agoCurious as to how much faster this makes standard workflows where you are re-compiling only a few files and the linker is typically the bottleneck. I use incredibuild in my day-job it's a great help when doing full re-compiles or changing a pervasive header but offers no help on smaller builds where it doesn't parallelize the link. Zappcc doesn't look to do anything with the linker either.
- mrich 10y agoYou can try gold with parallel and/or incremental linking (although incremental linking didn't work on a large library where I would've needed it most)
- trymas 10y agonon open source, based on clang, but faster? in the perfect world I would like that everyone who uses clang would freely benefit from this improvement. should some big and good corporations just buy out those guys?
- greglindahl 10y agoThe entire point of using a BSD/MIT-style license is that it gives "freedom" to a different set of people than the GPL does. In this case, why is it not perfect for someone to invest money building a commercial product on top of clang? Isn't it just fine that they want to make a lot of money?
- pjmlp 10y agoThat is the GPL world, the BSD world is all almost making this kind of work possible. So don't worship MIT/BSD and complain later about it when companies prevent you to get the code.
- mrich 10y agoI would love to see a C++ compiler implement multi-core optimization and code generation for template instantiations. I feel this can be a big win for cases where you instantiate a template n times and they are basically all independent from each other.
- DannyBee 10y agoclang/llvm are working on it. For codegen anyway. It's not clear that it will help with template instantiation, because it's fairly hard to parallelize. Certainly, possible, but very hard to do "optimally" (IE by sharing work instead of duplicating it). Given any initial work is likely to have to do duplicate work per thread, this usually cuts into your speedup quite a lot. Codegen, on the other hand, is pretty much fully parallelizable. This is the whole reason thinlto exists.
- faragon 10y agoTL;DR: not a new compiler, but one based on clang plus some tuning/optimizations.