Subject: bug#56682: Fix the long lines font locking related slowdowns

From: Eli Zaretskii <[email-masked]>
Date: Tue, 02 Aug 2022 18:46:52 +0300

> Date: Tue, 2 Aug 2022 17:10:53 +0300
> Cc: [email-masked], [email-masked], [email-masked]
> From: Dmitry Gutov <[email-masked]>
> 
> On 02.08.2022 05:27, Eli Zaretskii wrote:
> >> syntax-ppss cache is a list of checkpoints spread along the buffer.
> >>
> >> After a modification, only the checkpoints below it are invalidated (to
> >> be recomputed on-demand later).
> > So a suitably-concocted replace command will still invalidate a lot of
> > that cache, right?
> 
> For any cache, one can invent an operation that would result in 
> thrashing it repeatedly.

Yes, but when thrashing causes delays of dozens of seconds, the result
is not just a rare delay, the result is simply unacceptable.

> A regular search-replace should work well enough, though. Because when 
> the buffer is long, the user is likely, on average, to spend a lot more 
> time examining the occurrences and deciding whether to replace each one. 
> And since the operation goes from top to bottom, this will likely 
> invalidate the list of caches once, and then rebuild it from the 
> beginning (or from wherever the first replacement was).

We want every basic operation in such buffers to perform reasonably
well.  That's the goal of this activity.  Because partial solutions
that sometimes work we already have: there's so-long-mode, there's
longlines.el, and a couple of other trick up our sleeve.