Subject: Re: bug#23377: 25.0.93; Completion is extremely slow for insert-char

From: Eli Zaretskii <[email-masked]>
Date: Tue, 26 Apr 2016 09:21:42 +0300

> From: Paul Eggert <[email-masked]>
> Date: Mon, 25 Apr 2016 21:10:50 -0700
> Cc: "N. Jackson" <[email-masked]>, [email-masked]
> 
> Drew Adams wrote:
> > if the main reason to disable it is for performance in
> > an extreme use case (C-x 8 RET TAB)
> 
> It's not that extreme. It's natural for a user to get the whole list and then
> use C-s to find the desired character.
> 
> Also, there's a problem even in less-"extreme" cases. I just now tried 'C-x 8
> RET B TAB', which lists every character whose name starts with "B", and this
> took about 18 s on my platform, whereas with Emacs 24.5 it is almost
> instantaneous.  18 s is waayyy to slow for this sort of user interaction.

It takes less than 2 sec here.  The original recipe takes 11 sec.
This is a 32-bit optimized build with wide ints, so a build without
that option should be even faster.  IOW, on a reasonably modern
platform and the default build options, the feature performs with
reasonable speed.  E.g., this:

  C-x C-f /foo/bar/ TAB TAB

takes 2.5 sec here for a /foo/bar/ with more than 3600 files.  So it's
not like we don't see slow completion sometimes.

> Stefan's suggestion of a config var sounds good. It's a bit late to be adding
> features to the emacs-25 branch, though, so I'm inclined to revert in emacs-25
> (with a "do not merge to master") and add a customizable var in master.

No, please don't revert; it's too late for that.  Adding an option is
okay, and it should be ON by default, to keep the behavior we had in
Emacs 25, including all the pretests, until now.  A NEWS entry about
this would also be nice.

Btw, one way to make this much faster is install the fonts for the
characters that display as boxes with hex codepoints.  Emacs only
looks up fonts for characters it needs to display, and the latest
addition of Unicode added quite a few characters shown in the first
screen of *Completion*, which I suppose have no fonts on your systems
(I, too, don't have them).  In addition, Emacs 25 shows a larger
window for the *Completions* buffer by default, which also contributes
to the time it takes.

Thanks.