Subject: Very slow scroll-down-line with a lot of text properties
From: "Herman, Geza" <[email-masked]>
To: [email-masked]
Date: Tue, 21 Mar 2023 21:01:58 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Emacs can freeze for seconds when scroll-down-line is called multiple 
times if the buffer contains a lot of text properties.

I noticed this when using lsp-mode for C++.

To reproduce the issue without lsp-mode, execute this elisp command with 
M-:, this will add a face to operators:

(font-lock-add-keywords 'c++-mode '(("[][~!^&\|<>:=,.\\+*/%-]" 0 'error)))

Also, bind scroll-down-line to a key, like shift-up:

(global-set-key (kbd "<S-up>") 'scroll-down-line)

Then, put the attached example.cpp into a c++ buffer, move the point to 
the bottom, then press and hold shift-up. Emacs will update the window 
for several scroll events, but after that it won't update the screen for 
a while. Even after shift-up is released, Emacs needs several seconds to 
be interactive again.

In GNU Emacs 29.0.60 (build 1, x86_64-pc-linux-gnu, GTK+ Version
  3.24.36, cairo version 1.16.0) of 2023-03-21 built on okoska
Repository revision: 7a1272168af1a5b82979efa29451147c5d867981
Repository branch: emacs-29
Windowing system distributor 'The X.Org Foundation', version 11.0.12101006
System Description: Debian GNU/Linux bookworm/sid

Configured using:
  'configure --with-native-compilation=aot --without-compress-install
  --with-json --with-xinput2 --with-xwidgets --with-tree-sitter
  --with-cairo'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES
NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG SECCOMP SOUND SQLITE3 THREADS
TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM
XWIDGETS GTK3 ZLIB

Important settings:
   value of $LC_ALL: C.UTF-8
   value of $LANG: en_US.UTF-8
   value of $XMODIFIERS: @im=none
   locale-coding-system: utf-8-unix

Major mode: C++//l

Minor modes in effect:
   tooltip-mode: t
   global-eldoc-mode: t
   show-paren-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
   line-number-mode: t
   indent-tabs-mode: t
   transient-mark-mode: t
   auto-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t
   abbrev-mode: t

Load-path shadows:
/home/geza/.emacs.d/elpa/transient-20230304.1149/transient hides 
/usr/local/share/emacs/29.0.60/lisp/transient

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util text-property-search time-date mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils comp comp-cstr
warnings icons subr-x rx cl-seq cl-macs gv cl-extra help-mode bytecomp
byte-compile cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles
cc-align cc-engine cc-vars cc-defs cl-loaddefs cl-lib info
evil-surround-autoloads scad-mode-autoloads qml-mode-autoloads
evil-exchange-autoloads evil-args-autoloads cmake-font-lock-autoloads
visual-fill-column-autoloads evil-textobj-anyblock-autoloads
evil-visualstar-autoloads impatient-mode-autoloads
volatile-highlights-autoloads maxima-autoloads
evil-cleverparens-autoloads consult-dir-autoloads gnuplot-autoloads
helpful-autoloads git-modes-autoloads font-lock-profiler-autoloads
paredit-autoloads math-preview-autoloads modern-cpp-font-lock-autoloads
column-enforce-mode-autoloads plantuml-mode-autoloads
yaml-mode-autoloads magit-todos-autoloads hl-todo-autoloads
treemacs-evil-autoloads define-word-autoloads paradox-autoloads
highlight-quoted-autoloads rg-autoloads lsp-pyright-autoloads
peep-dired-autoloads highlight-numbers-autoloads dired-filter-autoloads
fold-this-autoloads eterm-256color-autoloads xterm-color-autoloads
rainbow-mode-autoloads evil-org-autoloads evil-mc-autoloads
doom-modeline-autoloads hungry-delete-autoloads vterm-autoloads
magit-tbdiff-autoloads embark-consult-autoloads
literate-calc-mode-autoloads free-keys-autoloads memory-usage-autoloads
ccls-autoloads svg-tag-mode-autoloads atomic-chrome-autoloads
websocket-autoloads test-simple-autoloads frog-jump-buffer-autoloads
frog-menu-autoloads gcmh-autoloads elisp-refs-autoloads
evil-textobj-line-autoloads yasnippet-autoloads
highlight-doxygen-autoloads vertico-autoloads elfeed-autoloads
consult-lsp-autoloads dired-narrow-autoloads highlight-autoloads
smeargle-autoloads clean-aindent-mode-autoloads cmake-mode-autoloads
string-inflection-autoloads ws-butler-autoloads ov-autoloads
gif-screencast-autoloads diredfl-autoloads go-mode-autoloads
centered-cursor-mode-autoloads lsp-ui-autoloads camcorder-autoloads
easy-mmode org-jira-autoloads ag-autoloads queue-autoloads
orderless-autoloads hide-lines-autoloads git-timemachine-autoloads
csv-mode-autoloads broadcast-autoloads evil-leader-autoloads
hide-mode-line-autoloads company-box-autoloads transpose-frame-autoloads
lsp-treemacs-autoloads evil-textobj-entire-autoloads htmlize-autoloads
dired-subtree-autoloads dired-hacks-utils-autoloads
evil-multiedit-autoloads iedit-autoloads orgit-autoloads
evil-textobj-column-autoloads names-autoloads advice wgrep-autoloads
ninja-mode-autoloads smartparens-autoloads powerthesaurus-autoloads
request-autoloads git-gutter-fringe-autoloads git-gutter-autoloads
highlight-indent-guides-autoloads parent-mode-autoloads
pcre2el-autoloads rust-mode-autoloads evil-snipe-autoloads
fringe-helper-autoloads glsl-mode-autoloads disk-usage-autoloads
highlight-symbol-autoloads git-identity-autoloads
consult-flycheck-autoloads consult-autoloads shrink-path-autoloads
treemacs-projectile-autoloads winum-autoloads svg-lib-autoloads
org-superstar-autoloads rmsbolt-autoloads dired-git-info-autoloads
all-the-icons-autoloads ob-ipython-autoloads dash-functional-autoloads
evil-collection-autoloads annalist-autoloads treemacs-magit-autoloads
treemacs-autoloads cfrs-autoloads pfuture-autoloads ace-window-autoloads
avy-autoloads demangle-mode-autoloads frame-local-autoloads
evil-anzu-autoloads anzu-autoloads evil-indent-plus-autoloads
better-jumper-autoloads delight-autoloads company-autoloads
projectile-autoloads marginalia-autoloads dumb-jump-autoloads
popup-autoloads bm-autoloads vdiff-magit-autoloads vdiff-autoloads
hydra-autoloads evil-lion-autoloads evil-autoloads goto-chg-autoloads
evil-matchit-autoloads async-autoloads simple-httpd-autoloads
lorem-ipsum-autoloads expand-region-autoloads shut-up-autoloads
flycheck-autoloads pkg-info-autoloads epl-autoloads
page-break-lines-autoloads embark-autoloads which-key-autoloads
blamer-autoloads posframe-autoloads git-link-autoloads
drag-stuff-autoloads code-review-autoloads emojify-autoloads
forge-autoloads yaml-autoloads deferred-autoloads uuidgen-autoloads
ghub-autoloads treepy-autoloads a-autoloads magit-autoloads
magit-section-autoloads git-commit-autoloads with-editor-autoloads
transient-autoloads closql-autoloads emacsql-autoloads compat-autoloads
lsp-mode-autoloads lv-autoloads markdown-mode-autoloads
spinner-autoloads ht-autoloads f-autoloads s-autoloads dash-autoloads
rmc iso-transl tooltip cconv eldoc paren electric uniquify ediff-hook
vc-hooks lisp-float-type elisp-mode 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 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 xwidget-internal dbusbind inotify lcms2 dynamic-setting
system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit
xinput2 x multi-tty make-network-process native-compile emacs)

Memory information:
((conses 16 150387 10063)
  (symbols 48 11460 0)
  (strings 32 32439 3583)
  (string-bytes 1 1406757)
  (vectors 16 19041)
  (vector-slots 8 386441 14177)
  (floats 8 38 102)
  (intervals 56 7894 0)
  (buffers 984 13))