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: Mon, 17 Oct 2022 00:56:02 +0000 Message-ID: <878rlfjmjh.fsf@localhost> 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> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4919"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 58558@debbugs.gnu.org, Eli Zaretskii , Lars Ingebrigtsen To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Oct 17 02:56:38 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 1okEQn-00015O-QI for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 17 Oct 2022 02:56:37 +0200 Original-Received: from localhost ([::1]:44546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okEQm-0000YY-ND for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 16 Oct 2022 20:56:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okEQG-0000VC-RX for bug-gnu-emacs@gnu.org; Sun, 16 Oct 2022 20:56:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47462) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1okEQE-0004n6-Ub for bug-gnu-emacs@gnu.org; Sun, 16 Oct 2022 20:56:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1okEQE-00041p-HW for bug-gnu-emacs@gnu.org; Sun, 16 Oct 2022 20:56:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 17 Oct 2022 00:56:02 +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.166596812915445 (code B ref 58558); Mon, 17 Oct 2022 00:56:02 +0000 Original-Received: (at 58558) by debbugs.gnu.org; 17 Oct 2022 00:55:29 +0000 Original-Received: from localhost ([127.0.0.1]:46540 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1okEPg-000413-KS for submit@debbugs.gnu.org; Sun, 16 Oct 2022 20:55:29 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:52851) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1okEPe-00040o-CO for 58558@debbugs.gnu.org; Sun, 16 Oct 2022 20:55:27 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 80B1C240101 for <58558@debbugs.gnu.org>; Mon, 17 Oct 2022 02:55:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1665968120; bh=Ua1uNSRgC02dkCsGFpT4g+jpofzuKo8ga72BiMSbOfA=; h=From:To:Cc:Subject:Date:From; b=ORA6VovbEmrO0UC7NOHPqntH0qGQNWLBxIFm0CB3IMSbKi5KMaCtxL0XZwEuGCThi IvIt7OmWBDHf4FdbyXT276KLWtJIjQQ8GmS5TCHhh6RmI8eRtptJmt13wyn4F9MFtw yrG0OgYd2aYsWmtbZbLxfzefNq7nCAmNlIg5XO2+EZIEjUitr1taLxOhPacf9wxNJj 54f17VIWS4rKACEQh1ZXTSJM7mgPMYPsJ0N8nrwoVFxRNS08ZrLbfxCpe6etU3ibuQ xgLgPqOzG/xeWeWZ0ADokkbf134wMgJS+2ZIsvy9MMEaDbqqRA3PeV0tIheh8CS4FX vdqfx8XyqnIZg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4MrJSM35ZDz6tmX; Mon, 17 Oct 2022 02:55:14 +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" Xref: news.gmane.io gmane.emacs.bugs:245681 Archived-At: Stefan Monnier writes: > 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. After 11 hours of Emacs uptime and some edits in the buffer (actually, just a few hours; mostly idle), running the benchmark-progn repetitively: ;; Elapsed time: 8.339753s ;; Elapsed time: 9.243140s ;; Elapsed time: 9.868761s ;; Elapsed time: 10.330362s ;; Elapsed time: 11.279218s ;; Elapsed time: 13.581893s ;; Elapsed time: 13.675609s ;; Elapsed time: 14.553157s ;; Elapsed time: 14.651782s ;; Elapsed time: 17.253983s The elapsed time gradually increases. It is definitely a clue, but very odd one. > BTW, what does the profiler-start/report say? > Is the time 100% spent in `re-search-forward`? ] ;; w CPU profiler ;; Elapsed time: 19.628828s ;; profiler: ;; 19954 99% - command-execute ;; 19926 99% - funcall-interactively ;; 19627 98% - eval-expression ;; 19627 98% - let ;; 19627 98% - progn ;; 19627 98% while ;; ------------ no more data inside while --------- Nothing useful. It's like while loop is doing something bad, but how so in (benchmark-progn (while (re-search-forward yant/re nil t))) ?? I also tried find-file-literally and the timing gets back to fresh Emacs (even faster): ;; find-file-literally ;; Elapsed time: 0.592935s Then, I re-opened the file normally. ;; re-open the file ;; Elapsed time: 7.348727s Note how the time is back to 7-8 seconds, but not same as fresh Emacs. > - 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? Hmm. I tried a very simple regexp "^\\*+ " 10 times in a row: ;; Elapsed time: 0.267681s ;; Elapsed time: 0.381607s ;; Elapsed time: 0.342378s ;; Elapsed time: 0.350618s ;; Elapsed time: 0.376871s ;; Elapsed time: 0.446346s ;; Elapsed time: 0.472543s ;; Elapsed time: 0.529925s ;; Elapsed time: 0.604101s ;; Elapsed time: 0.665601s It is generally faster, but still relatively slow and gets worse over time. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at