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

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

bug#24048: 25.0.95; syntax-ppss can be slow


From: Aaron Jensen
Subject: bug#24048: 25.0.95; syntax-ppss can be slow
Date: Fri, 30 Mar 2018 06:09:45 -0700

On Mon, Jul 25, 2016 at 8:08 AM, Aaron Jensen <aaronjensen@gmail.com> wrote:
> On Mon, Jul 25, 2016 at 5:42 AM Dmitry Gutov <dgutov@yandex.ru> wrote:
>>
>> Is 5.6ms really significant? You should be typing like 200 characters
>> per _second_ to really notice the difference.
>>
>> Even 12ms that I'm getting at the bottom of your example file doesn't
>> sound like it should have effect on the perceptible latency.
>
> Even if one can’t feel 5.6ms, it becomes another brick in the bag, i.e. if 
> another minor mode did something similar and added another 5.6ms. With enough 
> of them most people could probably feel it.

Hey all, I'm trying to clean up bugs I've submitted. This one is still
an issue of sorts. I've fixed the downstream usage of syntax-ppss by
memoizing it, but that feels like it should be unnecessary given that
syntax-ppss is meant to do its own caching.

The problem here is that syntax-ppss will not update its cache if it
is "close enough" to the old position. In languages like Elixir (and
probably Ruby) the old position is often the beginning of the outer
module which spans most, if not all of the file. This means that the
further you get down the file, the further you get from the old
position and the more work syntax-ppss must do.

If a user of syntax-ppss is not careful (as was the case in
smartparens) then syntax-ppss can be called multiple times in
succession, which can add up to enough latency to be noticed.

Ultimately, it seems like it may be worth reconsidering this condition:

(and old-pos (< (- pos old-pos)
    ;; The time to use syntax-begin-function and
    ;; find PPSS is assumed to be about 2 * distance.
    (* 2 (/ (cdr (aref syntax-ppss-stats 5))
    (1+ (car (aref syntax-ppss-stats 5)))))))

But I do not know what other impacts that may have.

Does anybody have any new thoughts on this?

Thanks!





reply via email to

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