Subject: Re: bug#75922: CPU hogs with pgtk

From: Eli Zaretskii <[email-masked]>
Date: Wed, 29 Jan 2025 15:06:50 +0200

> From: Nicolas Sarlin <[email-masked]>
> Date: Wed, 29 Jan 2025 12:05:16 +0100
> 
> I'm using lsp-mode with corfu on the emacs-30 branch, and I get extremely
> frequent CPU hogs (CPU runs at 100% for a few seconds) while typing
> code. I report this as an emacs bug because it seems to only occurs when
> emacs is compiled with pgtk. If I rebuild emacs with "make bootstrap
> configure=default" the bug disapears.
> 
> Here is a profiler record:
>        11152  91% - corfu--post-command
>        11152  91%  - corfu--exhibit
>        11043  90%   - corfu--update
>        10891  88%    - corfu--recompute
>        10891  88%     - corfu--filter-completions
>        10891  88%      - completion-all-completions
>        10891  88%       - completion--nth-completion
>        10891  88%        - seq-some
>        10891  88%         - seq-do
>        10891  88%          - mapc
>        10891  88%           - #<byte-code-function AC1>
>        10891  88%            - #<byte-code-function AD0>
>        10891  88%             - lsp-completion-passthrough-all-completions
>        10891  88%              - #<byte-code-function 4B5>
>        10891  88%               - #<byte-code-function 4DE>
>        10888  88%                - lsp-request-while-no-input
>        10888  88%                 - sit-for

The profile says most of the time is spent in sit-for called from
lsp-request-while-no-input.  First, sit-for is not supposed to consume
CPU, because it's a waiting function.  Are you sure this profile was
taken when Emacs was hogging CPU?

And second, lsp-mode is not part of Emacs, so if indeed the above is a
profile representative of high CPU load, I suggest to report this to
the developers of lsp-mode first, even though the problem appears only
in the PGTK build.

Thanks.