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#25706: 26.0.50; Slow C file fontification Date: Tue, 1 Dec 2020 12:57:34 +0000 Message-ID: References: <55C404DC-1C29-449F-9A49-B20EDFFCFCEA@acm.org> <27B320DF-8102-4CDF-8C6A-7157EEAACF64@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="37008"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Lars Ingebrigtsen , 25706@debbugs.gnu.org To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Dec 01 13:58:16 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 1kk5EW-0009Yj-6P for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 01 Dec 2020 13:58:16 +0100 Original-Received: from localhost ([::1]:54640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kk5EV-0005pI-6p for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 01 Dec 2020 07:58:15 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kk5EI-0005oM-80 for bug-gnu-emacs@gnu.org; Tue, 01 Dec 2020 07:58:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46697) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kk5EI-0003du-0e; Tue, 01 Dec 2020 07:58:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kk5EI-0001SF-0E; Tue, 01 Dec 2020 07:58:02 -0500 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: Tue, 01 Dec 2020 12:58:01 +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.16068274645570 (code B ref 25706); Tue, 01 Dec 2020 12:58:01 +0000 Original-Received: (at 25706) by debbugs.gnu.org; 1 Dec 2020 12:57:44 +0000 Original-Received: from localhost ([127.0.0.1]:58243 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kk5E0-0001Rm-B3 for submit@debbugs.gnu.org; Tue, 01 Dec 2020 07:57:44 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:14743 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1kk5Dy-0001RX-BL for 25706@debbugs.gnu.org; Tue, 01 Dec 2020 07:57:43 -0500 Original-Received: (qmail 69473 invoked by uid 3782); 1 Dec 2020 12:57:35 -0000 Original-Received: from acm.muc.de (p4fe15c10.dip0.t-ipconnect.de [79.225.92.16]) by localhost.muc.de (tmda-ofmipd) with ESMTP; Tue, 01 Dec 2020 13:57:34 +0100 Original-Received: (qmail 6870 invoked by uid 1000); 1 Dec 2020 12:57:34 -0000 Content-Disposition: inline In-Reply-To: <27B320DF-8102-4CDF-8C6A-7157EEAACF64@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:194733 Archived-At: Hello, Mattias. On Tue, Dec 01, 2020 at 13:03:21 +0100, Mattias Engdegård wrote: > 1 dec. 2020 kl. 10.21 skrev Alan Mackenzie : > > (i) Take the first 10% of the original 4MB file, and save it in a > > different file. > > (ii) Fontify that file from top to bottom: according to EPL, 292s > > (iii) Insert 9 new lines "{}" every 10% of that new file. > > (iv) Fontify the amended file top to bottom: new time 98s. > > That's a factor of 3 different. > Thank you, quite remarkable and a very useful piece of information! > Please let me curb some unwarranted optimism that I'm guilty of > engendering: > We have been measuring slightly different things. Being lazy, I timed > the fontification in one go: > (font-lock-ensure (point-min) (point-max)) > which took about 65 s originally and went down to about 24 s by fixing > the regexps as previously mentioned. Much better but still not > wonderful. > You have measured interactive scrolling which is more realistic, but > fontifying the buffer piecemeal it exercises slightly different code > paths. Fixing those regexps helps but not as much, and clearly more > work is needed. > (By the way, could you direct me to your benchmark code? I don't think > I have it.) Just something I threw together a few years ago, and use regularly on xdisp.c to check nothing's gone seriously slow/see how well my latest optimisation has worked. (defmacro time-it (&rest forms) "Time the running of a sequence of forms using `float-time'. Call like this: \"M-: (time-it (foo ...) (bar ...) ...)\"." `(let ((start (float-time))) ,@forms (- (float-time) start))) (defun time-scroll (&optional arg) (interactive "P") (message "%s" (time-it (condition-case nil (while t (if arg (scroll-down) (scroll-up)) (sit-for 0)) (error nil))))) Put point at the start or end of a buffer and do M-: (time-scroll) or M-: (time-scroll t) as appropriate. > Still, improving regexps is clearly beneficial. Reducing allocation can > be effective as well; a fair bit of the profile is in the GC. How much time does this regexp change save on a "normal" file, such as src/xdisp.c? -- Alan Mackenzie (Nuremberg, Germany).