unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
Subject: Re: Unfreezing the display during auto-repeated scrolling.
Date: Sun, 26 Oct 2014 22:15:30 +0000	[thread overview]
Message-ID: <20141026221530.GF4397@acm.acm> (raw)
In-Reply-To: <jwvmw8iin9i.fsf-monnier+emacs@gnu.org>

Hello, Stefan.

On Sun, Oct 26, 2014 at 04:42:38PM -0400, Stefan Monnier wrote:
> I'm not sure exactly what to think here.

> I think it is very desirable to try and come up with ways to speed up
> redisplay in cases such as auto-repeated scrolling.

> It seems that Alan's patch has a fairly small impact on the C code (in
> terms of its structure, not necessarily in terms of the end result),
> which is good.

> But even better would be something that has no impact at all on the
> C code.  Of course, I'm biased: I hacked my own defer-lock.el before
> Simon Marshall published his.

> So, I'd be in favor of trying to solve this at the Elisp level, ...

I don't think this is possible.  At least some minimal, finicky changes
will be needed where xdisp.c calls fontification functions.  (See below).

> ... i.e. inside jit-lock.  I think the result might even be better than
> Alan's patch because it should let Emacs keep up with scrolling much
> more easily (tho displaying un-font-locked content while scrolling).

The problem is, _every_ scroll operation into unfontified territory is
calling Fvertical_motion (or worse in the GUI case).  Fvertical_motion
calls start_display calls init_iterator calls reseat calls handle_stop
calls handle_fontified_prop.

At this stage, _nothing_ can stop handle_fontified_prop running
fontification-functions causing the fontification of >=
jit-lock-chunk-size (500) bytes.  Well, my patch stopped this, but
nothing else currently in the system can.

500+ bytes is about a fifth of the 2500 bytes which fit on my 65 line
screen, so fontifying them is going to take ~.017s (see other email
threads for details of these measurements).  My auto-repeat repeat rate
is every 0.024s, leaving 0.007s for other processing if Emacs is going to
keep up.  It can't; 0.007s isn't enough.

The above fontification is happening on _every_ scroll operation, even
though the fontified text is never going to appear on the screen.  The
sole purpose of this fontification is to work out how big (in pixels)
characters are.  And this is in the tty case.

The display code has been optimised for variable sized characters, and
all possibilities of optimising for the very common case of uniform
sized characters has been thrown out the window.  My patch was a way for
a user, in effect, to tell Emacs that his characters are all the same
size.

Something's got to give.

Maybe Eli's suggestion of rewriting scroll-up and scroll-down from
scratch in Elisp could work, but if I'm not mistaken, there's no
infrastructural support for window lines, etc., which doesn't involve
fontification.  This would have to be written.

If movement on a window absolutely requires fontified characters, then
some means will need to be found for the display code to tell jit-lock
HOW MUCH needs fontifying, and for that amount to be much less than 500
bytes in the non-display case.

> What I suggest is to refine jit-lock-defer such that jit-lock is
> deferred if there's input pending.

> I understand there's an underlying problem here, which is that "input
> pending" is something that's not tested reliably.  Maybe we will need to
> try and fix this as well.

As already pointed out, even one jit-lock-chunk-size fontification per
0.024s in C Mode is going to overfill the event queue, and that's with
nothing actually being drawn on the screen.

One might hold that it is unreasonable to expect Emacs to keep up with 42
PageDown's per second with a 65 line window on a mere 2.6 Ghz processor.
I disagree.

One might argue that CC Mode fontification should be speeded up.  Yes, it
should, but it's not ever going to be speeded up by an order of
magnitude.  Even in Emacs Lisp Mode, fontifying and displaying a 65 line
screen averages out at 0.018s, compared with a 0.024s repeat rate.
There's simply no spare processing capacity for frivolous
jit-lock-chunk-size'd fontifications.

