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: Sat, 3 Dec 2011 15:18:24 +0000 Message-ID: <20111203151824.GA4566@acm.acm> References: <83vcpxbxn0.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1322925859 1323 80.91.229.12 (3 Dec 2011 15:24:19 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 3 Dec 2011 15:24:19 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Dec 03 16:24:15 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 1RWrRn-0006xl-FE for ged-emacs-devel@m.gmane.org; Sat, 03 Dec 2011 16:24:15 +0100 Original-Received: from localhost ([::1]:51057 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RWrRm-0002Uf-UY for ged-emacs-devel@m.gmane.org; Sat, 03 Dec 2011 10:24:14 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:40391) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RWrRk-0002Ua-DH for emacs-devel@gnu.org; Sat, 03 Dec 2011 10:24:13 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RWrRj-0008LP-1N for emacs-devel@gnu.org; Sat, 03 Dec 2011 10:24:12 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:18674 helo=mail.muc.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RWrRi-0008LC-L4 for emacs-devel@gnu.org; Sat, 03 Dec 2011 10:24:10 -0500 Original-Received: (qmail 58082 invoked by uid 3782); 3 Dec 2011 15:24:08 -0000 Original-Received: from acm.muc.de (pD951A68E.dip.t-dialin.net [217.81.166.142]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 03 Dec 2011 16:24:07 +0100 Original-Received: (qmail 4579 invoked by uid 1000); 3 Dec 2011 15:18:24 -0000 Content-Disposition: inline In-Reply-To: <83vcpxbxn0.fsf@gnu.org> 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:146463 Archived-At: 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).