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: Wed, 21 Dec 2011 10:56:26 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

Hello, Kanru.

On Sun, Dec 18, 2011 at 12:06:00AM +0800, Kan-Ru Chen wrote:

> Please forgive me for using the other files, it is closer to the real
> case. You can get the file from

> https://hg.mozilla.org/mozilla-central/raw-file/tip/dom/base/nsDOMClassInfo.cpp

OK, now I understand.  I feel your pain.  ;-(

> (i) Loaded elp and instrumented the c- package.
> (ii) Loaded nsDOMClassInfo.cpp
> (iii) Done M-x c++-mode
> (iv) Done M-x elp-results (to clear the accumulated times)
> (v) C-s battery until failing to find 
> (vi) M-x elp-results.

> Before:

> c-beginning-of-decl-1                          201         13.065947999  
> 0.0650047164
> c-beginning-of-statement-1                     229         13.061191     
> 0.0570357685
> c-crosses-statement-barrier-p                  35466       11.622212999  
> 0.0003277001
> c-font-lock-declarations                       16          9.4090929999  
> 0.5880683124
> c-find-decl-spots                              16          9.4089879999  
> 0.5880617499

> c-at-macro-vsemi-p                             46569       6.6139159999  
> 0.0001420240
> c-in-literal                                   46569       5.4569670000  
> 0.0001171802
> c-literal-limits                               51666       3.1393819999  
> 6.076...e-05
> c-backward-sws                                 176682      1.6644079999  
> 9.420...e-06
> c-beginning-of-macro                           104078      0.5568430000  
> 5.350...e-06

> c-state-safe-place                             72459       0.3154430000  
> 4.353...e-06
> c-parse-state                                  225         0.1421229999  
> 0.0006316577
> c-parse-state-1                                225         0.1385559999  
> 0.0006158044
> c-font-lock-enclosing-decls                    16          0.1365140000  
> 0.0085321250
> c-append-to-state-cache                        196         0.0641449999  
> 0.0003272704

> After:

> c-beginning-of-decl-1                          137         9.6732900000  
> 0.0706079562
> c-beginning-of-statement-1                     165         9.6693369999  
> 0.0586020424
> c-crosses-statement-barrier-p                  25584       8.5505400000  
> 0.0003342143
> c-font-lock-declarations                       16          6.059768      
> 0.3787355
> c-find-decl-spots                              16          6.059666      
> 0.378729125

> c-at-macro-vsemi-p                             35149       4.7420429999  
> 0.0001349126
> c-in-literal                                   35149       4.0154739999  
> 0.0001142414
> c-literal-limits                               38962       2.5425719999  
> 6.525...e-05
> c-backward-sws                                 128214      1.1421259999  
> 8.907...e-06
> c-beginning-of-macro                           78145       0.3845660000  
> 4.921...e-06

> c-state-safe-place                             54703       0.2419970000  
> 4.423...e-06
> c-parse-state                                  317         0.1464209999  
> 0.0004618958
> c-font-lock-enclosing-decls                    16          0.137945      
> 0.0086215625
> c-parse-state-1                                317         0.1331939999  
> 0.0004201703
> c-font-lock-declarators                        24          0.065522      
> 0.0027300833

It looks like my latest change is saving ~25% of the runtime.  That is
not enough, not nearly enough.  Also, your hardware is _much_ faster than
mine.  ;-)

The problem is quite clear - because of the dearth of
semicolons/right-braces, searching backwards to the beginning of
statements (function "c-beginning-of-statement-1") takes forever during
fontification.  To solve this will involve putting a limit on backward
search and somehow coping with not finding BO-statement.

This is going to be a lot of work, and I'm not going to be able to get it
finished this year.  Sorry.  But I'm sure the bug can be fixed.  

In the meantime, I suggest turning font-lock off for this file.

> -- Kanru

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

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