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

From: Eli Zaretskii <[email-masked]>
Date: Sat, 23 Jul 2022 10:12:07 +0300

> From: Gerd Möllmann <[email-masked]>
> Cc: Gregory Heytings <[email-masked]>,  [email-masked],  Stefan
>  Monnier <[email-masked]>
> Date: Sat, 23 Jul 2022 09:07:53 +0200
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> > on long-line.xml produces a 15-fold slowdown with font-lock turned on
> > as compared to its being turned off (203 sec vs 13 sec).
> >
> > This is an unoptimized build, so you will probably see times that are
> > 4 times faster, but I'd be interested in the relative times on your
> > system.  Any explanations of the slowdown are also welcome.
> 
> MacOS 12.5, M1 chip
> Head: 792734a6e2cd5558debc8d9fe95d34cb3e809fa4 Improve efficiency of DND
> tooltip movement
> ./configure --with-native-compilation
> 
> The long-lines.xml is 313295 bytes.  Hope that's the right one.
> 
> Font-lock       Output
> ------------------------------------------------------------
> on              GCs: 14 Elapsed time: 7.880788 seconds
> off             GCs: 2 Elapsed time: 0.885791 seconds

Thanks.  This is still an order-of-magnitude slowdown, so the question
about the reasons is still relevant.

One thing we do under font-lock is merging faces, but that's supposed
to be very fast nowadays, given that faces are kept in a hash-table.
And what jit-lock does when the text is already fontified should be
negligible, right?