emacs-devel
[Top][All Lists]
Advanced

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

Re: Inefficient redisplay


From: Eli Zaretskii
Subject: Re: Inefficient redisplay
Date: Tue, 13 Apr 2010 23:05:02 +0300

> From: Stefan Monnier <address@hidden>
> Cc: address@hidden
> 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 via email to

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