Subject: bug#77224: [PATCH] New minor mode 'cursor-indicators-mode'

From: Ship Mints <[email-masked]>
Date: Fri, 28 Mar 2025 12:02:11 -0400

On Fri, Mar 28, 2025 at 11:41 AM Daniel Mendler via Bug reports for GNU
Emacs, the Swiss army knife of text editors <[email-masked]> wrote:

> Eli Zaretskii <[email-masked]> writes:
>
> >> From: Daniel Mendler <[email-masked]>
> >> Cc: [email-masked],  [email-masked],  [email-masked]
> >> Date: Thu, 27 Mar 2025 21:17:25 +0100
> >>
> >> Here we discuss changing only the color of the cursor, a much much less
> >> complex operation.
> >
> > My point is that when the list on post-command-hook is long, it takes
> > Emacs time to process all the functions on the list, and the longer
> > the list, the less responsive Emacs will be.  These small
> > insignificant delays add up.
>
> I see your point. But not only the length of the list but also the
> weight of the specific hook functions matters. A handful of
> insignificant delays add up, but will still stay insignificant. There
> are not that many hooks installed in the PCH list (see my list below).
> In the reports where users complain about slow Emacs, it seems more
> likely that one bad hook outweighs all the others.
>
> > How long is the post-command-hook list in your production sessions?
> > Should we poll users to give their data?  Just yesterday someone
> > complained on Reddit that Emacs is too slow, and I have no doubt that
> > features that use post-command-hook are at least part of the reason if
> > not _the_ reason.
>
> Indeed. PCHs are a common reason for slow down. Even worse are functions
> which run during redisplay. Heavy custom mode lines seem to be the main
> problem here.
>
> My `post-command-hook' list looks like this:
>
> Buffer-local:
> (jit-lock--antiblink-post-command eldoc-schedule-timer
>  corfu--auto-post-command jinx--reschedule
>  whitespace-post-command-hook hl-line-highlight t)
>
> Global:
> (ibuffer-auto-update-changed repeat-post-hook)
>
> I don't have any problems with these hooks, since they are either cheap
> or only schedule some timers for more expensive operations. At least I
> don't notice any sluggishness and the PCHs don't appear in profiles.
>

I have experienced issues in the past with PCH entries and cleaned it all
up ages ago and try to keep an eye on it.  One culprit was the pyvenv
tracker which I rewrote a private copy of to use a different method that
achieves the same effect with less overhead.

Out of both curiosity and to butt in on this discussion, I posted this
casual survey on reddit
https://www.reddit.com/r/emacs/comments/1jlyek0/show_your_postcommandhook_contents_to_help_emacs/

Perhaps we'll see that the bulk of people's PCH is the usual
well-performing suspects.  I posted mine.

-Stephane