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: Fri, 24 Jul 2020 19:24:50 +0000 Message-ID: <20200724192450.GA8811@ACM> References: <8E02A060-9CF0-4B1F-A780-4F51336291FA@acm.org> 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="458"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 42490@debbugs.gnu.org To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= , Olivier Scalbert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jul 24 21:26:19 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 1jz3Kk-000AaE-Bl for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 24 Jul 2020 21:26:18 +0200 Original-Received: from localhost ([::1]:34208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jz3Kj-0001QP-AB for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 24 Jul 2020 15:26:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jz3KU-0001QG-2V for bug-gnu-emacs@gnu.org; Fri, 24 Jul 2020 15:26:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37207) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jz3KT-0001sI-PR for bug-gnu-emacs@gnu.org; Fri, 24 Jul 2020 15:26:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jz3KT-0004d0-MY for bug-gnu-emacs@gnu.org; Fri, 24 Jul 2020 15:26: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: Fri, 24 Jul 2020 19:26: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.159561870317692 (code B ref 42490); Fri, 24 Jul 2020 19:26:01 +0000 Original-Received: (at 42490) by debbugs.gnu.org; 24 Jul 2020 19:25:03 +0000 Original-Received: from localhost ([127.0.0.1]:48744 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jz3JW-0004bI-Np for submit@debbugs.gnu.org; Fri, 24 Jul 2020 15:25:02 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:41566 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1jz3JS-0004ah-DO for 42490@debbugs.gnu.org; Fri, 24 Jul 2020 15:25:01 -0400 Original-Received: (qmail 97683 invoked by uid 3782); 24 Jul 2020 19:24:51 -0000 Original-Received: from acm.muc.de (p4fe15eb0.dip0.t-ipconnect.de [79.225.94.176]) by localhost.muc.de (tmda-ofmipd) with ESMTP; Fri, 24 Jul 2020 21:24:51 +0200 Original-Received: (qmail 9072 invoked by uid 1000); 24 Jul 2020 19:24:51 -0000 Content-Disposition: inline In-Reply-To: <8E02A060-9CF0-4B1F-A780-4F51336291FA@acm.org> 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:183504 Archived-At: 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).