From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Scrolling huge buffers and cc-mode Date: Tue, 18 Dec 2012 19:30:57 +0200 Message-ID: <83txrjp8ry.fsf@gnu.org> References: <50D03DBD.5000704@yandex.ru> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1355851858 28206 80.91.229.3 (18 Dec 2012 17:30:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 18 Dec 2012 17:30:58 +0000 (UTC) Cc: emacs-devel@gnu.org To: Dmitry Antipov , Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Dec 18 18:31:12 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Tl10V-0006wD-Cg for ged-emacs-devel@m.gmane.org; Tue, 18 Dec 2012 18:31:07 +0100 Original-Received: from localhost ([::1]:59069 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tl10H-0000N6-Ox for ged-emacs-devel@m.gmane.org; Tue, 18 Dec 2012 12:30:53 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:56564) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tl10F-0000LW-0j for emacs-devel@gnu.org; Tue, 18 Dec 2012 12:30:52 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tl10D-00084j-1D for emacs-devel@gnu.org; Tue, 18 Dec 2012 12:30:50 -0500 Original-Received: from mtaout20.012.net.il ([80.179.55.166]:57854) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tl10C-00084N-P9 for emacs-devel@gnu.org; Tue, 18 Dec 2012 12:30:48 -0500 Original-Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0MF800C00LXIR900@a-mtaout20.012.net.il> for emacs-devel@gnu.org; Tue, 18 Dec 2012 19:30:44 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MF800AWOLZ7WG01@a-mtaout20.012.net.il>; Tue, 18 Dec 2012 19:30:44 +0200 (IST) In-reply-to: <50D03DBD.5000704@yandex.ru> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 80.179.55.166 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:155651 Archived-At: > Date: Tue, 18 Dec 2012 13:56:13 +0400 > From: Dmitry Antipov > > Attached is a C++ source file to reproduce the painfully slow scrolling > under cc-mode. Test is simple: just visit it and press , or , > or whatever else bind to scroll-up-command, until buffer end is reached. > The file is ~900K; when scrolling reaches 50%, everything is stopped, may > be up to a few minutes (!), there is no response to any keyboard input > including C-g, and CPU consumption is ~80-90%. After that, scrolling is > resumed, but it's still _very_ slow. This looks like a C++ issue only > since xdisp.c of nearly the same size may be scrolled much faster. (Added Alan to the discussion.) It looks like this is due to font-lock (invoked by JIT Lock each time a new screenful is about to be displayed) that is specific to C++. To see this, fontify the whole buffer, or turn on JIT Stealth and wait for it to finish, and then try scrolling -- you will see a normal scrolling speed. While JIT Stealth was working, I noticed that one of my cores was busy 100%. So I turned on the profiler, and the result of running it for about 1 minute is below. If I understand correctly, it blames scan-sexps for most of the CPU load. - apply 25518 84% - jit-lock-stealth-fontify 25517 84% - jit-lock-fontify-now 25517 84% - byte-code 25517 84% - run-hook-with-args 25517 84% - font-lock-fontify-region 25517 84% - c-font-lock-fontify-region 25517 84% - font-lock-default-fontify-region 25495 84% - font-lock-fontify-keywords-regio 25495 84% - c-font-lock-enclosing-decls 25389 83% - c-beginning-of-decl-1 25388 83% - byte-code 25388 83% - c-beginning-of-statement 25388 83% - byte-code 25387 83% - byte-code 25373 83% scan-sexps 25372 83% scan-lists 1 0% - c-backward-sws 5 0% looking-at 4 0% previous-single-pr 1 0% - c-looking-at-inexpr- 5 0% looking-at 3 0% c-backward-sws 2 0% - c-beginning-of-macro 2 0% beginning-of-line 2 0% - c-crosses-statement- 2 0% append 2 0% - c-at-macro-vsemi-p 1 0% - c-backward-sws 1 0% looking-at 1 0% + c-parse-state 1 0% + c-font-lock-declarations 97 0% + # 5 0% + cwarn-font-lock-match-referenc 2 0% + c-font-lock-<>-arglists 2 0% + mapc 22 0% + auto-revert-buffers 1 0% + timer-event-handler 2496 8% + byte-code 1211 3% + redisplay_internal (C function) 392 1% Automatic GC 294 0% + call-interactively 226 0% + jit-lock-stealth-fontify 95 0% + jit-lock-fontify-now 40 0% + run-hook-with-args 8 0% + font-lock-fontify-region 3 0% + profiler-calltree-walk 1 0% tooltip-hide 1 0% + list 1 0% + input-pending-p 1 0%