unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Sean Whitton <spwhitton@spwhitton.name>
To: Eli Zaretskii <eliz@gnu.org>
Cc: "João Távora" <joaotavora@gmail.com>,
	72826@debbugs.gnu.org, "Juri Linkov" <juri@linkov.net>
Subject: bug#72826: 30.0.90; icomplete-in-buffer becomes unusably slow in large Eshell
Date: Thu, 03 Oct 2024 22:28:49 +0800	[thread overview]
Message-ID: <8734ldxntq.fsf@melete.silentflame.com> (raw)
In-Reply-To: <86r0aai1an.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 27 Aug 2024 15:43:28 +0300")

[CCing Juri and João who have worked on this.]

Hello,

On Tue 27 Aug 2024 at 03:43pm +03, Eli Zaretskii wrote:

>> From: Sean Whitton <spwhitton@spwhitton.name>
>> Date: Tue, 27 Aug 2024 15:26:03 +0800
>>
>> Hello,
>>
>> 1. emacs -q
>> 2. (setopt icomplete-in-buffer t)
>> 3. M-x icomplete-mode
>> 4. M-x eshell
>> 5. cat very_large_file.txt # I'm using an 80k line log file
>> 6. ls <TAB>
>> 7. Try to use C-, and C-. to cycle through the completions.
>>   => Emacs basically locks up.
>>
>> The buffer being large should surely not affect icomplete-in-buffer in
>> this way.  It shouldn't need to care about all the rest of the buffer.
>
> Strangely enough, I can only reproduce this on GNU/Linux, but not on
> MS-Windows.
>
> Profiling seems to indicate most of the time is spent in
> completion-all-sorted-completions and in GC.

I just tried profiling it myself:

       38958  93% - icomplete-post-command-hook
       38958  93%  - icomplete-exhibit
       38819  93%   - icomplete-completions
       38749  92%      string-width
          43   0%    + icomplete--sorted-completions
          27   0%      buffer-string
         139   0%   + sit-for

I think the culprit is probably the evaulation of
(string-width (buffer-string)) in icomplete-completions.
That'll always be fast for Icomplete in the minibuffer, but for
icomplete-in-buffer it depends on the size of the buffer.

I think this code is trying to determine how much space is taken up by
the minibuffer prompt and the user's input typed so far.  So, we can
probably find a cheaper way to compute the corresponding value for
icomplete-in-buffer.

-- 
Sean Whitton





  reply	other threads:[~2024-10-03 14:28 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-27  7:26 bug#72826: 30.0.90; icomplete-in-buffer becomes unusably slow in large Eshell Sean Whitton
2024-08-27 12:43 ` Eli Zaretskii
2024-10-03 14:28   ` Sean Whitton [this message]
2024-10-03 15:16     ` Eli Zaretskii
2024-10-04  0:20       ` Sean Whitton
2024-10-04  6:11         ` Eli Zaretskii
2024-10-04  9:02           ` Sean Whitton
2024-10-04 10:53             ` Eli Zaretskii
2024-10-04 11:02               ` Sean Whitton
2024-10-04 11:52                 ` Eli Zaretskii
2024-10-04 14:09                   ` Sean Whitton
2024-10-04 14:33                     ` Eli Zaretskii
2024-10-05  0:21                       ` Sean Whitton
2024-10-05  7:16                         ` Eli Zaretskii
2024-10-05  7:44                           ` Sean Whitton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8734ldxntq.fsf@melete.silentflame.com \
    --to=spwhitton@spwhitton.name \
    --cc=72826@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=joaotavora@gmail.com \
    --cc=juri@linkov.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).