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

From: Aaron Jensen <[email-masked]>
Date: Fri, 3 Dec 2021 20:31:50 -0500

On Fri, Dec 3, 2021 at 2:04 PM Stefan Monnier <[email-masked]> wrote:
>
> > In certain situations, the caching of syntax-ppss can seem to be
> > insufficient for good performance when syntax-ppss is invoked in
> > a tight loop.
>
> Yes, that's a known limitation.  Most uses of `syntax-ppss` that need to
> call it in a tight loop move the call outside of the loop and then use
> `parse-partial-sexp` inside the loop (and they're careful to move
> forward so `parse-partial-sexp` is only called between the last
> position and the current one so we avoid re-parsing the same text).
>
> Currently `syntax-ppss` assumes that parsing <2500 chars is "fast
> enough" and hence that it's better not to update the "last ppss data"
> when this happens (the advantage is that we save time not-updating the
> data and we also save time if the next call is somewhere within those
> <2500 chars).

Copy that, thanks for the explanation. I'm not presently affected by
this (no smartparens and no elixir) so I'd be happy to close this
given that it's working as expected and there are clear ways to avoid
it in many cases.

Thanks,

Aaron