unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: Mitchell <mitchellahren@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>, 71644@debbugs.gnu.org
Subject: bug#71644: 30.0.50; Severe slowdown in larger files with markers beginning in emacs 29+
Date: Fri, 21 Jun 2024 06:19:01 +0000	[thread overview]
Message-ID: <87h6dmbyy2.fsf@localhost> (raw)
In-Reply-To: <CAOQwW=b9ksFiPL6j5wzzea_Hq67xt31ME+rq6KkT96r-LGrigg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 560 bytes --]

Mitchell <mitchellahren@gmail.com> writes:

>> If you remove all the non-ASCII characters from the Org file, does the
>> slowdown go away?
>
> Eli, that solved it! The new test file is at
> https://gist.github.com/kings2u/2ef0e145f2b42d0a13605b0dc9b6e6e2. I
> replaced every non-ASCII character with an "a" so the file still has the
> same number of total characters, and in my emacs 30.0 50 build (as of
> 2024-05-25), doing Steps 1 to Step 7 gives me abbrev expansions that are as
> lighting fast as in emacs 28.2!

Hmm. Then, does the attached patch help?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-src-marker.c-buf_bytepos_to_charpos-Limit-marker-sea.patch --]
[-- Type: text/x-patch, Size: 1180 bytes --]

From 0bafd288faee8cae33fe4a122f6e3ac73ec10d60 Mon Sep 17 00:00:00 2001
Message-ID: <0bafd288faee8cae33fe4a122f6e3ac73ec10d60.1718950719.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Sun, 23 Apr 2023 21:31:46 +0200
Subject: [PATCH] * src/marker.c (buf_bytepos_to_charpos): Limit marker search

Limit searching across buffer markers to first 50 markers and thus
avoid performance scaling with the number of markers.

I got 5x `re-search-forward' speed improvement in my setup with this
dumb change.
---
 src/marker.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/marker.c b/src/marker.c
index f016bf9c088..4d7d6621513 100644
--- a/src/marker.c
+++ b/src/marker.c
@@ -354,8 +354,10 @@ buf_bytepos_to_charpos (struct buffer *b, ptrdiff_t bytepos)
   if (b == cached_buffer && BUF_MODIFF (b) == cached_modiff)
     CONSIDER (cached_bytepos, cached_charpos);
 
-  for (tail = BUF_MARKERS (b); tail; tail = tail->next)
+  int i = 0;
+  for (tail = BUF_MARKERS (b); tail && i < 50; tail = tail->next)
     {
+      i++;
       CONSIDER (tail->bytepos, tail->charpos);
 
       /* If we are down to a range of 50 chars,
-- 
2.45.1


[-- Attachment #3: Type: text/plain, Size: 224 bytes --]


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

  reply	other threads:[~2024-06-21  6:19 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-19  5:25 bug#71644: 30.0.50; Severe slowdown in larger files with markers beginning in emacs 29+ Mitchell
2024-06-19 12:56 ` Eli Zaretskii
2024-06-20 13:49   ` Ihor Radchenko
2024-06-20 16:11     ` Eli Zaretskii
2024-06-20 16:24       ` Eli Zaretskii
2024-06-20 18:57   ` Mitchell
2024-06-20 19:04     ` Eli Zaretskii
2024-06-21  2:46       ` Mitchell
2024-06-21  6:19         ` Ihor Radchenko [this message]
2024-06-21 20:53           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-22  5:23             ` Gerd Möllmann
2024-06-22 14:10             ` Ihor Radchenko
2024-06-22 15:52               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-25  3:07               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-25  4:00                 ` Eli Zaretskii
2024-06-25  9:30                 ` Ihor Radchenko
2024-06-25 13:44                   ` Eli Zaretskii
2024-06-25 13:50                     ` Ihor Radchenko
2024-06-25 13:57                       ` Eli Zaretskii
2024-06-25 14:25                         ` Ihor Radchenko
2024-06-26  3:53                         ` Mitchell
2024-06-26 12:41                           ` Eli Zaretskii
2024-06-25 20:54                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-26 11:41                   ` Eli Zaretskii
2024-06-26 12:35                     ` Ihor Radchenko
2024-06-26 13:30                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-26 13:49                       ` Ihor Radchenko
2024-06-26 14:08                         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-29 21:27                           ` Mitchell
2024-06-25 21:02               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-21  6:48         ` Eli Zaretskii
2024-06-21 21:06           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-22  6:57             ` Eli Zaretskii
2024-06-22 18:03               ` Mitchell
2024-06-22 18:17                 ` Eli Zaretskii
2024-06-24  7:09                   ` Mitchell
2024-06-24 12:38                     ` Eli Zaretskii
2024-06-25  3:08                       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-22 13:53 ` Ihor Radchenko
2024-06-22 14:12   ` Eli Zaretskii
2024-06-22 14:15     ` Eli Zaretskii
2024-06-22 15:09 ` Stefan Monnier 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

  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=87h6dmbyy2.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=71644@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=mitchellahren@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).