GNU bug report logs - #75922
CPU hogs with pgtk

Previous Next

Package: emacs;

Reported by: Nicolas Sarlin <nico.sarlin <at> gmail.com>

Date: Wed, 29 Jan 2025 11:16:02 UTC

Severity: normal

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #14 received at 75922 <at> debbugs.gnu.org (full text, mbox):

From: Nicolas Sarlin <nico.sarlin <at> gmail.com>
To: Pip Cet <pipcet <at> protonmail.com>
Cc: 75922 <at> debbugs.gnu.org
Subject: Re: bug#75922: CPU hogs with pgtk
Date: Wed, 29 Jan 2025 16:28:01 +0100
Thanks for your answer!

On Wed, 29 Jan 2025 at 13:41, Pip Cet <pipcet <at> protonmail.com> wrote:
>
> "Nicolas Sarlin" <nico.sarlin <at> gmail.com> writes:
>
> Thanks for the report! Debug suggestions below, but if you cannot or
> would prefer not to any or all of that, that's perfectly okay, too!
>
> > 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.
>
> So this happens on the pgtk branch, but behavior on the master branch is
> not noticeably slower than you'd expect?

This happens on the emacs-30 branch with configure=--with-pgtk

> > I report this as an emacs bug because it seems to only occurs when
> > emacs is compiled with pgtk.
>
> Are you running this on a Wayland setup, or on X (ignoring the popup)?

I am running this on Wayland

>
>
> > If I rebuild emacs with "make bootstrap configure=default" the bug
> > disapears.
>
> Entirely?

Yes, I see no slowdown at all without pgtk.
>
>
> > 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
> >           82   0%                  + redisplay_internal (C function)
> >           18   0%                  + #<byte-code-function 31C>
> >            3   0%                + lsp--text-document-position-params
> >          152   1%    + redisplay
> >           89   0%   + posn-at-point
> >           20   0%   + corfu--candidates-popup
> >          674   5% + command-execute
> >          269   2% + redisplay_internal (C function)
> >           74   0% + #<byte-code-function 31C>
> >           59   0% + timer-event-handler
> >           25   0% + ...
> >
> > Please tell me if you need more information,
>
> While a Lisp profile is always a good thing to have, I suspect a C
> profile is more useful in this case.  Can you run
>
> perf record -e instructions,cycles ./src/emacs -Q
>
> then find a problematic workflow and wait for the problem to occur
> (ideally, this will happen so often as to dominate the CPU trace), then
> quit emacs in the ordinary fashion.  After that
>
> perf report
>
> will produce a basic output C profile.  It's both very long and somewhat
> hard to read, but I think posting it to a bug number email should be
> okay.  If you do this, please save these files for this specific run
> somewhere:
>
> ./src/emacs
> ./src/emacs.pdmp
> ./perf.data
> any coredumps you might have had
>
> This will allow us to investigate the situation further if the function
> names aren't enough to find the culprits.

Thanks, here is a partial output of perf report, tell me if you need
more (events > 1%):

====
Samples: 1K of event 'cpu_atom/instructions/u', Event count (approx.):
1304155293
 10,41%  emacs    emacs                           [.]
find_cache_boundary

                                        ◆
   5,90%  emacs    emacs                           [.]
lookup_char_property

                                        ▒
   4,71%  emacs    libpixman-1.so.0.44.2           [.]
0x000000000006f4c3

                                        ▒
   3,33%  emacs    libpixman-1.so.0.44.2           [.]
0x000000000006f4d7

                                        ▒
   3,01%  emacs    libpixman-1.so.0.44.2           [.]
0x00000000000733a2

                                        ▒
   2,84%  emacs    libpixman-1.so.0.44.2           [.]
0x00000000000733d5

                                        ▒
   2,61%  emacs    libpixman-1.so.0.44.2           [.]
0x000000000006f4df

                                        ▒
   2,57%  emacs    emacs                           [.] find_newline


                        ▒
   2,20%  emacs    libpixman-1.so.0.44.2           [.]
0x00000000000733b8

                                        ▒
   1,81%  emacs    libpixman-1.so.0.44.2           [.]
0x00000000000733af

                                        ▒
   1,75%  emacs    emacs                           [.] read_char


                        ▒
   1,72%  emacs    emacs                           [.]
itree_iter_next_in_subtree

                                        ▒
   1,65%  emacs    libpixman-1.so.0.44.2           [.]
0x00000000000733e1

                                        ▒
   1,62%  emacs    libpixman-1.so.0.44.2           [.]
0x000000000006f4cf

                                        ▒
   1,59%  emacs    libpixman-1.so.0.44.2           [.]
0x00000000000733cf

                                        ▒
   1,56%  emacs    libpixman-1.so.0.44.2           [.]
0x00000000000733c5

                                        ▒
   1,56%  emacs    emacs                           [.]
re_match_2_internal

                                        ▒
   1,47%  emacs    libpixman-1.so.0.44.2           [.]
0x00000000000733aa

                                        ▒
   1,42%  emacs    emacs                           [.] find_interval


                        ▒
   1,34%  emacs    [vdso]                          [.]
