Thursday, February 5, 2015

Re: taglist() performance

On 2015-02-05, CodieCodemonkey wrote:
> Christian Brabandt wrote
> > Could you provide a) the tagfile and b) the two functions to search for
> > a specific tag
> > and c) the name of the tag, that makes it so slow?
> >
> > I'd like to check, what makes taglist() so slow.
>
> Hi Christian,
>
> I'm glad you're taking this on. I've attached the script
> <http://vim.1045645.n5.nabble.com/file/n5723929/inherits.vim> . It has two
> main functions, Inherits() and InheritsOld(). InheritsOld() uses taglist(),
> Inherits() uses readfile() and parses the tag records itself via a helper
> function ParseCtagsRec().
>
> The best way to switch between them is to change the command, also named
> Inherits, at the bottom of the file to call either Inherits() or
> InheritsOld().
>
> Inherits take the name of a class (you can also use a regex, but lets not
> complicate things) and finds all classes that inherit from the class
> directly. For our purposes it doesn't really matter if it's a real class,
> it will search the entire tags file anyway so that you'll see the problem
> whether or not the command succeeds. However, in order to have any chance
> of success, the tags file must be an Exuberant Ctags file build with 'i' in
> the --fields argument. I use --fields=ilmS.
>
> Unfortunately I cannot give you the tags file without getting special
> permission for security policy reasons. But I think that even a moderate
> tags file like I suppose would be generated from the VIM source code would
> show the problem. If not, we can discuss other possibilities.

My vim source tags file has only 23 thousand tags. I use taglist()
daily on tags files of typically 1.3 million tags and the search
time is not noticeable--less than a second. BUT, the search
patterns are anchored to the beginning of the tag and the tags files
are sorted for a binary search. A linear search takes considerably
longer.

Here's an example of part of a command using taglist.

taglist('^'.expand('<cfile>').'$')

Without the '^' and '$' anchors, the evaluation takes several
seconds.

I also have a bash-completion function that uses ex and the
taglist() function to perform tab-completion of tag names on the
command line. (It gives me tab-completion of tag names in 'vim -t
<tag>' commands.) It's pretty snappy, which is surprising given
that it runs ex for each completion request.

I certainly don't see a performance problem with taglist() on huge
tags files. The problem you're seeing is probably in your
application of taglist().

Regards,
Gary

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: