Subject: bug#62352: Very slow scroll-down-line with a lot of text properties

From: Eli Zaretskii <[email-masked]>
Date: Tue, 21 Mar 2023 22:26:01 +0200

> Date: Tue, 21 Mar 2023 21:01:58 +0100
> From: "Herman, Geza" <[email-masked]>
> 
> Emacs can freeze for seconds when scroll-down-line is called multiple 
> times if the buffer contains a lot of text properties.

Not any text properties: 'face' text properties.  Right?

> 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 general, any change in faces causes the display iterator to stop
and load the new face, before it continues.  They also cause drawing
on the screen to be in smaller chunks, since each stretch of
characters in the same face is drawn together.  And this example
basically changes to a new face every character.  So this is expected
to display slower than usual.

However, are you saying that this is slower in Emacs 29 than it was in
Emacs 28?  If so, bisection will be appreciated.