[cfe-dev] Clang indexing library performance

Alexander Bolodurin alexander.bolodurin at gmail.com
Sun Oct 2 02:06:35 PDT 2011


On 02/10/2011, at 10:34 AM, Tobias Grosser wrote:

> On 10/01/2011 10:34 AM, Alexander Bolodurin wrote:
>> I was playing with libclang-based indexing and clang_complete plugin for Vim.
>> Having found completion responsiveness a bit lacking, I decided to track down whether it's plugin's fault.
>> 
>> To put the indexer under stress, I've made up an artificial test with the biggest and baddest C++ headers:
>> 
>> ---------------8<---------------
>> #include<boost/asio.hpp>
>> #include<boost/regex.hpp>
>> #include<boost/thread.hpp>
>> #include<boost/spirit.hpp>
>> #include<boost/signals2.hpp>
>> boost::
>> ---------------8<---------------
>> 
>> ...and the following minimal test program using Python bindings:
>> 
>> ---------------8<---------------
>> from clang import cindex
> 
>       PrecompiledPreamble = 0x04
>       CacheCompletionResults = 0x08
>       CXXPrecompiledPreamble = 0x10
>       flags = PrecompiledPreamble |
>               CXXPrecompiledPreamble |
>               CacheCompletionResults
> > def clock(f):
>>     import time
>>     def wrapf(*args,**kw):
>>         start = time.time()
>>         f(*args,**kw)
>>         end = time.time()
>>         print f.func_name, end - start
>>     return wrapf
> 
> 
> 
>> 
>> fname='...path to file...'
>> idx=cindex.Index.create()
> 
> 
>> @clock
>> def parse():
>>     global tu
>>     opts = ['-I/opt/local/include'] # MacPorts Boost path
>>     tu=idx.parse(fname,opts)
> 
>       tu=idx.parse(fname,opts, [], flags)
> 
> This should give you a lot better results. You need to define these flags by yourself, as they are not yet available in the official python bindings.
> 
>> @clock
>> def complete():
>>     c = tu.codeComplete(fname,6,8)
> 
> Maybe using this may help even further:
>       c = tu.codeComplete(fname,6,8, flags)
> 
>> 
>> parse()
>> for i in range(4):
>>     complete()
>> ---------------8<---------------
>> 
>> This is the timing I get on a Macbook Pro:
>> 
>> parse 3.96061992645
>> complete 3.31106615067
>> complete 3.17438578606
>> complete 3.37997102737
>> complete 3.16793084145
> 
> Can you send me your new results, either only with the parse() change, and then with both the parse() and the complete() change.
> 
> Thanks and cheers
> Tobi

parse only:

parse 3.55141305923
complete 2.60280609131
complete 2.53132414818
complete 2.54255604744
complete 2.50854682922

parse + complete:

parse 3.58968901634
complete 2.62985301018
complete 2.55927109718
complete 2.54651212692
complete 2.55211901665

I have also tried to eliminate the middlemen completely and use C interface directly using this tool: https://gist.github.com/758615 from this clang_complete bug report: https://github.com/Rip-Rip/clang_complete/issues/17 which you have already read, as I can see.

I still get about 2.5s completion time even when setting parse and completion flags to clang_defaultEditingTranslationUnitOptions() and clang_defaultCodeCompleteOptions() respectively.



More information about the cfe-dev mailing list