Subject: bug#49127: Performance degradation in encode_coding_object

From: Mattias Engdegård <[email-masked]>
Date: Wed, 18 Aug 2021 13:04:12 +0200

17 aug. 2021 kl. 19.16 skrev Eli Zaretskii <[email-masked]>:

> It's a problem to have many markers in a buffer.  Not only for code
> that searches them linearly, but also for stuff like converting
> between character and byte positions, something that we do a lot in
> the most inner loops of our code.  Lisp programs that produce gobs of
> markers should be ideally redesigned not to do so.

I agree; the haskell-mode usage was misguided in this respect. Marker-intensive modes could still be justified occasionally: consider an index of all definitions and uses of each variable, function and type in a program, produced by an expensive compilation that cannot be re-run for each little change. This could easily amount to thousands of markers in a big file.

>  Unless we change
> the way we store markers to make that a non-issue.

We probably should but I agree that marker reduction should be the first remedy to try.
Improving the GC so that it's cheaper to run frequent collections would also help in the common case where most markers are dead (as in this case).