unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: Inefficient redisplay
Date: Tue, 13 Apr 2010 23:05:02 +0300	[thread overview]
Message-ID: <83hbnfxgnl.fsf@gnu.org> (raw)
In-Reply-To: <jwv39z0qrhw.fsf-monnier+emacs@gnu.org>

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: emacs-devel@gnu.org
> Date: Mon, 12 Apr 2010 17:46:21 -0400
> 
> > Also, what _is_ the problem, exactly?  Is that only that jit-lock
> > misbehaves, or is there something else?  You said in your original
> > mail that "redisplay code somehow seems to treat nhexl-mode's buffers
> > as one single long-line", but what are the symptoms of this?
> 
> Several problems:
> 1- it seems that I'm not able to have position N displayed without
>    having all positions 1..N with fontified set to non-nil (I.e. I have
>    to have all the prefix of the buffer fontified).  That's a major
>    problem since I use overlays: if N is large, that implies a large
>    number of overlays, which implies serious performance problems.
> 2- performance sucks.  Maybe it's because of 1, but it's probably not
>    only due to that, because performance is better when I go back to the
>    beginning of the buffer (which doesn't remove overlays).

I'm not sure I see the root cause yet, or even the most expensive
part, but one thing seems to be quite clear: the way you move overlays
disables quite a few of redisplay optimizations.  For example, if I
just move cursor, in a normal buffer redisplay calls
try_cursor_movement, and that's it.  But in a buffer under nhexl-mode,
try_cursor_movement is not even called because of this condition:

  current_matrix_up_to_date_p
    = (!NILP (w->window_end_valid)
       && !current_buffer->clip_changed
       && !current_buffer->prevent_redisplay_optimizations_p
       && XFASTINT (w->last_modified) >= MODIFF
       && XFASTINT (w->last_overlay_modified) >= OVERLAY_MODIFF);

It seems like the games you play in post-command-hook constantly
increment OVERLAY_MODIFF, and that prevents this optimization.
Instead, redisplay invokes try_window_id, which promptly gives up
here:

  if (current_buffer->clip_changed
      || current_buffer->prevent_redisplay_optimizations_p)
    GIVE_UP (3);

because someone turned on the prevent_redisplay_optimizations_p flag
(I don't yet know why).  Then try_window is called, which is much
heavier, and it does the job.  This happens for every cursor movement!

Why do you need to modify overlays in a post-command-hook?  That seems
to be at least part of the trouble.




  reply	other threads:[~2010-04-13 20:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-12  4:34 Inefficient redisplay Stefan Monnier
2010-04-12 17:17 ` Eli Zaretskii
2010-04-12 19:28   ` Stefan Monnier
2010-04-12 20:53     ` Eli Zaretskii
2010-04-12 21:46       ` Stefan Monnier
2010-04-13 20:05         ` Eli Zaretskii [this message]
2010-04-14 18:13         ` Eli Zaretskii
2010-04-15  4:38           ` Stefan Monnier
2010-04-15 11:05             ` Eli Zaretskii
2010-04-15 17:34               ` Stefan Monnier

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=83hbnfxgnl.fsf@gnu.org \
    --to=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).