emacs-devel
[Top][All Lists]
Advanced

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

Re: MPS: dangling markers


From: Stefan Monnier
Subject: Re: MPS: dangling markers
Date: Sat, 29 Jun 2024 14:30:36 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

> Can it be that `remove_marker` is called much more often than add_marker?

I don't think you can remove a marker before having added it, so it
seems rather unlikely.

>   igc_add_marker (struct buffer *b, struct Lisp_Marker *m)
>   {
>     Lisp_Object v = BUF_MARKERS (b);
>     if (NILP (v))
>       v = BUF_MARKERS (b) = alloc_vector_weak (1, Qnil);
>
>     ptrdiff_t i = find_nil_index (v);

My guess is that `find_nil_index` almost always scans the buffer until
near the end.  It should be fairly easy to speed that up by keeping
a "pointer" to the last known empty slot, or use the empty slots to
"point to each other" to form a free-list.

Still doesn't explain why `remove_marker` takes more time on your branch
than on `master`, unless we end up keeping significantly larger vectors
than the length of the linked-lists used on `master`.

Maybe it's because `unchain_marker` often exits early (e.g. maybe it's
common that `unchain_marker` is used to delete a marker recently added,
so it's near the top of the linked list which ends up behaving a bit
like a stack)?


        Stefan




reply via email to

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