From: Robert Pluim <rpluim@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: psainty@orcon.net.nz, pieter@vanoostrum.org, 38407@debbugs.gnu.org
Subject: bug#38407: 27.0.50; infinite loop with display of large file without newlines
Date: Thu, 05 Dec 2019 08:27:00 +0100 [thread overview]
Message-ID: <m21rtjnsfv.fsf@gmail.com> (raw)
In-Reply-To: <83zhg8hz6j.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 04 Dec 2019 17:45:40 +0200")
>>>>> On Wed, 04 Dec 2019 17:45:40 +0200, Eli Zaretskii <eliz@gnu.org> said:
>> Thread 1 "emacs" hit Breakpoint 3, bidi_shelve_cache () at bidi.c:981
>> 981 alloc = (bidi_shelve_header_size
>> $25 = 30860
>> $26 = 71842080
>>
>> which means Emacs is copying 70MB of data every time bidi_shelve_cache
>> is called, and itʼs called *a lot* in this scenario. Could we not do
>> this shelving by pointer-swapping or similar rather than copying?
Eli> Not sure I understand what kind of pointer-swapping you had in mind.
Eli> We don't swap between 2 buffers here, we save away a snapshot of the
Eli> iterator state each time we see a character where a line break can be
Eli> made, so that we could restore that state when we exhaust the window's
Eli> width. We must restore the iterator state to continue to the next
Eli> visual line, and the bidi cache is an integral part of that state.
Yes, I hadn't realized you needed to keep a copy of the data.
Eli> We could perhaps lower the cache size limit (see
Eli> BIDI_CACHE_MAX_ELTS_PER_SLOT in bidi.c), which would then
Eli> proportionally decrease the time for making a copy of the
Eli> cache.
I tried various values of that down to 5000, it improved matters by a
factor of 8 or so, but the resulting Emacs was still pretty laggy
(with visual-line-mode enabled).
Eli> Or
Eli> we could make some non-trivial changes in the logic of
Eli> move_it_in_display_line_to (and similar changes in display_line) to
Eli> detect when the cache becomes too large, and use a backup algorithm
Eli> that doesn't copy it. But I question the utility of such changes:
Eli> they will never get us a speedup like bidi-inhibit-bpa does, and for
Eli> the relatively rare use case like this one (extremely long lines in a
Eli> JSON file, with some bracketed parts containing R2L text, and the user
Eli> activating visual-line-mode on top of that) inhibiting the BPA,
Eli> whether via so-long or by the user or some other Lisp, sounds like an
Eli> okay solution to me. If the JSON file has long lines, but no R2L
Eli> text, we already have an optimization in bidi.c to avoid having a
Eli> large cache; and if visual-line-mode is off, the cache doesn't need to
Eli> be copied so frequently. So only the combination of the two causes
Eli> this tremendous slowdown, and bidi-inhibit-bpa solves it better than
Eli> any alternative. WDYT?
That sounds reasonable. I see global-so-long-mode is off by default,
do we want to enable it by default? It seems a dis-service to users to
make them have to find out about it by themselves.
Robert
next prev parent reply other threads:[~2019-12-05 7:27 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-27 21:52 bug#38407: 27.0.50; infinite loop with display of large file without newlines Pieter van Oostrum
2019-11-27 23:38 ` Phil Sainty
2019-11-28 0:30 ` Phil Sainty
2019-11-28 1:22 ` Phil Sainty
2019-11-28 6:51 ` Pieter van Oostrum
2019-11-28 15:14 ` Eli Zaretskii
2019-11-28 18:30 ` Pieter van Oostrum
2019-11-28 18:53 ` Eli Zaretskii
2019-11-28 22:09 ` Pieter van Oostrum
2019-11-29 7:12 ` Eli Zaretskii
2019-11-29 11:48 ` Phil Sainty
2019-11-29 13:20 ` Eli Zaretskii
2019-11-29 13:48 ` Dmitry Gutov
2019-11-29 14:26 ` Eli Zaretskii
2019-11-29 14:31 ` Dmitry Gutov
2019-11-29 15:03 ` Eli Zaretskii
2019-11-29 16:53 ` Dmitry Gutov
2019-11-29 19:28 ` Eli Zaretskii
2019-11-29 17:24 ` Pieter van Oostrum
2019-11-29 19:30 ` Eli Zaretskii
2019-11-30 8:25 ` Pieter van Oostrum
2019-12-01 7:23 ` Pieter van Oostrum
2019-12-01 10:37 ` Phil Sainty
2019-12-01 16:35 ` Pieter van Oostrum
2019-12-01 18:40 ` Pieter van Oostrum
2019-12-02 16:23 ` Eli Zaretskii
2019-12-01 17:45 ` Eli Zaretskii
2019-12-02 10:27 ` Robert Pluim
2019-12-03 11:20 ` Robert Pluim
2019-12-03 16:05 ` Eli Zaretskii
2019-12-04 9:15 ` Robert Pluim
2019-12-04 15:45 ` Eli Zaretskii
2019-12-05 7:27 ` Robert Pluim [this message]
2019-12-05 15:01 ` Eli Zaretskii
2019-12-05 20:38 ` Phil Sainty
2019-12-06 8:04 ` Eli Zaretskii
2019-12-07 1:28 ` Phil Sainty
2019-12-07 7:56 ` Eli Zaretskii
2019-11-28 15:06 ` 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=m21rtjnsfv.fsf@gmail.com \
--to=rpluim@gmail.com \
--cc=38407@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=pieter@vanoostrum.org \
--cc=psainty@orcon.net.nz \
/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).