unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: emacs-devel@gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>
Cc: eggert@cs.ucla.edu, dmantipov@yandex.ru
Subject: Re: Long lines and bidi
Date: Mon, 11 Feb 2013 19:17:28 +0200	[thread overview]
Message-ID: <83bobq6a8n.fsf@gnu.org> (raw)
In-Reply-To: <83r4ko5cpv.fsf@gnu.org>

> Date: Sun, 10 Feb 2013 18:57:00 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: emacs-devel@gnu.org
> 
> I just committed to the trunk revision 111724 with a couple of simple
> changes which speed up by a factor of 3 some redisplay operations,
> such as M-v or M->, in a buffer with very long lines.  Please try it.

Further measurements indicate that the bottleneck is in searches for
previous or next newline, or N-th previous/next newline.  These
searches are at the core of functions that compute pixel dimensions of
buffer text, when the display engine needs to figure out where to
start displaying the window after scrolling, or where to put point
after C-p or C-n.

As a typical example, a C-n in a buffer with truncate-lines set
non-nil requires us to find the next physical line in the buffer,
i.e. the next newline.  We currently do that by searching forward in
the buffer, one byte at a time, until we find a newline.  If lines are
very long, this is expensive.

When truncate-lines is nil, this problem doesn't exist for C-n, but a
similar problem exists for C-p: we need to find the _previous_
newline (which is many characters back when lines are long), and then
scan forward until we find a character that is displayed one screen
line above the one we were at when the user typed C-p.  Revision
111724 makes sure we don't go back more than one physical line, unless
really needed, but given the current design of the code, one full line
is the absolute minimum.

Turning on the newline cache speeds up these searches for a newline by
a factor of 2, which is not too spectacular, but not negligible.  Any
objections to turning on that caching by default in all buffers?

Beyond that, either we can find a much more efficient way of finding
the next or previous newline, or we will need a complete redesign and
re-implementation of the move_it_* family of functions, which is used
a lot by the display engine.



  parent reply	other threads:[~2013-02-11 17:17 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <877gmp5a04.fsf@ed.ac.uk>
     [not found] ` <83vca89izh.fsf@gnu.org>
     [not found]   ` <5110906D.7020406@yandex.ru>
     [not found]     ` <83fw1aac3d.fsf@gnu.org>
     [not found]       ` <51120360.4060104@yandex.ru>
     [not found]         ` <jwvehgtfrd6.fsf-monnier+emacs@gnu.org>
     [not found]           ` <51127363.5030203@yandex.ru>
     [not found]             ` <834nhp9u9j.fsf@gnu.org>
2013-02-08 13:33               ` Long lines and bidi [Was: Re: bug#13623: ...] Dmitry Antipov
2013-02-08 14:07                 ` Eli Zaretskii
2013-02-08 14:46                   ` Long lines and bidi Eli Zaretskii
2013-02-08 16:38                     ` Dmitry Antipov
2013-02-08 16:52                       ` Eli Zaretskii
2013-02-09  3:34                         ` Paul Eggert
2013-02-09  8:46                           ` Eli Zaretskii
2013-02-09  9:05                             ` Paul Eggert
2013-02-09  9:33                               ` Eli Zaretskii
2013-02-11  2:33                                 ` Paul Eggert
2013-02-09 10:01                               ` Eli Zaretskii
2013-02-10 16:57                                 ` Eli Zaretskii
2013-02-11  5:43                                   ` Dmitry Antipov
2013-02-11  7:54                                     ` Dmitry Antipov
2013-02-11 16:47                                       ` Eli Zaretskii
2013-02-11 23:55                                         ` Paul Eggert
2013-02-11 16:42                                     ` Eli Zaretskii
2013-02-11 17:53                                       ` Dmitry Antipov
2013-02-11 18:10                                         ` Eli Zaretskii
2013-02-11 18:21                                           ` Dmitry Antipov
2013-02-11 17:17                                   ` Eli Zaretskii [this message]
2013-02-11 17:55                                     ` Drew Adams
2013-02-11 18:13                                       ` Eli Zaretskii
2013-02-08 16:21                   ` Long lines and bidi [Was: Re: bug#13623: ...] Dmitry Antipov
2013-02-08 17:04                     ` Eli Zaretskii
2013-02-08 15:33                 ` Stefan Monnier
2013-02-08 16:05                   ` 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=83bobq6a8n.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=dmantipov@yandex.ru \
    --cc=eggert@cs.ucla.edu \
    --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).