From: Herman@debbugs.gnu.org, Géza <geza.herman@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 62352@debbugs.gnu.org, gregory@heytings.org
Subject: bug#62352: Very slow scroll-down-line with a lot of text properties
Date: Sun, 26 Mar 2023 09:14:40 +0200 [thread overview]
Message-ID: <5624c78c-c424-deec-2649-f11a5c149d22@gmail.com> (raw)
In-Reply-To: <834jq8az83.fsf@gnu.org>
On 3/26/23 06:55, Eli Zaretskii wrote:
>>
>> The problem is not there. The problem is that find_composition is only
>> interested in the composition property, yet it scans all the properties
>> linearly.
> It doesn't scan linearly. It calls next-single-property-change, which
> traverses the interval tree we use for storing text properties.
> Please take a look at the implementation of
> next-single-property-change in textprop.c.
It finds the starting point by traversing the tree (presumably an
O(log(number_of_properties)) operation (that's good), but then scans
linearly. My example buffer has a different property for (almost) all
characters, this means that this function will search the tree for ~500
elements to conclude that there is no such property around. And it does
this operation for every single character visible in the window, or
something like this.
>> And it scans it for 500 characters. This file has a lot of
>> properties, this means a lot of unnecessary and duplicated work (because
>> it does this for each character displayed, or something like this). If
>> the composition property had its own list, then this problem wouldn't exist.
> If the composition property had its own data structure, Emacs would
> need to search them both when it looks for a change in _any_ property
> (something that happens quite a lot in other places), and handle
> various combinations of hits in both data structures. That'd be a
> significant complication for a small gain.
If that's the case, then emacs could have a data structure which
contains all the properties (like now), and one which points only to the
composition properties. Yes, this is a complication, it will make emacs
generally a little bit slower, but it would avoid freezes.
But maybe this is not the correct solution. I have a feeling that this
500-character search area is not a good solution for the problem it
tries to solve. Maybe it's a result of some optimization that was
relevant a long time ago, but now it isn't, and it is actually a
de-optimization if the buffer contains a lot of properties.
A lot of people wouldn't care if emacs used a little more CPU power in
general (as an example, during general editing, it would use 30% CPU
instead of 20%), if this means that there is no stuttering. That's why
people (me included) set the garbage collector threshold to a high
value, because of the introduced micro-stuttering by the GC. But I'm not
even sure that having more specialized search structures would actually
slow down emacs in general. Maybe the net result would be that not only
emacs won't freeze, but it would also become generally faster.
prev parent reply other threads:[~2023-03-26 7:14 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-21 20:01 bug#62352: Very slow scroll-down-line with a lot of text properties Herman, Geza
2023-03-21 20:26 ` Eli Zaretskii
2023-03-21 20:39 ` Herman, Géza
2023-03-21 21:58 ` Gregory Heytings
2023-03-25 11:58 ` Eli Zaretskii
2023-03-25 12:33 ` Herman, Géza
2023-03-25 12:42 ` Eli Zaretskii
2023-03-25 13:41 ` Herman, Géza
2023-03-25 14:02 ` Eli Zaretskii
2023-03-25 15:24 ` Herman, Géza
2023-03-25 16:20 ` Eli Zaretskii
2023-03-25 17:38 ` Herman, Géza
2023-03-25 17:49 ` Eli Zaretskii
2023-03-25 21:39 ` Herman, Géza
2023-03-26 4:55 ` Eli Zaretskii
2023-03-26 7:14 ` Herman, Géza [this message]
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=5624c78c-c424-deec-2649-f11a5c149d22@gmail.com \
--to=herman@debbugs.gnu.org \
--cc=62352@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=geza.herman@gmail.com \
--cc=gregory@heytings.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).