GNU bug report logs - #76964
31.0.50; completion-preview-mode uses a lot of CPU

Previous Next

Package: emacs;

Reported by: Geza Herman <geza.herman <at> gmail.com>

Date: Tue, 11 Mar 2025 23:09:02 UTC

Severity: normal

Found in version 31.0.50

Fixed in version 30.2

Done: Eshel Yaron <me <at> eshelyaron.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Geza Herman <geza.herman <at> gmail.com>
To: Eshel Yaron <me <at> eshelyaron.com>
Cc: 76964 <at> debbugs.gnu.org
Subject: bug#76964: 31.0.50; completion-preview-mode uses a lot of CPU
Date: Sun, 16 Mar 2025 16:49:04 +0100
Hi Eshel,

Thanks, the new version seems to work correctly!

(Sorry, I was meant to create a patch, for before that I asked a 
question in emacs-devel about the behavior of define-minor-mode, and I 
was waiting for a response - got none so far)

Geza


On 3/16/25 10:17 AM, Eshel Yaron wrote:
> Eshel Yaron <me <at> eshelyaron.com> writes:
>
>> Geza Herman <geza.herman <at> gmail.com> writes:
>>
>>> When moving around a buffer with completion-preview-mode enabled, CPU
>>> usage becomes very high.
>>>
>>> Profiling the problem reveals that with completion-preview-mode,
>>> redisplay_internal takes much more CPU.
>>>
>>> The problem is in completion-preview--post-command, which calls
>>> (completion-preview-active-mode -1). For some reason, even though this
>>> should be a nop when just moving around a buffer, it forces emacs to
>>> do some more thorough redisplay. If I change this code to "(when
>>> completion-preview-active-mode (completion-preview-active-mode -1))",
>>> the problem goes away.
>>>
>>> I think the problem is inside the define-minor-mode macro, because if
>>> I change completion-preview-active-mode to an empty minor mode
>>> definition:
>>>
>>> (define-minor-mode completion-preview-active-mode
>>>    "Mode for when the completion preview is shown."
>>>    :interactive nil)
>>>
>>> the problem still happens. Note: looking inside the define-minor-mode
>>> macro, I see a (force-mode-line-update) call. I'm not sure it's
>>> related, but it has a chance that it is.
>> Thanks for investigating and reporting.  I think that conditioning the
>> (completion-preview-active-mode -1) in completion-preview--post-command
>> as you suggest makes sense.  Would you like to provide a simple patch
>> with that change?
> I've now pushed such a change along with some additional commentary to
> the emacs-30 branch in commit b6b4a080a3a.  It should make its way to
> master soon enough.  Could you please check whether that improves
> performance for you?
>
>
> Thanks,
>
> Eshel
>





This bug report was last modified 126 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.