From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: Slow fontification in C mode buffers Date: Fri, 16 Dec 2011 11:26:17 +0000 Message-ID: <20111216112617.GA3445@acm.acm> References: <83vcpxbxn0.fsf@gnu.org> <20111203151824.GA4566@acm.acm> <87pqfso5d3.fsf@isil.kanru.info> <20111215134332.GA5698@acm.acm> <87y5udizdy.fsf@isil.kanru.info> <20111215181215.GA3464@acm.acm> <87ty51i6vf.fsf@isil.kanru.info> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1324035157 1065 80.91.229.12 (16 Dec 2011 11:32:37 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 16 Dec 2011 11:32:37 +0000 (UTC) Cc: emacs-devel@gnu.org To: Kan-Ru Chen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 16 12:32:29 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RbW1c-0004Ne-FX for ged-emacs-devel@m.gmane.org; Fri, 16 Dec 2011 12:32:28 +0100 Original-Received: from localhost ([::1]:34132 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbW1Z-0004Dd-5Z for ged-emacs-devel@m.gmane.org; Fri, 16 Dec 2011 06:32:25 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:57526) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbW1W-0004DI-6z for emacs-devel@gnu.org; Fri, 16 Dec 2011 06:32:23 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RbW1U-0000jm-Oa for emacs-devel@gnu.org; Fri, 16 Dec 2011 06:32:22 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:32455 helo=mail.muc.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbW1U-0000jT-G5 for emacs-devel@gnu.org; Fri, 16 Dec 2011 06:32:20 -0500 Original-Received: (qmail 64543 invoked by uid 3782); 16 Dec 2011 11:32:18 -0000 Original-Received: from acm.muc.de (pD9556DB9.dip.t-dialin.net [217.85.109.185]) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 16 Dec 2011 12:32:17 +0100 Original-Received: (qmail 3620 invoked by uid 1000); 16 Dec 2011 11:26:17 -0000 Content-Disposition: inline In-Reply-To: <87ty51i6vf.fsf@isil.kanru.info> User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 193.149.48.1 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:146737 Archived-At: Hello, Kanru. On Fri, Dec 16, 2011 at 10:32:20AM +0800, Kan-Ru Chen wrote: > Alan Mackenzie writes: > > Hello, again. > > On Fri, Dec 16, 2011 at 12:16:25AM +0800, Kan-Ru Chen wrote: > >> Alan Mackenzie writes: > >> > Would you please try the following patch and let me know how it goes. > >> > Thanks! > >> No change. c-cheap-inside-bracelist-p seems not called at all. > > Hmm. The place c-cheap-inside-bracelist-p is inside > > c-font-lock-declarations, it can scarcely avoid being called. > > Forgive me for asking you this, but are you sure you byte compiled the > > two files after patching them, etc.? > I forgot that I've set font-lock-maximum-decoration to 2. I tested with > emacs -Q again. The first font-lock is slow, but pretty fast after > that. It occasionally hangs when I C-v the buffer. Below is the > elp-results: You haven't said exactly how many operations, or what, you performed before doing elp-results. In my elp results below, I've: (i) Loaded elp and instrumented the c- package. (ii) Loaded your file. (iii) Done M-x c++-mode (iv) Done M-x elp-results (to clear the accumulated times) (v) M-> (vi) M-x elp-results. I've done this twice, once before my patch, once after. See below. (I've added some blank lines to your lines to make it easier to read.) > Function Name Call Count Elapsed Time Average Time > c-beginning-of-decl-1 1203 269.68204399 0.2241746001 > c-beginning-of-statement-1 1242 269.60064599 0.2170697632 > c-crosses-statement-barrier-p 241143 258.95701700 0.0010738732 > c-font-lock-declarations 179 160.73329700 0.8979513798 > c-find-decl-spots 179 160.732037 0.8979443407 > c-at-macro-vsemi-p 336240 159.34210499 0.0004738939 > c-in-literal 336240 150.66956800 0.0004481012 > c-slow-in-literal 336240 149.19536500 0.0004437168 > c-literal-limits 374344 85.649792999 0.0002287996 > c-beginning-of-syntax 522725 73.183792999 0.0001400043 > c-font-lock-enclosing-decls 179 57.476122000 0.3210956536 > c-backward-sws 1215297 12.826941000 1.055...e-05 > c-beginning-of-macro 746198 4.2144529999 5.647...e-06 > c-parse-state 3326 1.0435710000 0.0003137615 > c-parse-state-1 3326 0.9558269999 0.0002873803 [ .... ] Here are the results. Firstly, before my patch: Function Name Call Count Elapsed Time Average Time c-font-lock-declarations 7 17.564425 2.5092035714 c-find-decl-spots 7 17.564371 2.5091958571 c-beginning-of-decl-1 319 17.295377000 0.0542174827 c-beginning-of-statement-1 333 17.290300000 0.0519228228 c-crosses-statement-barrier-p 40773 14.900494999 0.0003654500 c-at-macro-vsemi-p 41180 9.1869819999 0.0002230932 c-in-literal 41180 7.1732340000 0.0001741921 c-literal-limits 40126 3.7167549999 9.262...e-05 c-backward-sws 184630 2.7831049999 1.507...e-05 c-beginning-of-macro 103323 0.6003159999 5.810...e-06 c-state-safe-place 61257 0.4731989999 7.724...e-06 c-parse-state 326 0.2056420000 0.0006308036 c-parse-state-1 326 0.1998150000 0.0006129294 c-append-to-state-cache 319 0.1097839999 0.0003441504 c-forward-decl-or-cast-1 305 0.0845859999 0.0002773311 Secondly, after the patch. Function Name Call Count Elapsed Time Average Time c-font-lock-declarations 7 0.180145 0.025735 c-find-decl-spots 7 0.1800869999 0.0257267142 c-font-lock-enclosing-decls 7 0.0966709999 0.0138101428 c-beginning-of-decl-1 14 0.0923319999 0.0065951428 c-beginning-of-statement-1 28 0.0913820000 0.0032636428 c-parse-state 326 0.086686 0.0002659079 c-parse-state-1 326 0.0810159999 0.0002485153 c-crosses-statement-barrier-p 147 0.0744919999 0.0005067482 c-forward-decl-or-cast-1 305 0.0568969999 0.0001865475 c-forward-type 617 0.0472009999 7.650...e-05 c-append-to-state-cache 319 0.0459020000 0.0001438934 c-at-macro-vsemi-p 189 0.0408429999 0.0002161005 c-literal-limits 112 0.0402480000 0.0003593571 c-beginning-of-macro 2186 0.0391449999 1.790...e-05 c-in-literal 189 0.0371179999 0.0001963915 [ .... ] c-cheap-inside-bracelist-p 305 0.0109840000 3.601...e-05 Would you please perform the test again, exactly as I have done, and then send me the new results. (The top 15 lines should be enough). Thanks! > -- > Kanru -- Alan Mackenzie (Nuremberg, Germany).