[cfe-dev] Clang-based indexer and code navigator

Ryan Prichard ryan.prichard at gmail.com
Sun Mar 10 13:53:45 PDT 2013


On 03/10/2013 05:25 AM, ramneek wrote:
> Looks great from the demo images. Haven't tried it though.
> Do i need to reindex everything in case if i make a minor change in a file or does it track dependencies and patches the index appropriately?

There is an --incremental option to sw-clang-indexer.  It doesn't patch 
the index, but it avoids reindexing every translation unit when the 
project is reindexed.  With that option, the indexer saves an index file 
for each translation unit and avoids reindexing a translation unit if 
none of its source files have changed.  The indexer still merges all of 
the translation units' indices into a single index.  On my machine, for 
LLVM+Clang, --incremental reduces the reindexing time from about 5.5 
minutes to 16 seconds.  It has a few limitations:

  - It doesn't keep track of compiler options, so if the options change, 
it can incorrectly reuse a translation unit's index file.

  - Keeping around index files for each translation unit uses much more 
disk space.  While the index for LLVM+Clang is about 160MB, the 
intermediate index files total 2.8GB.  I believe the difference in sizes 
is due to header files.  (The per-translation-unit indices are already 
partitioned by source file to reduce merge time; placing each partition 
into a separate file could theoretically reduce the disk usage.)

  - If there are somehow multiple translation units in 
compile_commands.json with the same object file output, then the indexer 
may behave unpredictably, because it may spawn a subprocess that 
overwrites an index file while simultaneously reading the index file. 
This should be easy to fix.

-Ryan



More information about the cfe-dev mailing list