Subject: Re: bug#76538: 31.0.50; 31.0.50; 31.0.50; feature/igc: using magit-section-cycle-global (S-TAB) and magit-section-toggle (TAB) in some random ways blocks GNU Emacs.

From: Ihor Radchenko <[email-masked]>
Date: Wed, 26 Feb 2025 20:09:45 +0000

Stefan Monnier <[email-masked]> writes:

> FWIW, I have a branch `scratch/markers-as-gap-array` where I replace the
> linked list of markers with an "array with a gap" where markers are
> sorted, so we use a binary search.  It might help in your case.

Maybe not on feature/igc (this bug is about igc). It made changes to the
way markers are stored in buffer and your branch might need to be
adapted to work with the branch.

> It was pretty close to be "ready to merge" at some point, except that
> I had trouble convincing myself that it was a clear win: in my tests, it
> made `save-excursion` slower (the current naïve data-structure is ideal
> for most "trivial" uses of `save-excursion`: we create a marker,
> push it onto the head of the list, do a bit of unrelated work in the
> body and then come back and just pop the marker that's still at the head
> of the list) and the cases where it makes the code faster are hard to
> come by, other than artificial micro-benchmarks.

FYI, feature/igc is also using an array for markers. So, your approach
might not be as bad here.

> Indeed those cache-markers are referenced only weakly so they currently
> disappear at every GC.  I can't remember if I kept this behavior in my
> branch, but I remember considering some alternative where we keep every
> other weak marker.

It may or may not be the case on feature/igc. I think it remains to be
the case, and, unlike master, GC on feature/igc may happen at arbitrary
time rather than at specific code points. So, it may clear the cache in
the middle of the search (AFAIU).

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
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>