[cfe-dev] Improving Clang Parse Performance

Manuel Klimek klimek at google.com
Mon Jun 11 12:29:42 PDT 2012

On Mon, Jun 11, 2012 at 8:13 PM, James Dennett <james.dennett at gmail.com>wrote:

> On Mon, Jun 11, 2012 at 10:16 AM, sccllghn <sccllghn at yahoo.com> wrote:
> > I am trying to use Clang for parsing some C++ programs and have had good
> > success. The problem is performance. I can parse about 400,000 lines of C
> > code scattered in 400 files in about 25 minutes on a really fast machine.
> That is odd.  Clang's parser is pretty fast, as C++ parsers go.  Have
> you tried using an optimized build of Clang to compiler your 400
> files?  400,000 lines isn't much code, and 25 minutes is a long time.

If it's single threaded that is actually in line with numbers I have run
(3.75 seconds per TU on average). I also think I saw some regressions here
over the past year, but we'll need to investigate more. My numbers are
mostly C++ code though, so that might be apples and oranges.


> > I
> > think that this is not very good, considering that I am doing a lot less
> > than a compiler. Am I mistaken in my expectations?
> A rule of thumb is that, when not optimizing, lexing/parsing takes
> about half of the total compiler time.  If you do no work beyond
> parsing you might be able to be twice as fast as clang++ when it's
> compiling.
> > My sense is that to get a real bump in performance, I need to use
> > pre-compiled header files, because the vast majority of parsing is being
> > done over and over.
> My guess is that something is strange in your setup, because I'd
> expect that Clang is faster than that.  How long does it take to
> *compile* your 400k LOC?
> -- James
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120611/f83df40d/attachment.html>

More information about the cfe-dev mailing list