unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: dmantipov@yandex.ru, emacs-devel@gnu.org
Subject: Re: Long lines and bidi
Date: Sat, 09 Feb 2013 12:01:46 +0200	[thread overview]
Message-ID: <83mwvd7qlx.fsf@gnu.org> (raw)
In-Reply-To: <5116113D.5070707@cs.ucla.edu>

> Date: Sat, 09 Feb 2013 01:05:01 -0800
> From: Paul Eggert <eggert@cs.ucla.edu>
> CC: dmantipov@yandex.ru, emacs-devel@gnu.org
> 
> On 02/09/2013 12:46 AM, Eli Zaretskii wrote:
> 
> > 25% faster is still terribly slow for redisplay.
> 
> Yes, as I said, it doesn't solve the performance problem.
> Still, it doesn't complicate the code, and it significantly
> improves speed in code likely to be executed often, so it
> seems worth doing in its own right.

I suspect that the use case that makes scan_buffer so high on the
profile is very much skewed.  My crystal ball says that the file in
question was one very long paragraph, or at least had many-many
_thousands_ of lines between empty lines that delimit paragraphs.
scan_buffer is high on the profile because the bidi.c code tries to
find the beginning of a paragraph, which determines the base direction
of the paragraph, which in turn determines how the text should be
reordered for display.

By contrast, most real-life files have much less text between empty
lines, so scan_buffer will not be at any prominent place in the
profile.  But redisplay of a buffer with very long lines will still be
awfully slow, even if there's an empty line between every 2 long
lines, although scan_buffer will no longer be a factor.

OTOH, if you create a file with a single long paragraph, but whose
lines have "normal" width, like 100 characters, redisplay will perform
adequately, even though scan_buffer will be heavily used.  (It would
be interesting to see a profile for that, btw.)

IOW, the solution in bidi.c for extremely long paragraphs is optimized
for the 99% of use cases, where lines are not too long, i.e. for those
cases where the old unidirectional display engine gave reasonable
performance.  Dmitry's use case, OTOH, is skewed on several counts:

 . it uses extremely long lines
 . it uses too many neutral/weak characters
 . it uses extremely long paragraphs

This simultaneously hits on several unrelated weaknesses of the
current display engine, with the result that the profile is a
combination of at least 3 different reasons for slow-down, which makes
it very hard to analyze the results and look for solutions.

That is why I think we should attack this problem one reason at a
time.  The most important reason is the first one: long lines cause
the display code traverse too much of buffer text.  This is why you
see x_produce_glyphs so high on the profile in the unidirectional
case: it examines too many characters, much more than what will be
actually displayed on the screen.  Solve this problem, and the 2nd one
will simply disappear without a trace, because it is at least linear
in the number of scanned characters.  If the 3rd problem is still a
factor, after the 1st one is gone, we can tune the current
optimization at that time.



  parent reply	other threads:[~2013-02-09 10:01 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 [this message]
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
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=83mwvd7qlx.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=dmantipov@yandex.ru \
    --cc=eggert@cs.ucla.edu \
    --cc=emacs-devel@gnu.org \
    /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).