all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Kan-Ru Chen <kanru@kanru.info>
Cc: emacs-devel@gnu.org
Subject: Re: Slow fontification in C mode buffers
Date: Fri, 16 Dec 2011 11:26:17 +0000	[thread overview]
Message-ID: <20111216112617.GA3445@acm.acm> (raw)
In-Reply-To: <87ty51i6vf.fsf@isil.kanru.info>

Hello, Kanru.

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

> > Hello, again.

> > On Fri, Dec 16, 2011 at 12:16:25AM +0800, Kan-Ru Chen wrote:
> >> Alan Mackenzie <acm@muc.de> 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	other threads:[~2011-12-16 11:26 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-03 13:19 Slow fontification in C mode buffers Eli Zaretskii
2011-12-03 15:03 ` Sujith
2011-12-03 15:14   ` Eli Zaretskii
2011-12-03 15:32     ` Sujith
2011-12-03 15:18 ` Alan Mackenzie
2011-12-03 16:19   ` Eli Zaretskii
2011-12-13 15:31   ` Kan-Ru Chen
2011-12-14 11:19     ` Alan Mackenzie
2011-12-14 11:30     ` Alan Mackenzie
2011-12-14 12:23       ` Alan Mackenzie
2011-12-14 13:14     ` Alan Mackenzie
2011-12-14 15:02       ` Kan-Ru Chen
2011-12-15 13:43     ` Alan Mackenzie
2011-12-15 16:16       ` Kan-Ru Chen
2011-12-15 18:12         ` Alan Mackenzie
2011-12-16  2:32           ` Kan-Ru Chen
2011-12-16 11:26             ` Alan Mackenzie [this message]
2011-12-17 16:06               ` Kan-Ru Chen
2011-12-21 10:56                 ` Alan Mackenzie
2011-12-21 13:33                   ` Geoff Gole
2011-12-21 16:04                     ` Alan Mackenzie
2011-12-21 16:48                       ` Geoff Gole
2011-12-21 18:06                         ` Alan Mackenzie
2011-12-21 18:16                     ` Eli Zaretskii
2011-12-21 18:32                       ` Geoff Gole
2011-12-21 19:35                         ` Eli Zaretskii
2011-12-23  1:56                     ` Kentaro NAKAZAWA
2011-12-23 12:03                       ` Alan Mackenzie
2012-01-06 22:08                       ` Alan Mackenzie
2012-01-07  0:09                         ` Kentaro NAKAZAWA
2012-01-07 13:50                           ` Alan Mackenzie
2012-01-08  1:26                             ` Kentaro NAKAZAWA
2012-01-08 10:05                               ` Alan Mackenzie
2012-01-20 17:26                               ` Alan Mackenzie
2012-02-06 16:14                                 ` Kentaro NAKAZAWA
2011-12-22 16:06                   ` Kan-Ru Chen
2012-01-13 19:12                 ` Alan Mackenzie
2012-01-14  9:12                   ` Kan-Ru Chen
2012-01-15 21:12                 ` Alan Mackenzie
2012-01-22  4:20                   ` Kan-Ru Chen
2011-12-03 21:15 ` Alan Mackenzie
2011-12-04  6:00   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111216112617.GA3445@acm.acm \
    --to=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --cc=kanru@kanru.info \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.