emacs-devel
[Top][All Lists]
Advanced

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

Re: Scrolling commands and skipping redisplay, was: Re: emacs rendering


From: Dmitry Gutov
Subject: Re: Scrolling commands and skipping redisplay, was: Re: emacs rendering comparisson between emacs23 and emacs26.3
Date: Sat, 25 Apr 2020 03:21:34 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1

Hi Eli,

On 24.04.2020 12:51, Eli Zaretskii wrote:

Do scrolling commands and/or code that calls posn-at-point do anything
else common with redisplay other than fontification functions?

"Common" is too general a word to give an intelligent and helpful
answer to your question.  I have no other way except explaining a lot
of how relevant parts of the display engine work (below), or else we
will be forever trapped in misunderstandings.  (I do suggest to read
the commentary and the code in xdisp.c, to facilitate better
communications.  It takes time and non-trivial effort to write these
descriptions.)

Thank you for the explanation. I see you also updated the commentary. The people who will come after will surely benefit.

I hope you can now figure out the answer to your question about the
"common" parts.

I think so, and the answer is "no". That means performance revolution will have to wait. But this was seriously educational.

If *that* work (together with fontification) is usually what takes the
most time during redisplay

This remains to be shown.  Someoneā„¢ should profile redisplay in
relevant use cases and present the profiles, then we could decide
whether this is or isn't the case.  Personally, I think it's roughly
40%-60% or 30%-70%, with the actual redisplay being the larger part.
But humans are notoriously bad in guessing this stuff, so I won't be
surprised if mine turns out to be wrong.

Indeed.

there could be some simple cache added on to of it, which would make
skipping redisplay unnecessary in cases when the command would
pre-fill such cache.

I have my doubts that it will turn out to be simple.  Besides my
humble experience of hacking the display code, I have a much more
significant evidence: that such a cache was not implemented when the
current display engine was developed for Emacs 21.  Gerd Moellmann is
an extremely capable and talented programmer, and most of the work he
did on the display engine during Emacs 21 development was precisely to
make it fast enough.  All the redisplay optimizations we have now were
designed and implemented for that purpose, because without them
redisplay was unbearably slow on the machines we had at that time.  At
some point Gerd wrote that he implemented these optimizations one by
one, until he got satisfactory redisplay speed.  If there was a simple
way of caching more data to speed this up, I have no doubt we'd have
that already.

But 20 years have passed now, and I imagine the complexity of building a glyph matrix and then rendering it couldn't have changed much (maybe proportional to the screen resolutions). The font-lock rules have most likely became more complex in the meantime (meaning, fontification is possible always the slowest part by far). So actually giving up on some optimizations (such as skipping redisplay) might keep Emacs about the same in terms of performance on modern machines, yet improve responsiveness in those cases when it can't keep up with input.

But it's a difficult argument to make given we must have some users with 20-years old machines still. And while our developers compile with optimizations disabled (the current master might help improve on this).

Seems I should look into throttling repeated keyboard input when redisplay can't keep up instead after all. In theory, it should give about the same increase in responsiveness in the scenarios we've been discussing here.



reply via email to

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