[cfe-dev] Announcing "clang-ctags"

David Röthlisberger david at rothlis.net
Tue Jul 31 00:34:43 PDT 2012

On 26 Jul 2012, at 16:37, Douglas Gregor wrote:
> On Jul 26, 2012, at 2:11 AM, David Röthlisberger <david at rothlis.net> wrote:
>> When I run clang-ctags over clang/lib/Analysis/AnalysisDeclContext.cpp
>> it reports† that the call to clang_parseTranslationUnit takes 6.4s.
>> Giving the same compilation command directly to clang++ takes 1.4s.
> Perhaps it's building a precompiled preamble, which is only worthwhile
> if you're going to reparse the same file many times. Try setting the
> environment variable LIBCLANG_TIMING=1 to see if anything odd shows up
> in the internal timing log; if not, please grab a profile!

Oh dear... this is terribly embarrasing, but I was comparing a debug
build of libclang against a release build of clang++.

It's good news for clang-ctags, though. With a release build,
clang-ctags indexes clang/lib/**/*.[ch]* in 4.3 minutes (instead of the
37 minutes I had previously reported).

clang's parsing accounts for 72% of this time; of the remaining 28%,
maybe the overhead of python is more significant than I expected (but
I'm not going to re-implement in C++ to find out). :-)

As Sean Silva pointed out, run time could be further improved with
parallelization: If clang-ctags supported multiple processes writing to
the same tag file, one could use GNU parallel instead of xargs:

    find lib -name '*.[ch]*' | parallel clang-ctags --append ...


More information about the cfe-dev mailing list