From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#58558: 29.0.50; re-search-forward is slow in some buffers Date: Sun, 16 Oct 2022 10:23:45 -0400 Message-ID: References: <877d10r21x.fsf@localhost> <87zgdwyvkt.fsf@gnus.org> <87ilkk6ri5.fsf@localhost> <87v8okjei9.fsf@gnus.org> <87tu44jdce.fsf@localhost> <87czasjd9j.fsf@gnus.org> <87k050nio5.fsf@localhost> <87zgdwhw0z.fsf@gnus.org> <83sfjo3tfw.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25283"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 58558@debbugs.gnu.org, Lars Ingebrigtsen , yantar92@posteo.net To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 16 16:24:11 2022 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 1ok4Yk-0006Lz-Ac for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 16 Oct 2022 16:24:10 +0200 Original-Received: from localhost ([::1]:46400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ok4Yi-0006d2-LE for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 16 Oct 2022 10:24:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ok4Yc-0006ct-Fb for bug-gnu-emacs@gnu.org; Sun, 16 Oct 2022 10:24:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46771) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ok4Yc-0000Ny-6y for bug-gnu-emacs@gnu.org; Sun, 16 Oct 2022 10:24:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ok4Yb-0003hT-OF for bug-gnu-emacs@gnu.org; Sun, 16 Oct 2022 10:24:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 16 Oct 2022 14:24: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.166593023514207 (code B ref 58558); Sun, 16 Oct 2022 14:24:01 +0000 Original-Received: (at 58558) by debbugs.gnu.org; 16 Oct 2022 14:23:55 +0000 Original-Received: from localhost ([127.0.0.1]:45849 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ok4YU-0003h5-SX for submit@debbugs.gnu.org; Sun, 16 Oct 2022 10:23:55 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:16352) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ok4YT-0003gt-Ny for 58558@debbugs.gnu.org; Sun, 16 Oct 2022 10:23:54 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 6266B807E9; Sun, 16 Oct 2022 10:23:48 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 0B1F9805B2; Sun, 16 Oct 2022 10:23:47 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1665930227; bh=FKAjNhuF/pOAdEquOPHAUmV4pabgPbyDhTHbdeM6zx0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=BzqzeYqjrhsZgjlYUA4wDAmn4pe7cdCBPkDKbOcUoDI0q1tla57aGAT4Q+FimSJzF XaUJ06G5dVS/lVwfG9SOKj/Cnu3uH63WHsqzg33SpP0EQb1g/+1KS7jQe+eibN/rw/ P0h+RJml8W1NpM7dqJRaVT/IH5HhKw8cx4zuS5WIat/qazRGc8pTXRSVNsceq6IyLO 5DnNyh7PGtvcVB1k4JQ/UYFRKU6NcuFHdChN0ZbdMWT11gcskmU/JrT8NPzD8scAsR UhxTL2hiZHXJBd2y/OG/BsZu1wY93TmA4fFYZmvNTAFJskxMppbkAdly287HK33ERn RDj5D80XAGq+w== Original-Received: from pastel (65-110-220-202.cpe.pppoe.ca [65.110.220.202]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id BFABD120F05; Sun, 16 Oct 2022 10:23:46 -0400 (EDT) In-Reply-To: <83sfjo3tfw.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 16 Oct 2022 14:21:23 +0300") 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" Xref: news.gmane.io gmane.emacs.bugs:245652 Archived-At: >> Huh, very odd. Almost as something is... fragmenting in the buffer? >> We do have many caches and stuff -- perhaps something is... degrading? >> >> I guess some C-level perf measurements would be handy here, but that's >> not something I know much about. Anybody? > > AFAIU, we use elaborate caching for regular expressions, so maybe that > is related. Stefan, any ideas? The regexp cache hasn't changed between 28 and 29, so that seems unlikely to be the source of the problem. But that cache is fairly simple-minded, so it's possible that for some reason it thrashes in Emacs-29 but not in Emacs-28 (but see below). IIUC a summary of what we know so far: - the "yant/re" benchmark is ~20x slower in Emacs-29 than in Emacs-28. - removing all text properties reduces the factor down to about ~15x. - that difference is absent after a fresh start: it only appears over time. Since this benchmark always matches the same regexp, I can't imagine how the regexp cache could thrash, so it definitely seems to come from something else. I'd curious to know the result of the following tests: - Run the same benchmark twice in a row: does the second run take the same time as the first, or is the second run significantly faster? [ if it's faster it might be due to something like the on-the-fly `syntax-propertize`ation. BTW, what does the profiler-start/report say? Is the time 100% spent in `re-search-forward`? ] - Try to reduce the number of "features" used in the regexp to see how it affects the slow down. Maybe try a "binary search" where you try to reduce the regexp to something much simpler and see if some regexps exhibit the slowdown while others don't? Stefan