From: "Mattias Engdegård" <mattias.engdegard@gmail.com>
To: 72830@debbugs.gnu.org
Cc: Stefan Monnier <monnier@iro.umontreal.ca>, Juri Linkov <juri@linkov.net>
Subject: bug#72830: Big rectangular selections are slow
Date: Tue, 27 Aug 2024 14:39:37 +0200 [thread overview]
Message-ID: <AAC45D97-2341-4A9C-90E9-60F3A8BA7F32@gmail.com> (raw)
Selecting rectangles that stretch across many lines is very slow. Recipe:
C-x b example RET
C-u 60 x C-u 200000 M-x duplicate-dwim RET C-a
C-x SPC
M-> C-f C-f C-f C-f
Each keystroke at the end lags noticeably, to the point that this isn't practical.
Why this matters: rectangular selections are very useful for editing large amount of data in a homogeneous way, and such a file (12 MB) isn't huge.
Possible causes:
- Slow `region-beginning` and `region-end`.
Fixed on master (3a8222e7).
- `select-active-regions` makes each selection change very expensive.
Can be set to nil by the user, but I really suggest that we change the default to nil, at least for non-X11 since the default assumes old-school X11 PRIMARY selection which is alien on most other platforms.
- Slow `rectangle--highlight-for-redisplay`. This is the remaining cause.
Profiling shows that most of the time is spent in the function passed to `apply-on-rectangle`.
Here is an excerpt of that profile:
| Weight Self
| 31.93 Gc 57.4% 103.06 Mc Fmove_to_column
| 31.52 Gc 56.7% 884.80 Mc scan_for_column
| 14.45 Gc 26.0% 27.82 Mc check_display_width
| 14.30 Gc 25.7% 648.23 Mc get_char_property_and_overlay
| 9.79 Gc 17.6% 1.07 Gc itree_iterator_next
| 2.00 Gc 3.6% 42.68 Mc Fget_text_property
| 743.88 Mc 1.3% 154.63 Mc itree_iterator_start
| 678.00 Mc 1.2% 183.02 Mc lookup_char_property
| 7.28 Gc 13.0% 155.15 Mc skip_invisible
| 4.22 Gc 7.6% 701.27 Mc composition_compute_stop_pos
| 3.00 Gc 5.3% 153.86 Mc window_loop
| 1.28 Gc 2.3% 216.97 Mc find_newline
| 2.28 Gc 4.1% 80.59 Mc Fmove_overlay
| 1.46 Gc 2.6% 40.18 Mc lookup_char_property
This excludes GC costs (about 18 % I think), which in turn is dominated by scanning overlays.
It's a bit surprising (to me) how expensive move-to-column is. The text is all-ASCII without any complications (no long lines, properties, etc).
next reply other threads:[~2024-08-27 12:39 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-27 12:39 Mattias Engdegård [this message]
2024-08-27 13:48 ` bug#72830: Big rectangular selections are slow Eli Zaretskii
2024-08-27 14:04 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-27 16:42 ` Mattias Engdegård
2024-08-27 17:47 ` Eli Zaretskii
2024-08-27 19:16 ` Eli Zaretskii
2024-08-27 18:23 ` Juri Linkov
2024-08-27 18:55 ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-27 19:03 ` Eli Zaretskii
2024-08-27 19:44 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-29 3:56 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-29 10:22 ` Mattias Engdegård
2024-08-29 11:18 ` Mattias Engdegård
2024-08-29 8:09 ` Mattias Engdegård
2024-08-29 20:04 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-30 15:20 ` Mattias Engdegård
2024-09-20 12:53 ` Mattias Engdegård
2024-09-21 2:07 ` Stefan Kangas
2024-09-21 8:26 ` Eli Zaretskii
2024-09-21 3:05 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-22 13:27 ` Mattias Engdegård
2024-09-22 14:12 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-22 15:16 ` Mattias Engdegård
2024-09-22 15:32 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-22 16:22 ` Mattias Engdegård
2024-09-22 17:37 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-23 10:42 ` Mattias Engdegård
2024-08-29 0:45 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-29 3:39 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-29 4:44 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-29 0:40 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AAC45D97-2341-4A9C-90E9-60F3A8BA7F32@gmail.com \
--to=mattias.engdegard@gmail.com \
--cc=72830@debbugs.gnu.org \
--cc=juri@linkov.net \
--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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.