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

From: Gregory Heytings <[email-masked]>
Date: Mon, 01 Aug 2022 11:23:52 +0000

>> The problem is that this is, as I said, slow.  On my laptop, opening a 
>> 1 GB file takes about 6 seconds.  The call to syntax-ppss adds 70 
>> seconds, so opening a large file becomes an order of magnitude slower 
>> (13 times slower).
>
> It's meaningless to talk about the time taken by `syntax-ppss` without 
> specifying the major mode that was in use.
>

It isn't.  The benchmark above was with a JSON file (js-mode), but you'll 
see the same ratio with an Elisp file for example:

for I in $(seq 1 2500); do cat lisp/simple.el; done > complex.el

That file opens in about 5 seconds, and (benchmark-run 1 (syntax-ppss 
(point-max))) takes about 45 seconds.

Sure, there are perhaps modes that are slower, but my tests seem to 
indicate that the 1/10 ratio is correct, or IOW that syntax-ppss is an 
order of magnitude slower than opening the file.

>
> You might also want to compare to the time to run
>
> (parse-partial-sexp (point-min) (point-max))
>
> which is a kind of "speed of light" for `syntax-ppss`.
>

What do you mean?  With the above file (benchmark-run 1 
(parse-partial-sexp (point-min) (point-max))) takes 55 seconds.