Subject: Re: bug#48841: fido-mode is slower than ido-mode with similar settings

From: João Távora <[email-masked]>
Date: Sun, 06 Jun 2021 00:20:28 +0100

Dmitry Gutov <[email-masked]> writes:

> On 05.06.2021 12:35, João Távora wrote:
>> Thanks for the report.  Before I try reproducing, can you try with
>> fido-vertical-mode and tell us it if that changes anything?  I think I
>> remember that skipping some suffix-calculation logic saved on a few
>> traversals of the big list of symbol completions.
>
> Why, yes it is. fido-vertical-mode is definitely snappier with such
> settings.
>
> Maybe still not on the level of ido-mode, but at least halfway there,
> compared to the "horizontal" version.

Yes, that is also my assessment after trying your recipe.  fido-mode +
fido-vertical-mode is not quite as snappy as ido-ubiquitous-mode, but
decently close.

My bet is that the remaining lag is due to sorting.  In a dumb but
illustrative example, when given the pattern 'fmcro' flex-enabled
ido-mode pops 'flymake--backend-state-p--cmacro' to the top, while fido
mode selects the much more reasonable 'defmacro'.

Now, what I called here the "suffix-calculation logic" is what I also
called the "[mplete] dance" back in the emacs-devel thread.  Truth is,
it's always annoyed me in icomplete partially because I don't understand
what it does exactly and how it is supposed to help me.  I suppose
Stefan knows best here.  Regardless of its use, it seems to require
another try-completion call in all the filtered candidates (which might
be very big) so that's probably where the extra lag comes from.

So, in summary, to speed this up for whomever is _not_ using
fido-vertical-mode, either we manage to speed up that part of
icomplete.el, or we get rid of it completely (at least for fido-mode).
For reference, it lives in an "else" branch of one of the "if"s in
icomplete-completions.

João