Subject: Re: bug#23223: 25.0.92; Can xref-find-references be sped up?

From: Eli Zaretskii <[email-masked]>
Date: Tue, 12 Apr 2016 18:50:49 +0300

> Cc: [email-masked]
> From: Dmitry Gutov <[email-masked]>
> Date: Tue, 12 Apr 2016 02:25:54 +0300
> 
> > Unfortunately, it seems to miss matches: out of 1127 matches of
> > current_buffer with the original version, the new one only shows 963.
> > It sounds like some conditions on what exactly is a symbol need
> > adjustment,
> 
> Ooh, that's a great catch, thanks! Turns out, auto-mode-alist wasn't 
> getting applied because buffer-file-name wasn't set. Fixing that added 
> ~25% performance hit, so I also added xref--find-buffer-visiting to 
> cache the expensive lookup mentioned previously. See the new patch attached.
> 
> That seems to about exhaust the optimization opportunity here.

LGTM, please push.

Btw, I noticed another strange thing, but I was only able to reproduce
it with the current version, before your patch: the set of results
returned by xref-find-references, when it uses IDUtils, is not
entirely repeatable.  Sometimes, a few matches, sometimes a few dozen
of them, are missing.  I have no idea why; the lid command
consistently returns the same number of lines each time I invoke it.

> >   semantic-symref-derive-find-filepatterns: Customize ‘semantic-symref-filepattern-alist’ for lisp-interaction-mode
> >
> > unless I invoke xref-find-references from a buffer in C mode.
> 
> ...or the current major mode is one of the currently supported ones, via 
> the above variable.
> 
> > Curiously, this doesn't happen when there's an ID file and IDutils is
> > invoked.  Is this expected?
> 
> Yes. semantic-symref-filepattern-alist is defined in and used by 
> semantic/symref/grep.el. We can add (lisp-interaction-mode "*.el") to it.

I think we should do that, yes.

Thanks.