__vdso_clock_gettime

                                        ▒
   1,21%  emacs    libpixman-1.so.0.44.2           [.]
0x00000000000733b6

                                        ▒
   1,19%  emacs    emacs                           [.] Fassq


                        ▒
   1,18%  emacs    libpixman-1.so.0.44.2           [.]
0x00000000000733e4

                                        ▒
   1,14%  emacs    libpixman-1.so.0.44.2           [.]
0x00000000000733d9

                                        ▒
   1,10%  emacs    emacs                           [.]
gui_produce_glyphs

                                        ▒
   1,05%  emacs    emacs                           [.]
bidi_resolve_explicit

====
Samples: 133K of event 'cpu_core/instructions/u', Event count
(approx.): 186403198903
  21,55%  emacs    [vdso]                                [.]
__vdso_clock_gettime
  20,07%  emacs    [unknown]                             [k] 0xffffffff9e200080
  11,55%  emacs    emacs                                 [.] read_char
   4,31%  emacs    emacs                                 [.] restore_getcjmp
   2,87%  emacs    libpixman-1.so.0.44.2                 [.] 0x00000000000733a2
   2,47%  emacs    emacs                                 [.]
quit_throw_to_read_char
   2,16%  emacs    emacs                                 [.] some_mouse_moved
   1,94%  emacs    libc.so.6                             [.] siglongjmp
   1,89%  emacs    libc.so.6                             [.] pthread_sigmask
   1,75%  emacs    emacs                                 [.] unbind_to
   1,49%  emacs    emacs                                 [.] EQ
   1,33%  emacs    libc.so.6                             [.] 0x00000000000925c6
   1,32%  emacs    emacs                                 [.] kbd_on_hold_p
   1,25%  emacs    libc.so.6                             [.] 0x00000000000925a5
   1,19%  emacs    emacs                                 [.] _longjmp <at> plt
   1,18%  emacs    libc.so.6                             [.] 0x0000000000092616
   1,11%  emacs    emacs                                 [.]
record_unwind_protect_ptr
   1,10%  emacs    libpixman-1.so.0.44.2                 [.] 0x00000000000733b8
   1,08%  emacs    libc.so.6                             [.] 0x000000000003cfaf
   1,00%  emacs    emacs                                 [.] pthread_sigmask <at> plt

====
Samples: 1K of event 'cpu_atom/cycles/u', Event count (approx.): 1083537627
 22,42%  emacs    libpixman-1.so.0.44.2         [.] 0x000000000006f4c3


                       ◆
  13,33%  emacs    libpixman-1.so.0.44.2         [.]
0x000000000006f4d7

                                          ▒
   9,30%  emacs    libpixman-1.so.0.44.2         [.]
0x000000000006f4df

                                          ▒
   4,77%  emacs    emacs                         [.]
find_cache_boundary

                                          ▒
   3,84%  emacs    libpixman-1.so.0.44.2         [.]
0x000000000006f4cf

                                          ▒
   2,95%  emacs    libpixman-1.so.0.44.2         [.]
0x00000000000733a2

                                          ▒
   2,34%  emacs    emacs                         [.]
lookup_char_property

                                          ▒
   1,51%  emacs    libpixman-1.so.0.44.2         [.]
0x000000000006f4e3

                                          ▒
   1,28%  emacs    libpixman-1.so.0.44.2         [.]
0x00000000000733b8

                                          ▒
   1,23%  emacs    libpixman-1.so.0.44.2         [.]
0x000000000006f4d3

====
Samples: 140K of event 'cpu_core/cycles/u', Event count (approx.): 79660130854
  16,86%  emacs    [vdso]                                [.]
__vdso_clock_gettime
  13,66%  emacs    [unknown]                             [k] 0xffffffff9e200080
  12,32%  emacs    emacs                                 [.] read_char
   6,88%  emacs    emacs                                 [.] unbind_to
   6,41%  emacs    libpixman-1.so.0.44.2                 [.] 0x00000000000733a2
   5,66%  emacs    libc.so.6                             [.] pthread_sigmask
   4,58%  emacs    emacs                                 [.] restore_getcjmp
   3,73%  emacs    libpixman-1.so.0.44.2                 [.] 0x000000000006f4c3
   2,64%  emacs    libpixman-1.so.0.44.2                 [.] 0x000000000006f4db
   2,22%  emacs    emacs                                 [.]
quit_throw_to_read_char
   1,90%  emacs    libpixman-1.so.0.44.2                 [.] 0x000000000006f4e3
   1,24%  emacs    emacs                                 [.] some_mouse_moved
   1,19%  emacs    libpixman-1.so.0.44.2                 [.] 0x000000000006f4cb
   1,08%  emacs    emacs                                 [.]
record_unwind_protect_ptr
   1,05%  emacs    emacs                                 [.] current_timespec


>
> Please also attempt to find the precise version of "corfu", as well as
> any other packages that might seem like they're involved.

I am using corfu 1.7 from melpa-stable, and lsp-mode 20250129.601 from melpa

>
>
> Thanks!
> Pip
>




This bug report was last modified 159 days ago.

Previous Next


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