* bug#48812: 28.0.50; describe-bindings stucks and gets high CPU load @ 2021-06-03 15:06 Naofumi Yasufuku 2021-06-03 15:15 ` Naofumi Yasufuku 2021-06-03 17:15 ` Eli Zaretskii 0 siblings, 2 replies; 4+ messages in thread From: Naofumi Yasufuku @ 2021-06-03 15:06 UTC (permalink / raw) To: 48812 [-- Attachment #1: Type: text/plain, Size: 6089 bytes --] This describe-bindings stuck is caused by millions of shadow_lookup() calls in src/keymap.c describe_vector(). ------------------------------------------------------------------------ $ ./src/emacs describe_vector] shadow_lookup loop START: definition=self-insert-command shadowed_by=nil starting_i=128 i=4194175 describe_vector] shadow_lookup loop END: definition=self-insert-command shadowed_by=nil starting_i=128 i=4194175 describe_vector] shadow_lookup loop START: definition=self-insert-command shadowed_by=nil starting_i=4194176 i=4194303 describe_vector] shadow_lookup loop END: definition=self-insert-command shadowed_by=nil starting_i=4194176 i=4194303 describe_vector] shadow_lookup loop START: definition=digit-argument shadowed_by=nil starting_i=48 i=57 describe_vector] shadow_lookup loop END: definition=digit-argument shadowed_by=nil starting_i=48 i=57 $ ------------------------------------------------------------------------ diff --git a/src/keymap.c b/src/keymap.c index fb8eceaec1..0efa78ce9b 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -3065,6 +3065,11 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args, if (CHAR_TABLE_P (vector) && i != starting_i) { Lisp_Object key = make_nil_vector (1); + fprintf (stderr, "%s] shadow_lookup loop START: definition=%s shadowed_by=%s starting_i=%d i=%d\n", + __func__, + SDATA (SYMBOL_NAME (definition)), + SDATA (SYMBOL_NAME (shadowed_by)), + starting_i, i); for (int j = starting_i + 1; j <= i; j++) { ASET (key, 0, make_fixnum (j)); @@ -3072,6 +3077,11 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args, if (NILP (Fequal (tem, shadowed_by))) i = j - 1; } + fprintf (stderr, "%s] shadow_lookup loop END: definition=%s shadowed_by=%s starting_i=%d i=%d\n", + __func__, + SDATA (SYMBOL_NAME (definition)), + SDATA (SYMBOL_NAME (shadowed_by)), + starting_i, i); } /* If we have a range of more than one character, ------------------------------------------------------------------------ This shadow_lookup() loop was introduced by the following commit: ------------------------------------------------------------------------ commit a6490343366f2b2331a91dcb693effb3a9dd78f5 Author: Stefan Kangas <stefan@marxist.se> Date: Fri Nov 13 15:28:29 2020 +0100 Don't show key ranges if shadowed by different commands * src/keymap.c (describe_vector): Make sure found consecutive keys are either not shadowed or, if they are, that they are shadowed by the same command. (Bug#9293) * test/src/keymap-tests.el (help--describe-vector/bug-9293-one-shadowed-in-range): New test. ------------------------------------------------------------------------ In GNU Emacs 28.0.50 (build 3, aarch64-unknown-linux-gnu, GTK+ Version 3.24.25, cairo version 1.16.0) of 2021-06-03 built on phoebe Repository revision: 089e0c4c55dcf72f9cf2f6f04b8a52fc7355499c Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101001 System Description: Ubuntu 21.04 Configured features: CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB Important settings: value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: C/*l Minor modes in effect: bug-reference-prog-mode: t tooltip-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t abbrev-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message rmc puny rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache json map text-property-search mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils vc-git diff-mode easy-mmode vc vc-dispatcher bug-reference cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs misearch multi-isearch dired-aux dired dired-loaddefs time-date subr-x cl-extra seq byte-opt gv bytecomp byte-compile cconv kmacro two-column help-mode cl-loaddefs cl-lib iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-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 cl-generic 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 charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 118009 7881) (symbols 48 9308 1) (strings 32 27924 2053) (string-bytes 1 1038142) (vectors 16 18491) (vector-slots 8 227657 9510) (floats 8 31 163) (intervals 56 10630 0) (buffers 992 14)) [-- Attachment #2.1: Type: text/html, Size: 10295 bytes --] [-- Attachment #2.2: 28.0.50-describe-bindings-01.png --] [-- Type: image/png, Size: 446268 bytes --] [-- Attachment #2.3: 28.0.50-describe-bindings-02.png --] [-- Type: image/png, Size: 446434 bytes --] [-- Attachment #2.4: 27.1-ubuntu-describe-bindings.png --] [-- Type: image/png, Size: 407059 bytes --] ^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#48812: 28.0.50; describe-bindings stucks and gets high CPU load 2021-06-03 15:06 bug#48812: 28.0.50; describe-bindings stucks and gets high CPU load Naofumi Yasufuku @ 2021-06-03 15:15 ` Naofumi Yasufuku 2021-06-03 17:15 ` Eli Zaretskii 1 sibling, 0 replies; 4+ messages in thread From: Naofumi Yasufuku @ 2021-06-03 15:15 UTC (permalink / raw) To: 48812 [-- Attachment #1: Type: text/plain, Size: 107 bytes --] Attached simple patch could fix this. Is there no regression with this change? Regards, —Naofumi [-- Attachment #2: 0001-Fix-describe-bindings-stuck-caused-by-heavy-shadow_l.patch --] [-- Type: application/octet-stream, Size: 1265 bytes --] From 66cc6b85e13fc49a5b8115c4606d36660c486a97 Mon Sep 17 00:00:00 2001 From: Naofumi Yasufuku <naofumi@yasufuku.dev> Date: Thu, 3 Jun 2021 22:02:28 +0900 Subject: [PATCH] Fix describe-bindings stuck caused by heavy shadow_lookup() loop * src/keymap.c (describe_vector): If 'shadowed_by' key definition is nil, do not attempt to find a first key character, which is shadowed by the same command, in consecutive character table range by using shadow_lookup() loop. This loop can cause millions of Flookup_key() calls: e.g. 'self-insert-command' bindings. (Bug#48812 Bug#9293) --- src/keymap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/keymap.c b/src/keymap.c index fb8eceaec1..a20b877565 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -3062,7 +3062,7 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args, /* Make sure found consecutive keys are either not shadowed or, if they are, that they are shadowed by the same command. */ - if (CHAR_TABLE_P (vector) && i != starting_i) + if (!NILP (shadowed_by) && CHAR_TABLE_P (vector) && i != starting_i) { Lisp_Object key = make_nil_vector (1); for (int j = starting_i + 1; j <= i; j++) -- 2.31.1 [-- Attachment #3: Type: text/plain, Size: 6577 bytes --] > On Jun 4, 2021, at 0:06, Naofumi Yasufuku <naofumi@yasufuku.dev> wrote: > > This describe-bindings stuck is caused by millions of shadow_lookup() calls > in src/keymap.c describe_vector(). > > ------------------------------------------------------------------------ > $ ./src/emacs > describe_vector] shadow_lookup loop START: definition=self-insert-command shadowed_by=nil starting_i=128 i=4194175 > describe_vector] shadow_lookup loop END: definition=self-insert-command shadowed_by=nil starting_i=128 i=4194175 > describe_vector] shadow_lookup loop START: definition=self-insert-command shadowed_by=nil starting_i=4194176 i=4194303 > describe_vector] shadow_lookup loop END: definition=self-insert-command shadowed_by=nil starting_i=4194176 i=4194303 > describe_vector] shadow_lookup loop START: definition=digit-argument shadowed_by=nil starting_i=48 i=57 > describe_vector] shadow_lookup loop END: definition=digit-argument shadowed_by=nil starting_i=48 i=57 > $ > ------------------------------------------------------------------------ > diff --git a/src/keymap.c b/src/keymap.c > index fb8eceaec1..0efa78ce9b 100644 > --- a/src/keymap.c > +++ b/src/keymap.c > @@ -3065,6 +3065,11 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args, > if (CHAR_TABLE_P (vector) && i != starting_i) > { > Lisp_Object key = make_nil_vector (1); > + fprintf (stderr, "%s] shadow_lookup loop START: definition=%s shadowed_by=%s starting_i=%d i=%d\n", > + __func__, > + SDATA (SYMBOL_NAME (definition)), > + SDATA (SYMBOL_NAME (shadowed_by)), > + starting_i, i); > for (int j = starting_i + 1; j <= i; j++) > { > ASET (key, 0, make_fixnum (j)); > @@ -3072,6 +3077,11 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, Lisp_Object args, > if (NILP (Fequal (tem, shadowed_by))) > i = j - 1; > } > + fprintf (stderr, "%s] shadow_lookup loop END: definition=%s shadowed_by=%s starting_i=%d i=%d\n", > + __func__, > + SDATA (SYMBOL_NAME (definition)), > + SDATA (SYMBOL_NAME (shadowed_by)), > + starting_i, i); > } > > /* If we have a range of more than one character, > ------------------------------------------------------------------------ > > > This shadow_lookup() loop was introduced by the following commit: > > ------------------------------------------------------------------------ > commit a6490343366f2b2331a91dcb693effb3a9dd78f5 > Author: Stefan Kangas <stefan@marxist.se> > Date: Fri Nov 13 15:28:29 2020 +0100 > > Don't show key ranges if shadowed by different commands > > * src/keymap.c (describe_vector): Make sure found consecutive keys > are either not shadowed or, if they are, that they are shadowed by > the same command. (Bug#9293) > * test/src/keymap-tests.el > (help--describe-vector/bug-9293-one-shadowed-in-range): New test. > > ------------------------------------------------------------------------ > > > <28.0.50-describe-bindings-01.png> > > <28.0.50-describe-bindings-02.png> > > <27.1-ubuntu-describe-bindings.png> > > > In GNU Emacs 28.0.50 (build 3, aarch64-unknown-linux-gnu, GTK+ Version 3.24.25, cairo version 1.16.0) > of 2021-06-03 built on phoebe > Repository revision: 089e0c4c55dcf72f9cf2f6f04b8a52fc7355499c > Repository branch: master > Windowing system distributor 'The X.Org Foundation', version 11.0.12101001 > System Description: Ubuntu 21.04 > > Configured features: > CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON > LCMS2 LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG > RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM > GTK3 ZLIB > > Important settings: > value of $LANG: en_US.UTF-8 > value of $XMODIFIERS: @im=ibus > locale-coding-system: utf-8-unix > > Major mode: C/*l > > Minor modes in effect: > bug-reference-prog-mode: t > tooltip-mode: t > global-eldoc-mode: t > electric-indent-mode: t > mouse-wheel-mode: t > tool-bar-mode: t > menu-bar-mode: t > file-name-shadow-mode: t > global-font-lock-mode: t > font-lock-mode: t > blink-cursor-mode: t > auto-composition-mode: t > auto-encryption-mode: t > auto-compression-mode: t > line-number-mode: t > transient-mark-mode: t > abbrev-mode: t > > Load-path shadows: > None found. > > Features: > (shadow sort mail-extr emacsbug message rmc puny rfc822 mml mml-sec epa > derived epg epg-config gnus-util rmail rmail-loaddefs auth-source cl-seq > eieio eieio-core cl-macs eieio-loaddefs password-cache json map > text-property-search mm-decode mm-bodies mm-encode mail-parse rfc2231 > mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums > mm-util mail-prsvr mail-utils vc-git diff-mode easy-mmode vc > vc-dispatcher bug-reference cc-mode cc-fonts cc-guess cc-menus cc-cmds > cc-styles cc-align cc-engine cc-vars cc-defs misearch multi-isearch > dired-aux dired dired-loaddefs time-date subr-x cl-extra seq byte-opt gv > bytecomp byte-compile cconv kmacro two-column help-mode cl-loaddefs > cl-lib iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks > lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar > dnd fontset image regexp-opt fringe tabulated-list replace newcomment > text-mode elisp-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 cl-generic > 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 charscript charprop > case-table epa-hook jka-cmpr-hook help simple abbrev obarray > cl-preloaded nadvice button loaddefs faces cus-face macroexp files > window text-properties overlay sha1 md5 base64 format env code-pages > mule custom widget hashtable-print-readable backquote threads dbusbind > inotify lcms2 dynamic-setting system-font-setting font-render-setting > cairo move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) > > Memory information: > ((conses 16 118009 7881) > (symbols 48 9308 1) > (strings 32 27924 2053) > (string-bytes 1 1038142) > (vectors 16 18491) > (vector-slots 8 227657 9510) > (floats 8 31 163) > (intervals 56 10630 0) > (buffers 992 14)) > > ^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#48812: 28.0.50; describe-bindings stucks and gets high CPU load 2021-06-03 15:06 bug#48812: 28.0.50; describe-bindings stucks and gets high CPU load Naofumi Yasufuku 2021-06-03 15:15 ` Naofumi Yasufuku @ 2021-06-03 17:15 ` Eli Zaretskii 2021-06-03 17:52 ` Naofumi Yasufuku 1 sibling, 1 reply; 4+ messages in thread From: Eli Zaretskii @ 2021-06-03 17:15 UTC (permalink / raw) To: Naofumi Yasufuku; +Cc: 48812 merge 48812 45379 thanks > From: Naofumi Yasufuku <naofumi@yasufuku.dev> > Date: Fri, 4 Jun 2021 00:06:55 +0900 > > This describe-bindings stuck is caused by millions of shadow_lookup() calls > in src/keymap.c describe_vector(). This is a duplicate of bug#45379. ^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#48812: 28.0.50; describe-bindings stucks and gets high CPU load 2021-06-03 17:15 ` Eli Zaretskii @ 2021-06-03 17:52 ` Naofumi Yasufuku 0 siblings, 0 replies; 4+ messages in thread From: Naofumi Yasufuku @ 2021-06-03 17:52 UTC (permalink / raw) To: Eli Zaretskii; +Cc: 48812 Thanks. I’m sorry for bothering you. I found bug#45379. It looks really complicated... > On Jun 4, 2021, at 2:15, Eli Zaretskii <eliz@gnu.org> wrote: > > merge 48812 45379 > thanks > >> From: Naofumi Yasufuku <naofumi@yasufuku.dev> >> Date: Fri, 4 Jun 2021 00:06:55 +0900 >> >> This describe-bindings stuck is caused by millions of shadow_lookup() calls >> in src/keymap.c describe_vector(). > > This is a duplicate of bug#45379. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-06-03 17:52 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2021-06-03 15:06 bug#48812: 28.0.50; describe-bindings stucks and gets high CPU load Naofumi Yasufuku 2021-06-03 15:15 ` Naofumi Yasufuku 2021-06-03 17:15 ` Eli Zaretskii 2021-06-03 17:52 ` Naofumi Yasufuku
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.