[Top][All Lists]

[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: Sat, 3 Dec 2011 15:18:24 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

Hi, Eli.

On Sat, Dec 03, 2011 at 03:19:47PM +0200, Eli Zaretskii wrote:
> Did anyone else notice that scrolling the first time through a very
> large comment in C mode became extremely slow lately?  For example,
> visit xdisp.c in "emacs -Q", type M-<, then hit C-v several times in
> quick succession.  Then watch in disbelief how long it takes for Emacs
> to scroll by these several screenfuls.  In my case (6.5 year old
> hardware), I even see the "hourglass cursor" kick in, and the CPU
> meter shows 100% utilization of one execution unit for about 5
> seconds.

> If you then type M-< and again hit C-v several times, scrolling will
> be at its usual speed.  Scrolling outside of large comments is also
> reasonably fast, even for the first time.

> Therefore, my prime suspect is font-lock, which is triggered by the
> need to display a portion of the buffer that was not fontified yet.
> This suspicion is corroborated by the fact that jit-stealth font-lock
> of xdisp.c causes extremely high peaks of CPU usage, and Emacs
> response time becomes very sluggish.

> Is there something in C Mode's arrangements for fontification,
> specifically related to comments, that was changed lately and that can
> explain this slowdown?

By a happy coincidence, I've just tracked down another sluggishness (in
large array initialisations, reported by Peter Milliken on bug-cc-mode)
which looks to have exactly the same cause, namely
`c-font-lock-enclosing-decls' which fontifies the innards of a
struct/union/enum when jit-lock etc. starts in the middle of it.

I've got a solution, though it's not fully worked out yet.  Give me till
later on today, possibly tomorrow.

Alan Mackenzie (Nuremberg, Germany).

reply via email to

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