Subject: Re: bug#79141: 31.0.50; The tab-bar-format-align-right cache doesn't take face changes and per-frame faces into account

From: Daniel Mendler <[email-masked]>
Date: Tue, 12 Aug 2025 20:40:13 +0200

Steven Allen <[email-masked]> writes:

> Juri Linkov <[email-masked]> writes:
>
>> close 79141 31.0.50
>> quit
>>
>>> I don't have a clear idea what should the proposed modification hook be
>>> used for, so I'm not sure whether we need to expose anything to Lisp.
>>> If you or someone else could describe the proposed use of such a tick,
>>> I could try providing a more useful advice.
>>
>> Since no one has an idea how to use such a tick,
>> I had to revert the last change.
>>
>> Anyone who needs a (possibly unreliable) caching version, it's easy
>> to create a copy of the existing 'tab-bar-format-align-right',
>> add caching to it, and use in 'tab-bar-format'.
>
> I can describe it in this case, at least:
>
> 1. Any time any face attribute is updated, the "tick" would be incremented.
> 2. We'd change `tab-bar--align-right-cache' to be (cached-tick . cached-string).
> 3. When checking the cache, we'd check if (new-tick . new-string) is
>     `equal-including-properties' to (cached-tick . cached-string).

Yes, this is how I understood the proposal.

> IMO, the real question is: where else would/could we use this. Adding a
> new `face-modification-tick' just to support this one cache seems a bit overkill.

Agree. Right now I don't have other good use case in mind, but I
remember that I had some problems with face recomputation in my corfu
and org-modern packages. However the face change tick might be too
rough.

I went back to my own pixel width caching for my system status bar.
Maybe in this scenario the pixel width computation is particularly
expensive since the tab elements to the right of
tab-bar-format-align-right are long. During redisplay dominated loads,
e.g. when doing pixel precise scrolling, the pixel width computation
accounts for 5% or more of the runtime according to the profiler. With
pixel caching the tab bar recomputation disappears from the profile. I
have seen similar issues with expensive mode line elements.

Daniel