From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#25706: 26.0.50; Slow C file fontification Date: Wed, 2 Dec 2020 16:06:43 +0100 Message-ID: <53CC4F6E-716E-4D4B-8903-F32CCB676163@acm.org> References: <55C404DC-1C29-449F-9A49-B20EDFFCFCEA@acm.org> <27B320DF-8102-4CDF-8C6A-7157EEAACF64@acm.org> <956BCA08-0376-4FAD-B1F7-2087C03F6181@acm.org> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16641"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Lars Ingebrigtsen , 25706@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 02 16:08:25 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 1kkTk0-0004DF-23 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 02 Dec 2020 16:08:24 +0100 Original-Received: from localhost ([::1]:55636 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kkTjz-0003y2-46 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 02 Dec 2020 10:08:23 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kkTig-000375-Pn for bug-gnu-emacs@gnu.org; Wed, 02 Dec 2020 10:07:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53489) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kkTig-00011A-H7; Wed, 02 Dec 2020 10:07:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kkTig-0000yy-BZ; Wed, 02 Dec 2020 10:07:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Wed, 02 Dec 2020 15:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25706 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 25706-submit@debbugs.gnu.org id=B25706.16069216163751 (code B ref 25706); Wed, 02 Dec 2020 15:07:02 +0000 Original-Received: (at 25706) by debbugs.gnu.org; 2 Dec 2020 15:06:56 +0000 Original-Received: from localhost ([127.0.0.1]:36799 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kkTiZ-0000yR-L8 for submit@debbugs.gnu.org; Wed, 02 Dec 2020 10:06:55 -0500 Original-Received: from mail1469c50.megamailservers.eu ([91.136.14.69]:57240 helo=mail102c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kkTiW-0000y4-HD for 25706@debbugs.gnu.org; Wed, 02 Dec 2020 10:06:54 -0500 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1606921605; bh=ZeHCDT52G7JivR/mK0vNBWyZB45lR7zygmHvrHHdbiA=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=ngpTYzjDl71R1t7AS0ZAIDl756LnxVXq/po3ykvKTg5SAVu8SvnS9RqbFIYMg/KaD nnBok3n7FnQ5TQhyyUHfMPJUzlqnCEUKY+jElVe0HX31qsdPsv1PPnAgisnRtGiXeo On0pqqUM3Y2ktw0wzsdFkM2OwtfnwN9UOkE627uo= Feedback-ID: mattiase@acm.or Original-Received: from stanniol.lan (c-064ae655.032-75-73746f71.bbcust.telenor.se [85.230.74.6]) (authenticated bits=0) by mail102c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 0B2F6hwW022452; Wed, 2 Dec 2020 15:06:45 +0000 In-Reply-To: X-Mailer: Apple Mail (2.3445.104.17) X-CTCH-RefID: str=0001.0A782F24.5FC7AD85.00C9, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=M8Qz1B4s c=1 sm=1 tr=0 a=Ni+dBsiEfW2GqKMPYZim9A==:117 a=Ni+dBsiEfW2GqKMPYZim9A==:17 a=kj9zAlcOel0A:10 a=M51BFTxLslgA:10 a=VwQbUJbxAAAA:8 a=yuzmvS1Ki6nyFtx0mO0A:9 a=CjuIK1q_8ugA:10 a=AjGcO6oz07-iQ99wixmX:22 a=pHzHmUro8NiASowvMSCR:22 a=Ew2E2A-JSTLzCXPT_086:22 X-Origin-Country: SE 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:194805 Archived-At: 2 dec. 2020 kl. 11.15 skrev Alan Mackenzie : > I spent yesterday evening investigating the "CC Mode state cache", = i.e. > the thing that keeps track of braces and open parens/brackets. I = found a > place where it was unnecessarily causing scanning from BOB, and fixed = it > provisionally. On doing a (time-scroll) on the entire monster buffer, = it > saved ~25% of the run time. There is definitely something else = scanning > repeatedly from BOB - the screen scrolling was more sluggish near the = end > of the buffer than half way through. >=20 > Here's that provisional patch, if you'd like to try it: Thanks, it does indeed speed things up in various synthetic tests as = well. You are right that there still seems to be at least a quadratic = term left. > Because many situations are context dependent, particularly in C++ = Mode. > That raises the possibility of not tracking context for these monster > files.h, but how would one distinguish between these different "types" = of > CC Mode file? Please bear with my lack of understanding of how this works, but what I = meant is that a preprocessor line neither affects nor is affected by the = context, so until something other than such lines (and comments) are = found in the region being fontified, there should be no need to = determine the context in the first place. > I put some instrumentation on it yesterday evening, and it is apparent > that it is getting called four times in succession from the same point > with N =3D 500, 1000, 1000, 1000. This screams out for a simple = cache, > which I intend to implement. Also, maybe I should always call > c-determine-limit with the same N, and perhaps even cut N to 500 in = all > cases. Or something like that. It is clear that a great deal of run > time could be saved, here. >=20 > Also, I intend to track down whatever the other thing is that is = scanning > from the previous brace or BOB. It may be possible to alter the = handling > of these monster files from impossibly slow to somewhat sluggish. There is optimism then! Some of the files from the Linux tree mentioned = by Ravine Var are also good to try, such as = https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/d= rivers/gpu/drm/amd/include/asic_reg/bif/bif_5_1_sh_mask.h