From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.bugs Subject: bug#58558: 29.0.50; re-search-forward is slow in some buffers Date: Tue, 11 Apr 2023 11:29:26 +0000 Message-ID: <87zg7e8xnt.fsf@localhost> References: <877d10r21x.fsf@localhost> <87mt9tbbbp.fsf@gnus.org> <8335bl18lo.fsf@gnu.org> <87wn8x9eqb.fsf@gnus.org> <87tu1zd2c6.fsf@localhost> <83h6xzphxm.fsf@gnu.org> <87wn6vbfaa.fsf@localhost> <838rjbpecw.fsf@gnu.org> <87fsdjwb4e.fsf@localhost> <874jtyuqax.fsf@localhost> <83zgbqm8q6.fsf@gnu.org> <87sfhit8ug.fsf@localhost> <83tu1ym6jo.fsf@gnu.org> <87h6xyt77x.fsf@localhost> <87h6ttkz6n.fsf@localhost> <838rf5qkpt.fsf@gnu.org> <87lej0zv92.fsf@localhost> <83ttxol6f5.fsf@gnu.org> <87h6tolybs.fsf@localhost> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18082"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 58558@debbugs.gnu.org, Eli Zaretskii , larsi@gnus.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Apr 11 13:28:25 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pmCAh-0004S1-VK for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 11 Apr 2023 13:28:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pmCAO-0007Ye-8M; Tue, 11 Apr 2023 07:28:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pmCAM-0007YG-Aw for bug-gnu-emacs@gnu.org; Tue, 11 Apr 2023 07:28:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pmCAM-0002LS-2l for bug-gnu-emacs@gnu.org; Tue, 11 Apr 2023 07:28:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pmCAL-0007eD-Uw for bug-gnu-emacs@gnu.org; Tue, 11 Apr 2023 07:28:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 11 Apr 2023 11:28:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58558 X-GNU-PR-Package: emacs Original-Received: via spool by 58558-submit@debbugs.gnu.org id=B58558.168121243029321 (code B ref 58558); Tue, 11 Apr 2023 11:28:01 +0000 Original-Received: (at 58558) by debbugs.gnu.org; 11 Apr 2023 11:27:10 +0000 Original-Received: from localhost ([127.0.0.1]:36762 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pmC9W-0007cr-3M for submit@debbugs.gnu.org; Tue, 11 Apr 2023 07:27:10 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:57621) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pmC9R-0007cJ-7W for 58558@debbugs.gnu.org; Tue, 11 Apr 2023 07:27:08 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 0D80D240377 for <58558@debbugs.gnu.org>; Tue, 11 Apr 2023 13:26:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1681212419; bh=pPaN7Y5SwwnOH8BN81eWuKamaplwyfKA1thWuuJeh5I=; h=From:To:Cc:Subject:Date:From; b=EP9DeAQJx1gqg1KjlLHOrnnlWxuJ1AGB5JGTQcXaeMH3DbcvGR8m3UxITOXmEfvtm ZBR7PeIQXHcGeyE0ELKs6x+m0mJisXC8NqQ3E10nrQJissseLLrOxCXVTTuGZkISHy TGhxZiMwgE1AmxDHVpOsGBiNjDibIUFSXc+umMWS439vRD2T7DV6OldmRvjQ7W9Xgp CAewgh8tMnF0MZRutzmVmFHGYRXueeVU/vtsEyBRaxXwPv6B3QoKj5KJIjuQ//UIUi Uhs25uI058EVWPvEyOyOxzGISnlKELvGWWH1rhVqRHHNfo/kpF49gIH3q64pm8Thlr tMU5ORTwHQkKA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Pwk822BPcz6tmv; Tue, 11 Apr 2023 13:26:57 +0200 (CEST) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:259634 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier 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. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-add-debug-vars.patch >From ac15ad3262ddf0a0bf459dc603cb79f7f9c737f7 Mon Sep 17 00:00:00 2001 Message-Id: From: Ihor Radchenko 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 --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--