Sunday, February 8, 2015

Re: taglist() performance

On 2015-02-06, Christian Brabandt wrote:
> Hi CodieCodemonkey!
>
> On Do, 05 Feb 2015, 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.
>
> I see what you mean. Please take the following with a grain of salt,
> because I haven't used the tag feature of Vim yet.
>
> For me, it looks like you are using taglist() not as intended. Since you
> are looking for inherited field, you have the taglist() function
> regexp-search each item just to then throw away all items that do not
> have the 'inherits' flag.
>
> That does sound like the naive readfile approach could be faster indeed.
>
> I do not know what kind of fields could be there in a tags field, but
> perhaps we can make taglist() smarter and have it search for a specific
> field (like your inherits field), perhaps as second argument. What do
> you guys think?

Granted I have not looked closely at CodieCodemonkey's specific
problem, but I don't think a speed issue, especially a gross speed
issue, is going to be improved by adding an argument to the search
function. The solutions to such issues usually involve
restructuring the data to make it fast to search. A linear search
is not going to cut it. I could see even reordering the fields in
the tags file to create a second tags file with the inherited field
as the key, then switching between the tags files as needed to do a
binary search on the desired field.

Another approach is to combine two key fields into one, by
concatenating them, so that you can do a binary search on the two
keys together.

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: