unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Aaron Jensen <aaronjensen@gmail.com>
Cc: 30457@debbugs.gnu.org
Subject: bug#30457: 26.0.91; bidi-display-reordering makes navigation around melpa/archive-contents slow
Date: Thu, 15 Feb 2018 23:47:26 +0200	[thread overview]
Message-ID: <83sha2udqp.fsf@gnu.org> (raw)
In-Reply-To: <CAHyO48zd=iAc80uOwBJx2yD-sDNdmyO9hhny1nxhc0fxRyjAnw@mail.gmail.com> (message from Aaron Jensen on Thu, 15 Feb 2018 10:49:23 -0800)

> From: Aaron Jensen <aaronjensen@gmail.com>
> Date: Thu, 15 Feb 2018 10:49:23 -0800
> Cc: 30457@debbugs.gnu.org
> 
> > It isn't WONTFIX, I just don't know how to make the BPA implementation
> > faster with such long lines and deeply nested parentheses.  It already
> > includes all the optimizations I could think of.  But maybe someone
> > else will find a way to optimize it more.
> 
> I'm only just now learning about BPA, so I apologize if this is a
> silly question, but would it be any faster to scan a buffer and
> determine that there are no rtl characters so parentheses matching is
> unnecessary?

Scanning the entire buffer could be faster only for small buffers.
But with a very large buffer we'd be scanning a lot more than needed,
because redisplay tries very hard not to examine much more of the
buffer than is needed to show one window-full.  And due to the way the
display engine is designed, it doesn't lend itself easily to caching
stuff, so you'd need to scan the entire buffer every redisplay cycle,
e.g., after each C-n.

The current code in bidi_find_bracket_pairs scans only as much as
needed (which unfortunately could be quite a lot for deeply nested
parens in a long line).  And it already includes an optimization for
strictly left-to-right text inside the parens, something that it
detects as part of the scan.

> > It does, sort of.  At least near the end of the buffer you clearly see
> > that bidi-display-reordering has a much smaller effect, in relative
> > terms.
> 
> Yeah, I wasn't aware that the end of the buffer had more slowness, but
> that's good to know.

The farther you are from the beginning of line, the more buffer
positions Emacs needs to scan to determine where to put point after
C-n or C-p.  That's because the layout calculations needed for
determining coordinates of each buffer position must start from some
known anchor, and currently the only anchor is the line beginning,
where we sure the X coordinate is zero.  So Emacs needs to go back to
the line beginning (something it can do very fast), and then come back
(much slower) one character at a time, until it hits the buffer
position with the right coordinate.  That coming back is the main
reason why doing this near the end of the line is so much slower than
near the beginning.





  reply	other threads:[~2018-02-15 21:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14 16:49 bug#30457: 26.0.91; bidi-display-reordering makes navigation around melpa/archive-contents slow Aaron Jensen
2018-02-14 18:40 ` Eli Zaretskii
2018-02-14 19:22   ` Aaron Jensen
2018-02-14 19:51     ` Eli Zaretskii
2018-02-15 18:49       ` Aaron Jensen
2018-02-15 21:47         ` Eli Zaretskii [this message]
2018-02-15  1:48     ` Noam Postavsky
2018-02-15  3:07       ` Aaron Jensen

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=83sha2udqp.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=30457@debbugs.gnu.org \
    --cc=aaronjensen@gmail.com \
    /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).