help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why code completion using CEDET in Emacs so slow?


From: David Engster
Subject: Re: Why code completion using CEDET in Emacs so slow?
Date: Thu, 13 Oct 2011 18:02:21 +0200
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.90 (darwin)

Judeau writes:
> David Engster wrote:
>> 
>> I'm afraid I can't see any code there.
>> 
>> -David
>> 
> As I said, if you include new file every time, it will have a brief delay
> when looking up members. If you try to delete .semanticdb (back up it
> first), and/or try code completion for every new file included. It always
> takes a brief delay depends on how large the looking up scope. For example:
>
> (local-set-key "\C-c>" 'semantic-complete-analyze-inline)
>
> When I try to look up symbols in a namespace (such as std:: or boost::) with
> semantic-complete-analyze-inline using C-c > , or when looking up class
> members in map, set, boost types..., I always have to wait for a while.
> Well, I guess I will have to accept this and not to rely to much on code
> completion then, since it would be slower than I type it manually if the
> looking up scope is greater medium (for my own classes placed locally in my
> project, it is enough). Still, using autocomplete.el works better for me.

Looking up everything in std:: will surely take some time. I mean, that
namespace is huge, with thousands of members. I believe you that
Eclipse/KDevelop do this much quicker, and while there may be some
potential for optimization in CEDET, it is really pushing what you can
still do in Emacs Lisp. We will probably end up coding some of the
database and parsing stuff in C, but there's more urgent stuff to do at
the moment.

> I don't know is there a way to update .semanticdb? It seems to me after the
> first time scan, if I update the file (such as add more function
> declarations), it won't rescan and save to update.

Yes, that's what CEDET does. It will update semanticdb automatically if
needed, i.e., if you #include new headers or change one of the headers.

Here's a little benchmark I did, using this:

--------------------
/* (benchmark-run
     (progn
       (search-forward "boost::asio::")
       (semantic-analyze-possible-completions 
(semantic-analyze-current-context))))
*/

#include <iostream>
#include <boost/asio.hpp>

int main()
{
   boost::asio::
}
======================

Just go behind the last bracket of the comment and hit C-x C-e to time
this call. If you delete everything in ~/.semanticdb, this will parse
lots of STL and boost stuff and takes about 2:20m on my
machine. Afterwards, this should take about 0.15 seconds (you have to
enter a newline in the main function or something, otherwise it will be
much quicker due to caching).

If you restart Emacs, CEDET will have to read the cache-files first,
which takes about 3-4 seconds on my machine. Afterwards, it will again
be around 0.15 seconds.

If you try to complete only "boost::" or "std::", it will be much slower
because those namespaces simply have lots and lots of members. If you
just want to safe some keystrokes and do not depend on actual "smart"
completions, you might be happier with tools like etags/ctags or GNU
global, and only use CEDET when you actually need context-aware
completions.

-David




reply via email to

[Prev in Thread] Current Thread [Next in Thread]