emacs-devel
[Top][All Lists]
Advanced

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

Re: Collecting markers with MPS


From: Eli Zaretskii
Subject: Re: Collecting markers with MPS
Date: Wed, 24 Apr 2024 18:54:07 +0300

> From: Helmut Eller <eller.helmut@gmail.com>
> Cc: gerd.moellmann@gmail.com,  emacs-devel@gnu.org
> Date: Wed, 24 Apr 2024 17:03:10 +0200
> 
> On Wed, Apr 24 2024, Eli Zaretskii wrote:
> 
> >> And I was hoping you would say: "We don't need to collect markers.  It's
> >> a nicety that was easy to do in the old GC.  If it's not easy in the new
> >> GC, leave it out".
> >
> > Can we really do that?  I don't think so, but maybe I'm missing
> > something.
> 
> We don't need it for correctness.  We would unlikely run out of memory.

Are you sure?  Emacs could easily create gobs of markers.  For
example, if there are buffers with lost of non-ASCII characters, each
time we need to compute character position from byte position or vice
versa, we create more markers in the buffer.  In a session that runs
for weeks, there could be a lot of them, I think.

> However, a buffer with an unreasonably long marker-chain will make some
> operations slower.  How much slowness can we accept?  I don't know;
> maybe I should measure this first.

I think we had in the past complaints from Ihor that some buffers with
a lot of markers slowed down things.

> We could also provide functions to manually unlink markers from the
> buffer that programmers could use to keep the slowness in check.

If we can do this manually, we should be able to do it from a timer,
no?

> The MPS supports finalization and weak references.  Finalization could
> tell us which markers are unreferenced.  The problem is that markers
> stay referenced as long as they are part of the buffer's marker-chain or
> the undo-list.
> 
> That's why we could use weak references here.  If a marker is referenced
> only through weak references then MPS can collect it.  MPS will also set
> the weak reference to 0 when the marker has been collected.  So that we
> know when we no longer can/need to update the marker.
> 
> The old GC knows which references are weak; that's what the special code
> there is for.  For MPS, we somehow need to tell it which references are
> weak.

So why did you say this will take much more code than in the old GC?



reply via email to

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