From: Ihor Radchenko <yantar92@posteo.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 58558@debbugs.gnu.org, Eli Zaretskii <eliz@gnu.org>, larsi@gnus.org
Subject: bug#58558: 29.0.50; re-search-forward is slow in some buffers
Date: Tue, 11 Apr 2023 11:29:26 +0000 [thread overview]
Message-ID: <87zg7e8xnt.fsf@localhost> (raw)
In-Reply-To: <jwvjzyjhlf1.fsf-monnier+emacs@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 399 bytes --]
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> BTW, when debugging such performance problem, I often resort to
> a few `DEFVAR_INT` defining ad-hoc counter variables, then sprinkle
> corresponding increments of those variables from various places
> (typically function entry point, loops, ...).
Well. I just tried, but my Emacs-C foo is not good enough.
The attached patch fails to compile.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-add-debug-vars.patch --]
[-- Type: text/x-patch, Size: 3962 bytes --]
From ac15ad3262ddf0a0bf459dc603cb79f7f9c737f7 Mon Sep 17 00:00:00 2001
Message-Id: <ac15ad3262ddf0a0bf459dc603cb79f7f9c737f7.1681212491.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
Date: Tue, 11 Apr 2023 13:27:56 +0200
Subject: [PATCH] add debug vars
---
src/regex-emacs.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/src/regex-emacs.c b/src/regex-emacs.c
index 2571812cb39..6bcc64d5c0a 100644
--- a/src/regex-emacs.c
+++ b/src/regex-emacs.c
@@ -3889,6 +3889,25 @@ unwind_re_match (void *ptr)
b->text->inhibit_shrinking = 0;
}
+DEFVAR_INT("re-match-2-internal-bytepos-calls-1", re_match_2_internal_bytepos_calls_1,
+ doc: /* Call count 1. Internal use only. */);
+DEFVAR_INT("re-match-2-internal-bytepos-calls-2", re_match_2_internal_bytepos_calls_2,
+ doc: /* Call count 1. Internal use only. */);
+DEFVAR_INT("re-match-2-internal-bytepos-calls-3", re_match_2_internal_bytepos_calls_3,
+ doc: /* Call count 1. Internal use only. */);
+DEFVAR_INT("re-match-2-internal-bytepos-calls-4", re_match_2_internal_bytepos_calls_4,
+ doc: /* Call count 1. Internal use only. */);
+DEFVAR_INT("re-match-2-internal-bytepos-calls-5", re_match_2_internal_bytepos_calls_5,
+ doc: /* Call count 1. Internal use only. */);
+DEFVAR_INT("re-match-2-internal-bytepos-calls-6", re_match_2_internal_bytepos_calls_6,
+ doc: /* Call count 1. Internal use only. */);
+re_match_2_internal_bytepos_calls_1 = 0;
+re_match_2_internal_bytepos_calls_2 = 0;
+re_match_2_internal_bytepos_calls_3 = 0;
+re_match_2_internal_bytepos_calls_4 = 0;
+re_match_2_internal_bytepos_calls_5 = 0;
+re_match_2_internal_bytepos_calls_6 = 0;
+
/* This is a separate function so that we can force an alloca cleanup
afterwards. */
static ptrdiff_t
@@ -4808,6 +4827,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp,
int dummy;
ptrdiff_t offset = PTR_TO_OFFSET (d);
ptrdiff_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset) - 1;
+ re_match_2_internal_bytepos_calls_1++;
UPDATE_SYNTAX_TABLE (charpos);
GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2);
nchars++;
@@ -4848,6 +4868,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp,
int dummy;
ptrdiff_t offset = PTR_TO_OFFSET (d);
ptrdiff_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset);
+ re_match_2_internal_bytepos_calls_2++;
UPDATE_SYNTAX_TABLE (charpos);
PREFETCH ();
GET_CHAR_AFTER (c2, d, dummy);
@@ -4891,6 +4912,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp,
int dummy;
ptrdiff_t offset = PTR_TO_OFFSET (d);
ptrdiff_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset) - 1;
+ re_match_2_internal_bytepos_calls_3++;
UPDATE_SYNTAX_TABLE (charpos);
GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2);
nchars++;
@@ -4933,6 +4955,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp,
int s1, s2;
ptrdiff_t offset = PTR_TO_OFFSET (d);
ptrdiff_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset);
+ re_match_2_internal_bytepos_calls_4++;
UPDATE_SYNTAX_TABLE (charpos);
PREFETCH ();
c2 = RE_STRING_CHAR (d, target_multibyte);
@@ -4974,6 +4997,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp,
int s1, s2;
ptrdiff_t offset = PTR_TO_OFFSET (d);
ptrdiff_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset) - 1;
+ re_match_2_internal_bytepos_calls_5++;
UPDATE_SYNTAX_TABLE (charpos);
GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2);
nchars++;
@@ -5010,6 +5034,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp,
{
ptrdiff_t offset = PTR_TO_OFFSET (d);
ptrdiff_t pos1 = SYNTAX_TABLE_BYTE_TO_CHAR (offset);
+ re_match_2_internal_bytepos_calls_6++;
UPDATE_SYNTAX_TABLE (pos1);
}
{
--
2.40.0
[-- 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>
next prev parent reply other threads:[~2023-04-11 11:29 UTC|newest]
Thread overview: 81+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-16 1:26 bug#58558: 29.0.50; re-search-forward is slow in some buffers Ihor Radchenko
2022-10-16 9:19 ` Lars Ingebrigtsen
2022-10-16 9:34 ` Ihor Radchenko
2022-10-16 9:37 ` Lars Ingebrigtsen
2022-10-16 10:02 ` Ihor Radchenko
2022-10-16 10:04 ` Lars Ingebrigtsen
2022-10-16 10:53 ` Ihor Radchenko
2022-10-16 11:01 ` Lars Ingebrigtsen
2022-10-16 11:21 ` Eli Zaretskii
2022-10-16 14:23 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-17 0:56 ` Ihor Radchenko
2022-10-18 11:50 ` Lars Ingebrigtsen
2022-10-18 14:58 ` Eli Zaretskii
2022-10-18 18:19 ` Lars Ingebrigtsen
2022-10-18 18:38 ` Eli Zaretskii
2022-12-13 10:28 ` Ihor Radchenko
2022-12-13 13:11 ` Eli Zaretskii
2022-12-13 13:32 ` Ihor Radchenko
2022-12-13 14:28 ` Eli Zaretskii
2022-12-13 15:56 ` Ihor Radchenko
2022-12-13 16:08 ` Eli Zaretskii
2022-12-13 17:43 ` Ihor Radchenko
2022-12-13 17:52 ` Eli Zaretskii
2022-12-13 18:03 ` Ihor Radchenko
2022-12-13 20:02 ` Eli Zaretskii
2022-12-14 11:40 ` Ihor Radchenko
2022-12-14 13:06 ` Eli Zaretskii
2022-12-14 13:23 ` Ihor Radchenko
2022-12-14 13:32 ` Eli Zaretskii
2022-12-14 13:39 ` Ihor Radchenko
2022-12-14 14:12 ` Eli Zaretskii
2022-12-13 18:15 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-13 18:40 ` Ihor Radchenko
2022-12-13 19:55 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-13 20:21 ` Eli Zaretskii
2022-12-14 11:42 ` Ihor Radchenko
2022-12-13 17:38 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-14 12:00 ` Ihor Radchenko
2022-12-14 12:23 ` Ihor Radchenko
2022-12-14 13:10 ` Eli Zaretskii
2022-12-14 13:26 ` Ihor Radchenko
2022-12-14 13:57 ` Eli Zaretskii
2022-12-14 14:01 ` Ihor Radchenko
2023-04-06 11:49 ` Ihor Radchenko
2023-04-06 12:05 ` Eli Zaretskii
2023-04-09 19:54 ` Ihor Radchenko
2023-04-10 4:14 ` Eli Zaretskii
2023-04-10 12:24 ` Ihor Radchenko
2023-04-10 13:40 ` Eli Zaretskii
2023-04-10 14:55 ` Ihor Radchenko
2023-04-10 16:04 ` Eli Zaretskii
2023-04-10 14:27 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-11 11:29 ` Ihor Radchenko [this message]
2023-04-11 11:51 ` Eli Zaretskii
2023-04-12 13:39 ` Ihor Radchenko
2023-04-12 14:06 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-12 14:30 ` Eli Zaretskii
2023-04-12 14:38 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-12 15:22 ` Eli Zaretskii
2023-04-12 15:59 ` Alan Mackenzie
2023-04-12 14:38 ` Stephen Berman
2023-04-12 14:42 ` Ihor Radchenko
2023-04-12 14:39 ` Ihor Radchenko
2023-04-12 15:20 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-12 23:23 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-13 4:33 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-13 20:05 ` Ihor Radchenko
2023-04-13 4:52 ` Eli Zaretskii
2023-04-13 5:15 ` Eli Zaretskii
2023-04-12 18:31 ` Alan Mackenzie
2023-04-12 23:25 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-13 4:43 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-04-13 12:09 ` Ihor Radchenko
2022-12-13 13:27 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-16 10:36 ` Eli Zaretskii
2023-02-19 12:17 ` Dmitry Gutov
2023-02-20 10:24 ` Ihor Radchenko
2023-02-20 14:54 ` Dmitry Gutov
2023-04-10 8:48 ` Mattias Engdegård
2023-04-10 9:57 ` Ihor Radchenko
2023-04-10 10:05 ` Mattias Engdegård
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=87zg7e8xnt.fsf@localhost \
--to=yantar92@posteo.net \
--cc=58558@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=larsi@gnus.org \
--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.