From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#18134: 24.3; Doxygen comments trigger anomalous C++ major mode behavior Date: Sat, 19 Oct 2019 16:13:05 +0000 Message-ID: <20191019161305.GB7911@ACM> References: <87ppgpiraa.fsf@octopus.email-scan.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="201138"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: 18134@debbugs.gnu.org, Sam Varshavchik To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Oct 19 18:14:10 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iLrMo-000qDh-92 for geb-bug-gnu-emacs@m.gmane.org; Sat, 19 Oct 2019 18:14:10 +0200 Original-Received: from localhost ([::1]:58310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLrMn-0008SG-5I for geb-bug-gnu-emacs@m.gmane.org; Sat, 19 Oct 2019 12:14:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50835) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLrMh-0008S7-DJ for bug-gnu-emacs@gnu.org; Sat, 19 Oct 2019 12:14:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iLrMg-0002c9-5r for bug-gnu-emacs@gnu.org; Sat, 19 Oct 2019 12:14:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44665) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iLrMg-0002c5-1s; Sat, 19 Oct 2019 12:14:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iLrMf-0001ol-QC; Sat, 19 Oct 2019 12:14:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Sat, 19 Oct 2019 16:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18134 X-GNU-PR-Package: emacs,cc-mode Original-Received: via spool by 18134-submit@debbugs.gnu.org id=B18134.15715015986918 (code B ref 18134); Sat, 19 Oct 2019 16:14:01 +0000 Original-Received: (at 18134) by debbugs.gnu.org; 19 Oct 2019 16:13:18 +0000 Original-Received: from localhost ([127.0.0.1]:53486 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iLrLx-0001nW-RS for submit@debbugs.gnu.org; Sat, 19 Oct 2019 12:13:18 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:33311 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1iLrLt-0001nG-EM for 18134@debbugs.gnu.org; Sat, 19 Oct 2019 12:13:16 -0400 Original-Received: (qmail 69569 invoked by uid 3782); 19 Oct 2019 16:13:11 -0000 Original-Received: from acm.muc.de (p2E5D550D.dip0.t-ipconnect.de [46.93.85.13]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 19 Oct 2019 18:13:10 +0200 Original-Received: (qmail 9571 invoked by uid 1000); 19 Oct 2019 16:13:05 -0000 Content-Disposition: inline In-Reply-To: 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-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:169745 Archived-At: Hello, Stefan and Sam. On Mon, Oct 07, 2019 at 00:42:46 +0200, Stefan Kangas wrote: > found 27.0.50 > thanks > Sam Varshavchik writes: > > I am seeing anomalous behavior in C++ major mode that's triggered by > > long, but not excessively long -- only a few hundred lines -- Doxygen-style > > comments. > > Cursor navigation at the end of the Doxygen comment block in the > > following file (just before the first typedef), and trying to add some > > additional text there, results in 3-5 seconds' worth of delays for > > nearly typed character. > > Highlighting the entire Doxygen comment block: M-x indent-region takes > > several minutes (!) with emacs consuming 100% CPU. > [Snipped a long C++ example file here.] > I can reproduce both issues on current master using the provided example > file. > 1. Editing is very slow after the Doxygen comment block. > 2. Opening the example file under "emacs -Q", pressing C-x h TAB takes > several minutes and sees the emacs process consume 100 % CPU (on one > core at least). Yes. Some optimisation is needed in c-crosses-statement-barrier-p for large blocks of comments. Please try out this patch, and let me know if anything untoward happens: diff -r d84523ed901e cc-engine.el --- a/cc-engine.el Sat Oct 12 08:55:31 2019 +0000 +++ b/cc-engine.el Sat Oct 19 16:06:23 2019 +0000 @@ -1474,10 +1474,13 @@ (progn (if (setq lit-start (c-literal-start from)) ; Have we landed in a string/comment? (goto-char lit-start)) - (c-backward-syntactic-ws) ; ? put a limit here, maybe? + (c-backward-syntactic-ws (c-point 'bopl)) (setq vsemi-pos (point)) (c-at-vsemi-p)))) (throw 'done vsemi-pos)) + ((progn (c-forward-syntactic-ws to) + (>= (point) to)) + (throw 'done nil)) ;; In a string/comment? ((setq lit-range (c-literal-limits from)) (goto-char (cdr lit-range))) > Using the profiler during step 2 gives me: > >- command-execute 59856 97% > > - call-interactively 59856 97% > > - funcall-interactively 59827 97% > > - c-indent-line-or-region 59820 97% > > - c-indent-region 59819 97% > > - c-guess-basic-syntax 59809 97% > > - c-beginning-of-statement-1 39327 63% > > - c-crosses-statement-barrier-p 39105 63% <==== > > - c-backward-sws 22222 36% > > + c-beginning-of-macro 492 0% > > # 1 0% > > c-literal-limits 9508 15% > > c-literal-start 6228 10% > > + c-at-macro-vsemi-p 217 0% > > + c-backward-sws 61 0% > > + c-at-macro-vsemi-p 16 0% > > + c-beginning-of-macro 10 0% > > - c-just-after-func-arglist-p 19872 32% > > - c-beginning-of-statement-1 19872 32% > > - c-crosses-statement-barrier-p 19795 32% > > - c-backward-sws 11424 18% > > + c-beginning-of-macro 287 0% > > # 2 0% > > c-literal-limits 4707 7% > > c-literal-start 3095 5% > > + c-at-macro-vsemi-p 121 0% > > + c-backward-sws 17 0% > > c-beginning-of-macro 2 0% > > c-at-macro-vsemi-p 1 0% > > + c-looking-at-inexpr-block 1 0% > > + c-backward-sws 202 0% > > + c-back-over-member-initializers 106 0% > > + c-determine-limit 103 0% > > + c-parse-state 61 0% > > + c-looking-at-decl-block 55 0% > > + c-looking-at-inexpr-block 19 0% > > + c-syntactic-skip-backward 13 0% > > + c-back-over-member-initializer-braces 4 0% > > + c-beginning-of-decl-1 4 0% > > + c-in-literal 3 0% > > + c-at-macro-vsemi-p 1 0% > > + c-inside-bracelist-p 1 0% > > + c-at-statement-start-p 1 0% > > + c-indent-line 9 0% > > + execute-extended-command 7 0% > > - byte-code 29 0% > > + read-extended-command 29 0% > >+ ... 1784 2% > (Quoted above so Gmail doesn't mess it up...) > Best regards, > Stefan Kangas -- Alan Mackenzie (Nuremberg, Germany).