On Sat, 13 May 2006 at 9:46am, Yegappan Lakshmanan wrote:
> Hi Hari,
>
> On 5/12/06, Hari Krishna Dara <[EMAIL PROTECTED]> wrote:
> >
> > I am finding that the new taglist() function performans much slower than
> > the :tag command for the same pattern. I have a couple of huge tag
> > files in 'tags' and doing something like:
> >
> > :ta /.*t<Tab>
> >
> > will start giving me the matches with in a second or two (at the most),
> > but calling taglist('t') will take a long time (didn't finish after
> > waiting for a couple of minutes). I would imagine both :tag command and
> > taglist() using the same tag lookup code, so probably it is the
> > generation of list of dictionary entries that is very inefficient.
> >
>
> When you use the ":tag <pattern>" command, only the next few
> matching tags are retrieved from the tags file. OTOH, the taglist()
> function retrieves all the matching tag names from the tags file.
>
> The dictionary creation is not slowing down the taglist() function.
> Searching the entire tags file for all the matching tag names is
> slowing down the taglist() function.
>
> > To test this theory, in a crude way, I tried:
> >
> > :echo len(taglist('z'))
> >
> > And I got 5427 as the response in a couple of seconds, so the match for
> > 't' must have been a lot more, resulting in a lot more time taken.
> >
> > On a smaller tags file of containing only about 40,000 tags (about 4mb),
> > for pattern 't', I got a match of 34361 entries, but it took about
> > 10seconds to complete, but if I use the :tag command the response is
> > almost instantaneous.
> >
> > On further study, I realized that the :tag command with pattern comes
> > back with matches very fast, but the same with :ts is very slow, so
> > something like:
> >
> > :ts /.*t<CR>
> >
> > will take a long time to come up with the list. I don't know if this is
> >
>
> The tselect, tjump, tlast and ltag commands also load all the matching
> tags from the tags file. These commands are similar to the taglist()
> function, so these commands also will take similar amount of time
> to get all the matching tag names from the tags file.
>
> >
> > because Vim is trying to create a buffer containing all the entries for
> > presentation purposes, for the same reasons taglist() is also slow. In
> > any case, if creating such a huge list of dictionary items is going to
> > be so time consuming (and memory intensive), how about supporting a
> > second argument for passing an index? In this case, the script can
> > restrict it to always say, only the first 100 entries (or whatever is
> > configured by the user). I would assume that there are optimizations for
> > fast lookup of the same pattern (the way :ts command performs in
> > subsequent invocations), if you have to call the function 100 times.
> >
>
> We can modify the taglist() function to take a starting index and the
> number of tags to return:
>
> taglist(<pattern>, <start_idx>, <count>)
>
> If you want all the matching tags, then you can use
>
> taglist(<pattern>, 0, 9999999)
I think this will be useful in some cases to reduce the time.
>
> Note that it will not be possible to get a list of all the matching tags
> and the number of matching tags without parsing the entire tags file.
>
> - Yegappan
>
I am not sure if the bottleneck is entirely due to scanning the whole
tags file. I have run a few more tests, looking for patterns such as,
'^t', '^.t', '^..t' and so on, and they all return result immediately
(actually having 6 dots took one second). Assuming these scan a
significant portion of the tag file (especially when there are several
dots), I think the problem is at least partly due to the pattern
matching too.
--
Thanks,
Hari
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com