Subject: 26.3; Emacs is extremely unresponsive on a trivial python file

From: Ivan Oreshnikov <[email-masked]>
Date: Fri, 14 Feb 2020 11:48:43 +0100

Emacs becomes extremely sluggish for me even on the most trivial python
files sometime. The most recent example I of this behavior that I can
reliably reproduce is the following:

1. Open an empty python buffer.
2. Insert a string "this is a test string" (including quotes) on the
   first line of buffer.
3. Copy it and insert it 10 times.
4. Copy all the lines in the buffer and insert them 10 times more. This
   should give you 100 lines of python strings.
5. By the fifth paste command you can see 1 or 2 second delays before the
   buffer is updated.
6. After that navigating to the beginning or the end of buffer will
   trigger a couple of seconds of hangup. Page scrolls can randomly
   hangup. Iserting a blank line somewhere in the middle of the buffer can
   cause a random 1 or 2 second delay as well.

Those are some excerpts from the profiler report:

- command-execute                                               48141  87%
 - call-interactively                                           48137  87%
  - funcall-interactively                                       48064  87%
   - end-of-buffer                                              46719  84%
    - recenter                                                  46713  84%
     - jit-lock-function                                        46713  84%
      - jit-lock-fontify-now                                    46713  84%
       - jit-lock--run-functions                                46713  84%
        - run-hook-wrapped                                      46713  84%
         + #<compiled 0xf8aa91>                                 46713  84%

...

- redisplay_internal (C function)                                4935   8%
 - jit-lock-function                                             4899   8%
  - jit-lock-fontify-now                                         4897   8%
   - jit-lock--run-functions                                     4894   8%
    - run-hook-wrapped                                           4894   8%
     + #<compiled 0xf8aa91>                                      4894   8%

In GNU Emacs 26.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
 of 2019-12-03 built on lgw01-amd64-029
Repository revision: ea9cfdb4812c1140416c523bac34a6ec72db7fce
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
System Description: Ubuntu 18.04.3 LTS

Recent messages:
Mark set
Quit
Mark set
next-line: End of buffer
Mark set [3 times]
Quit [2 times]
Mark set [4 times]
Quit
Mark set [2 times]
Quit

Configured using:
 'configure --prefix= --prefix=/snap/emacs/current/usr 'CFLAGS=
 -I/build/emacs/parts/emacs/install/usr/include' 'CPPFLAGS=
 -I/build/emacs/parts/emacs/install/usr/include' 'LDFLAGS=
 -L/build/emacs/parts/emacs/install/lib
 -L/build/emacs/parts/emacs/install/usr/lib
 -L/build/emacs/parts/emacs/install/lib/x86_64-linux-gnu
 -L/build/emacs/parts/emacs/install/usr/lib/x86_64-linux-gnu''

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS GLIB
NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM THREADS LIBSYSTEMD LCMS2

Important settings:
  value of $LC_MONETARY: en_GB.UTF-8
  value of $LC_NUMERIC: en_GB.UTF-8
  value of $LC_TIME: en_GB.UTF-8
  value of $LANG: en_GB.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Python

Minor modes in effect:
  shell-dirtrack-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  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

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail
rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils profiler python easymenu tramp-sh tramp
tramp-compat tramp-loaddefs trampver ucs-normalize shell pcomplete
parse-time format-spec advice auth-source cl-seq eieio eieio-core
cl-macs eieio-loaddefs password-cache json map seq byte-opt gv bytecomp
byte-compile cconv comint ring cl-loaddefs cl-lib ansi-color elec-pair
time-date mule-util 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 menu-bar
rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core term/tty-colors frame 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 minibuffer
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
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
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 233944 16451)
 (symbols 48 22819 2)
 (miscs 40 68 448)
 (strings 32 37667 2664)
 (string-bytes 1 1114745)
 (vectors 16 60243)
 (vector-slots 8 1252726 14364)
 (floats 8 70 421)
 (intervals 56 875 0)
 (buffers 992 14))