emacs-devel
[Top][All Lists]
Advanced

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

Re: Debouncing slow mode line constructs (was: Emacs design and architec


From: Dmitry Gutov
Subject: Re: Debouncing slow mode line constructs (was: Emacs design and architecture. How about copy-on-write?)
Date: Fri, 22 Sep 2023 15:52:32 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

On 22/09/2023 13:23, Ihor Radchenko wrote:
What I have in mind is the following:

1. Every time Emacs processes :eval construct it (a) measures the time
    taken; (b) caches return value.
    The total mode line render time is also recorded.

2. If the total render time exceeds configurable threshold, processing
    the most time-consuming :eval constructs will be suspended until
    "debounce" time since the last full processing.

    By "suspended", I mean that cached :eval value is reused instead of
    invoking :eval again. Possibly, not reused verbatim, but by replacing
    the cached value with some kind of placeholder that has the same
    total height/width as the cached value.

    For example, consider :eval segment invoking external git command and
    producing branch name: "⛬ master".
    If that command takes too long, Emacs will display
    "⏳       " instead of
    "⛬ master", until the mode-line redisplay that is some fixed time
    ahead.

3. After "debounce" time since the last "suspend", all the :eval are
    processed in full again, generating up-to-date mode-line.

I think it can be worth a try, although this general thing sounds easier to do (in a different way) with parallel rendering of buffers/mode-lines/etc. If we ever get to that, of course.

In terms of values, I am thinking something like 0.2 sec for threshold
and 1.0 sec for debounce. This way, mode line will be outdated no longer
than 1 second.

FWIW, the "slow" mode-lines I had tried in the past were still much faster than the above.



reply via email to

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