Something's got to give.

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).



  reply	other threads:[~2014-10-26 22:15 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-19 14:17 Aborting display. Is this possible? Alan Mackenzie
2014-10-19 14:32 ` David Kastrup
2014-10-19 14:54   ` Eli Zaretskii
2014-10-19 14:50 ` Eli Zaretskii
2014-10-19 15:42   ` Alan Mackenzie
2014-10-19 18:09     ` Eli Zaretskii
2014-10-20 11:09       ` Alan Mackenzie
2014-10-20 11:30         ` David Kastrup
2014-10-20 12:00           ` Alan Mackenzie
2014-10-20 15:15             ` Eli Zaretskii
2014-10-20 15:12         ` Eli Zaretskii
2014-10-20 16:56           ` Stefan Monnier
2014-10-20 17:10             ` Eli Zaretskii
2014-10-20 17:40               ` Eli Zaretskii
2014-10-20 18:57           ` Alan Mackenzie
2014-10-20 19:24             ` Eli Zaretskii
2014-10-20 21:08               ` Alan Mackenzie
2014-10-21  8:09                 ` David Kastrup
2014-10-21 10:58                   ` Alan Mackenzie
2014-10-21 11:04                     ` David Kastrup
2014-10-21 14:25                       ` Stefan Monnier
2014-10-21 14:01                   ` Stefan Monnier
2014-10-21 15:35                     ` Eli Zaretskii
2014-10-21 16:27                       ` Stefan Monnier
2014-10-22 18:28                         ` Stephen Leake
2014-10-22 20:10                           ` Stefan Monnier
2014-10-21 17:14                       ` Alan Mackenzie
2014-10-21 18:00                         ` Eli Zaretskii
2014-10-21 18:38                           ` Alan Mackenzie
2014-10-21 18:43                             ` Eli Zaretskii
2014-10-21 19:42                               ` Eli Zaretskii
2014-10-26 12:43                             ` Unfreezing the display during auto-repeated scrolling. [ Was: Aborting display. Is this possible? ] Alan Mackenzie
2014-10-26 16:45                               ` Eli Zaretskii
2014-10-26 20:03                                 ` Alan Mackenzie
2014-10-26 20:20                                   ` Eli Zaretskii
2014-10-26 20:42                                   ` Stefan Monnier
2014-10-26 22:15                                     ` Alan Mackenzie [this message]
2014-10-27  1:03                                       ` Unfreezing the display during auto-repeated scrolling Stefan Monnier
2014-10-27 14:28                                         ` Unfreezing the display during auto-repeated scrolling. Simpler approach Alan Mackenzie
2014-10-27 16:51                                           ` Eli Zaretskii
2014-10-27 19:13                                             ` David Engster
2014-10-27 19:26                                               ` Eli Zaretskii
2014-10-27 19:36                                                 ` David Engster
2014-10-27 19:38                                             ` Alan Mackenzie
2014-10-27 21:38                                               ` Stefan Monnier
2014-10-28 18:10                                                 ` Alan Mackenzie
2014-10-29  0:57                                                   ` Stefan Monnier
2014-10-29 14:14                                                     ` Eli Zaretskii
2014-10-29 14:52                                                       ` Alan Mackenzie
2014-10-29 15:37                                                         ` Eli Zaretskii
2014-10-29 16:59                                                         ` Stefan Monnier
2014-10-29 21:25                                                           ` Alan Mackenzie
2014-10-30  1:49                                                             ` Stefan Monnier
2014-10-30 22:09                                                               ` Alan Mackenzie
2014-10-31  3:06                                                                 ` Stefan Monnier
2014-10-31  7:55                                                                   ` Eli Zaretskii
2014-10-31 14:04                                                                     ` Stefan Monnier
2014-11-21 15:44                                                                       ` Alan Mackenzie
2014-11-23  9:51                                                                         ` Tassilo Horn
2014-11-23 10:40                                                                           ` Alan Mackenzie
2014-11-23 19:44                                                                             ` Tassilo Horn
2014-11-23 22:04                                                                               ` Alan Mackenzie
2014-11-24 11:34                                                                                 ` Tassilo Horn
2014-11-24 11:53                                                                                   ` David Kastrup
2014-11-24 16:00                                                                                     ` Alan Mackenzie
2014-11-24 14:37                                                                                 ` Stefan Monnier
2014-11-24 16:08                                                                                   ` Alan Mackenzie
2014-11-24 17:44                                                                                     ` Stefan Monnier
2014-10-27  3:36                                       ` Unfreezing the display during auto-repeated scrolling Eli Zaretskii
2014-10-27 10:05                                         ` Alan Mackenzie
2014-10-27 16:48                                           ` Eli Zaretskii
2014-10-27 22:46                                             ` Alan Mackenzie
2014-10-28  0:22                                               ` Stefan Monnier
2014-10-27  3:33                                     ` Unfreezing the display during auto-repeated scrolling. [ Was: Aborting display. Is this possible? ] Eli Zaretskii
2014-10-21 18:01                         ` Aborting display. Is this possible? Stefan Monnier
2014-10-21 15:40                 ` Eli Zaretskii
2014-10-21 17:00                 ` Michael Welsh Duggan
2014-10-21 18:25                   ` Alan Mackenzie
2014-10-20  1:59     ` Stefan Monnier
2014-10-20  2:45       ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141026221530.GF4397@acm.acm \
    --to=acm@muc.de \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).