emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Slow fontification in C mode buffers


From: Alan Mackenzie
Subject: Re: Slow fontification in C mode buffers
Date: Fri, 16 Dec 2011 11:26:17 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

Hello, Kanru.

On Fri, Dec 16, 2011 at 10:32:20AM +0800, Kan-Ru Chen wrote:
> Alan Mackenzie <address@hidden> writes:

> > Hello, again.

> > On Fri, Dec 16, 2011 at 12:16:25AM +0800, Kan-Ru Chen wrote:
> >> Alan Mackenzie <address@hidden> 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).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]