Subject: bug#58558: 29.0.50; re-search-forward is slow in some buffers

From: Ihor Radchenko <[email-masked]>
Date: Thu, 06 Apr 2023 11:49:52 +0000

Ihor Radchenko <[email-masked]> writes:

>> Did you try to see how the number of markers in the buffer evolves
>> with the up-time?
>
> Is there any way to get the number of buffer markers from Elisp?

I finally got back to this and implemented a small subr to count
number of buffer markers:

DEFUN ("buffer-markers", Fbuffer_markers, Sbuffer_markers, 0, 0, 0,
       doc: /* Return the number of markers in current buffer.*/)
  (void)
{
  struct Lisp_Marker *tail;
  int count = 0;

  for (tail = BUF_MARKERS (current_buffer); tail; tail  = tail->next)
    count++;

  return make_fixnum (count);
}

Then, I tracked how the number of markers evolves in my problematic
buffer when building agenda. On master and on Emacs 28 (where the agenda
is building 10x faster).

As you can see on the attached graph, the number of markers is ~1000, and
it is not significantly different for the two Emacs versions.

So, the number of markers itself does not look like the real culprit.

I have no better ideas for now except slowly bisecting Emacs (again).

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>