bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Stefan Monnier
Subject: bug#56682: Fix the long lines font locking related slowdowns
Date: Tue, 02 Aug 2022 17:32:14 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Gregory Heytings [2022-08-01 11:23:52] wrote:

>>> 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:

Hmmm was that using the GNU ELPA `json-mode` package?
If so, then indeed there's no `syntax-propertize-function` setup there
and `syntax-ppss` should be ideally not much slower than
`parse-partial-sexp`.

> 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 be right.
But there are still significant differences between different major modes:

    LISP> (benchmark-run 1 (fundamental-mode) (parse-partial-sexp (point-min) 
(point-max)))
    (0.276774213 0 0.0)
    
    LISP> (benchmark-run 1 (fundamental-mode) (syntax-ppss (point-max)))
    (0.329234636 0 0.0)
    
    ELISP> (benchmark-run 1 (emacs-lisp-mode) (syntax-ppss (point-max)))
    (0.392759479 0 0.0)
    
    ELISP> (benchmark-run 1 (js-mode) (syntax-ppss (point-max)))
    (1.036089104 7 0.20054423700000001)
    
    ELISP> (benchmark-run 1 (nxml-mode) (syntax-ppss (point-max)))
    (1.169055192 7 0.15886504199999996)
    
    ELISP> (benchmark-run 1 (cperl-mode) (syntax-ppss (point-max)))
    (1.857638439 9 0.19724271499999996)

(this was in a 5MB buffer).


        Stefan






reply via email to

[Prev in Thread] Current Thread [Next in Thread]