From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#42490: Emacs is very slow when navigating into a specific C++ file Date: Mon, 21 Sep 2020 09:06:39 +0000 Message-ID: <20200921090639.GA6379@ACM> References: <8E02A060-9CF0-4B1F-A780-4F51336291FA@acm.org> <20200724192450.GA8811@ACM> <1b3a22e8-859f-b839-74cb-1905a8298b52@algosyn.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25604"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= , 42490@debbugs.gnu.org, acm@muc.de To: Olivier Scalbert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 21 11:07:11 2020 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 1kKHmx-0006a4-1z for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 21 Sep 2020 11:07:11 +0200 Original-Received: from localhost ([::1]:44932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kKHmw-0002aH-3c for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 21 Sep 2020 05:07:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34478) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kKHmo-0002a2-A2 for bug-gnu-emacs@gnu.org; Mon, 21 Sep 2020 05:07:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41901) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kKHmo-00070o-12 for bug-gnu-emacs@gnu.org; Mon, 21 Sep 2020 05:07:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kKHmn-0002Lw-St for bug-gnu-emacs@gnu.org; Mon, 21 Sep 2020 05:07:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 21 Sep 2020 09:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42490 X-GNU-PR-Package: emacs Original-Received: via spool by 42490-submit@debbugs.gnu.org id=B42490.16006792099026 (code B ref 42490); Mon, 21 Sep 2020 09:07:01 +0000 Original-Received: (at 42490) by debbugs.gnu.org; 21 Sep 2020 09:06:49 +0000 Original-Received: from localhost ([127.0.0.1]:53447 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kKHmb-0002LV-9C for submit@debbugs.gnu.org; Mon, 21 Sep 2020 05:06:49 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:14102 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1kKHmZ-0002LC-BE for 42490@debbugs.gnu.org; Mon, 21 Sep 2020 05:06:48 -0400 Original-Received: (qmail 26247 invoked by uid 3782); 21 Sep 2020 09:06:40 -0000 Original-Received: from acm.muc.de (p4fe15e13.dip0.t-ipconnect.de [79.225.94.19]) by localhost.muc.de (tmda-ofmipd) with ESMTP; Mon, 21 Sep 2020 11:06:39 +0200 Original-Received: (qmail 6432 invoked by uid 1000); 21 Sep 2020 09:06:39 -0000 Content-Disposition: inline In-Reply-To: <1b3a22e8-859f-b839-74cb-1905a8298b52@algosyn.com> X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de 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:188559 Archived-At: Hello, Olivier. Ping? On Fri, Jul 24, 2020 at 21:34:51 +0200, Olivier Scalbert wrote: > Hi, > Thanks for your answer. > Unfortunately, I am out of my home, with no PC, for the week-end. > If I'll survive, I will test it next Monday. Very sorry ! > ;-) Emacs 27.1 was released just a few weeks ago. Maybe you're already using it. I think CC Mode processes the test file fast enough on 27.1, so it's probably time to close this bug. What do you say? > Regards, > Olivier > On 7/24/20 9:24 PM, Alan Mackenzie wrote: > > Hello, Mattias and Olivier. > > Firstly Olivier, thanks for taking the trouble to report the bug. > > On Fri, Jul 24, 2020 at 18:46:45 +0200, Mattias Engdegård wrote: > >> Hello Olivier, > >> Thanks for the report! Could you try Emacs 27 (or git master), building > >> from source if necessary? Those versions should be slightly faster, > >> although the response time is probably well below acceptable. > >> If we distill the essentials of your file to some sort of benchmark, we > >> might end up with: > >> (with-temp-buffer > >> (c++-mode) > >> (dotimes (_ 1000) > >> (insert "OP(ed,b0) { ldir(); } /* LDIR */\n")) > >> (garbage-collect) > >> (let ((t0 (current-time))) > >> (font-lock-ensure (point-min) (point-max)) > >> (time-to-seconds (time-since t0)))) > >> Emacs 26.3 runs it in 11.9 s on this old lappy, but Emacs 27 does it in > >> 3.3 s. This is a clear improvement but we should be able to do better. > >> Alan may have a feeling for where the cycles are spent. > > I've bisected CC Mode to find the critical change, and it is: > > commit cc80eeb4a43d2079963de3d181002a6a6b56560d > > Author: Alan Mackenzie > > Date: Fri Apr 12 20:07:03 2019 +0000 > > Analyze C++ method with & or && ref-qualifier as defun, not brace list > > Also firm up detection of beginning of brace list in > > c-looking-at-or-maybe-in-bracelist. > > I have a simple benchmark which scrolls through a file, fontifying it, > > and my results from this benchmark are: > > (i) Before applying that patch: 53.022s. > > (ii) After applying that patch: 7.039s. > > I don't understand at the moment why that patch sped up scrolling in your > > (Olivier's) file, but it would seem the patch is most desirable. > > Unfortunately, the patch won't apply cleanly to the Emacs 26.3 sources. > > It might be possible to find a sequence of patches which would do the > > job. I think (though I haven't checked) the patch will have been > > included in the upcoming Emacs 27.1 release. -- Alan Mackenzie (Nuremberg, Germany).