Subject: CPU hogs with pgtk
From: Nicolas Sarlin <[email-masked]>
To: [email-masked]
Date: Wed, 29 Jan 2025 12:05:16 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello,
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
          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,
Thank you for your help

In GNU Emacs 30.0.93 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.43, cairo version 1.18.2) of 2025-01-27 built on zama-laptop
Repository revision: 84595cbcc78b1ea44302f22b83a7d722940c6e49
Repository branch: emacs-30
System Description: Arch Linux

Configured using:
 'configure --with-pgtk'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBOTF LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY
PDUMPER PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM GTK3 ZLIB

Important settings:
  value of $LC_MONETARY: fr_FR.UTF-8
  value of $LC_NUMERIC: fr_FR.UTF-8
  value of $LC_TIME: fr_FR.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Message

Minor modes in effect:
  editorconfig-mode: t
  global-corfu-mode: t
  corfu-mode: t
  mml-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  column-number-mode: t
  line-number-mode: t
  auto-fill-function: message-do-auto-fill
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  abbrev-mode: t
  hs-minor-mode: t

Load-path shadows:
None found.

Features:
(mailalias mailclient textsec uni-scripts idna-mapping ucs-normalize
uni-confusable textsec-check ispell help-fns profiler flymake
lsp-diagnostics lsp-headerline lsp-modeline lsp-lens view lsp-zig
lsp-yang lsp-yaml lsp-xml lsp-wgsl lsp-volar lsp-vimscript lsp-vhdl
lsp-vetur lsp-verilog lsp-vala lsp-v lsp-typespec lsp-typeprof lsp-ttcn3
lsp-ts-query lsp-trunk lsp-toml lsp-tilt lsp-tex lsp-terraform
lsp-svelte lsp-steep lsp-sqls lsp-sql lsp-sorbet lsp-solidity
lsp-solargraph lsp-semgrep lsp-rust lsp-ruff lsp-ruby-syntax-tree
lsp-ruby-lsp lsp-rubocop lsp-roslyn lsp-roc lsp-rf lsp-remark lsp-racket
lsp-r lsp-qml lsp-pylsp lsp-pyls lsp-pwsh lsp-purescript lsp-pls lsp-php
lsp-perlnavigator lsp-perl lsp-openscad lsp-ocaml lsp-nushell lsp-nix
lsp-nim lsp-nginx lsp-nextflow lsp-move lsp-mojo lsp-mint lsp-meson
lsp-mdx lsp-matlab lsp-marksman lsp-markdown lsp-magik lsp-fennel
lsp-lua lsp-lisp lsp-kubernetes-helm lsp-kotlin lsp-json lsp-jq
lsp-idris lsp-haxe lsp-hack lsp-groovy lsp-graphql lsp-golangci-lint
lsp-glsl lsp-gleam lsp-gdscript lsp-fsharp lsp-futhark lsp-fortran
lsp-eslint lsp-erlang lsp-emmet lsp-elm lsp-elixir lsp-earthly
lsp-dockerfile lsp-dhall lsp-d lsp-cypher lsp-cucumber lsp-copilot
lsp-css lsp-csharp lsp-crystal lsp-credo lsp-cobol lsp-cmake lsp-clojure
lsp-clangd lsp-bufls lsp-beancount lsp-bash lsp-awk lsp-autotools
lsp-astro lsp-asm lsp-ansible lsp-angular lsp-ada lsp-actionscript
vc-git diff-mode track-changes vc-dispatcher misearch multi-isearch
shadow sort mail-extr emacsbug editorconfig editorconfig-core
editorconfig-core-handle editorconfig-fnmatch rust-utils rust-prog-mode
rust-mode rust-playpen rust-cargo rust-common rust-rustfmt rust-compile
rust-mode-autoloads corfu compat corfu-autoloads lsp-ui lsp-ui-doc
lsp-ui-imenu lsp-ui-peek lsp-ui-sideline find-func goto-addr lsp-ui-util
face-remap lsp-ui-autoloads lsp-javascript lsp-html ido lsp-icons dom
lsp-go lsp-completion lsp-semantic-tokens lsp-mode comp comp-cstr
lsp-protocol xref tree-widget spinner markdown-mode lv imenu ht
filenotify f ewoc lsp-mode-autoloads s f-autoloads s-autoloads inline
dash ht-autoloads info dash-autoloads spinner-autoloads pcase color
thingatpt noutline outline markdown-mode-autoloads easy-mmode warnings
lv-autoloads loaddefs-gen lisp-mnt radix-tree tar-mode arc-mode
archive-mode cus-edit pp cus-start cus-load wid-edit mm-archive message
sendmail yank-media dired dired-loaddefs rfc822 mml mml-sec epa derived
gnus-util time-date mailabbrev gmm-utils mailheader mm-decode mm-bodies
mm-encode mail-utils gnutls network-stream url-cache url-http url-auth
mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr url-gw
nsm puny compile text-property-search comint ansi-osc ansi-color ring
comp-run comp-common rx epg rfc6068 epg-config use-package-ensure
project finder-inf package browse-url url url-proxy url-privacy
url-expand url-methods url-history url-cookie generate-lisp-file
url-domsuf url-util mailcap url-handlers url-parse auth-source eieio
eieio-core icons password-cache json subr-x map byte-opt url-vars
cl-macs gv cl-extra help-mode cl-seq use-package-core cl-loaddefs cl-lib
bytecomp byte-compile rmc iso-transl tooltip cconv eldoc paren electric
uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/pgtk-win pgtk-win term/common-win touch-screen pgtk-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow
isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify
dynamic-setting system-font-setting font-render-setting cairo gtk pgtk
lcms2 multi-tty move-toolbar make-network-process native-compile emacs)

Memory information:
((conses 16 1165555 834435) (symbols 48 39223 34) (strings 32 289158 102434)
 (string-bytes 1 6818416) (vectors 16 137350) (vector-slots 8 1772485
595550)
 (floats 8 631 1411) (intervals 56 5673 2695) (buffers 992 36))