From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#16526: 24.3.50; scroll-conservatively & c-mode regression Date: Wed, 25 Jun 2014 21:32:06 +0000 Message-ID: <20140625213206.GA3604@acm.acm> References: <83txcl75nj.fsf@gnu.org> <52EAA0C9.1090000@gmx.at> <834n4j5d3k.fsf@gnu.org> <20140202174050.GA5365@acm.acm> <837g9d4cde.fsf@gnu.org> <20140202192007.GB5365@acm.acm> <831tzl44ox.fsf@gnu.org> <20140205230001.GB3381@acm.acm> <8338jw230j.fsf@gnu.org> <83wqc8sxd2.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1403732250 31307 80.91.229.3 (25 Jun 2014 21:37:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 25 Jun 2014 21:37:30 +0000 (UTC) Cc: 16526-done@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jun 25 23:37:23 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1Wzusb-0002uE-TU for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 Jun 2014 23:37:22 +0200 Original-Received: from localhost ([::1]:41107 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wzusb-00046s-Fm for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 Jun 2014 17:37:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39413) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzusT-00046a-9u for bug-gnu-emacs@gnu.org; Wed, 25 Jun 2014 17:37:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WzusO-0000TO-Co for bug-gnu-emacs@gnu.org; Wed, 25 Jun 2014 17:37:13 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41495) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzusJ-0000SZ-6O; Wed, 25 Jun 2014 17:37:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WzusI-0006WZ-M9; Wed, 25 Jun 2014 17:37:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Wed, 25 Jun 2014 21:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 16526 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 16526-done@debbugs.gnu.org id=D16526.140373220325038 (code D ref 16526); Wed, 25 Jun 2014 21:37:02 +0000 Original-Received: (at 16526-done) by debbugs.gnu.org; 25 Jun 2014 21:36:43 +0000 Original-Received: from localhost ([127.0.0.1]:60878 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wzurz-0006Vl-5X for submit@debbugs.gnu.org; Wed, 25 Jun 2014 17:36:43 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:25128 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wzurx-0006Va-1o for 16526-done@debbugs.gnu.org; Wed, 25 Jun 2014 17:36:42 -0400 Original-Received: (qmail 91540 invoked by uid 3782); 25 Jun 2014 21:36:39 -0000 Original-Received: from acm.muc.de (pD9518C32.dip0.t-ipconnect.de [217.81.140.50]) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 25 Jun 2014 23:36:38 +0200 Original-Received: (qmail 3860 invoked by uid 1000); 25 Jun 2014 21:32:06 -0000 Content-Disposition: inline In-Reply-To: <83wqc8sxd2.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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:90815 Archived-At: Hi, Eli. On Sun, Jun 22, 2014 at 07:49:29PM +0300, Eli Zaretskii wrote: > > Date: Thu, 06 Feb 2014 08:01:32 +0200 > > From: Eli Zaretskii > > Cc: rudalics@gmx.at, 16526@debbugs.gnu.org > > > Date: Wed, 5 Feb 2014 23:00:01 +0000 > > > Cc: rudalics@gmx.at, 16526@debbugs.gnu.org > > > From: Alan Mackenzie > > > > Do you need help in identifying what takes 11 sec in the unoptimized > > > > build to traverse a few lines? Just to recap what was taking 11 seconds. With xdisp.c revision 116189 newly loaded into an emacs -Q, do (goto-char 948757). This emacs was built with CFLAGS='-O0 -g3' and --enable-checking='yes,glyphs' Yes, I would like some help, please. [ From this point on, all my timings are with reference to my normal optimised build of Emacs 24.3 (though the version doesn't make any difference). ] I elp-instrument-package "c-" and elp-instrument-function "scan-lists". After the (goto-char 948757), my elp-results looks like this (with blank lines added for clarity): c-font-lock-fontify-region 6 1.12553871 0.187589785 scan-lists 2359 0.9151535670 0.0003879413 c-parse-state 200 0.8451750940 0.0042258754 c-parse-state-1 200 0.7929608409 0.0039648042 c-font-lock-enclosing-decls 6 0.7164836050 0.1194139341 c-append-lower-brace-pair-to-state-cache 4 0.7143309609 0.1785827402 c-font-lock-declarations 6 0.255113226 0.0425188710 c-find-decl-spots 6 0.255040271 0.0425067118 c-backward-over-enum-header 62 0.1797902729 0.0028998431 c-font-lock-complex-decl-prepare 6 0.0648537759 0.0108089626 Clearly c-append-lower-brace-pair-to-state-cache is problematic. I then timed each of the four calls of c-append-lower-...-cache. Three were rapid, one took 0.6977412700653076 seconds. I then zeroed in on the main loop (the only loop, really) and when I found it was hardly looping at all (a mere four calls of scan-lists altogether). I then timed _each_ individual call of scan-lists, and found that the call (scan-lists 947171 -1 1) took 0.6962041854858398 seconds. (947171 is just inside the closing brace of syms_of_xdisp, and the result of the scan is 919215, the function's opening brace.) How come this scan-lists is taking 0.7 seconds? When I call this from M-: (let ((thyme (float-time))) (scan-lists 947171 -1 1) (- (float-time) thyme)) , I get 0.013844966888427734 seconds, 2% of the above figure. It is true that in CC-Mode, that bit of the code is deeply nested inside some macros which manipulate text properties. But when I include these in the manual call of scan-lists, they barely make any difference. How can this one single scan-lists called from CC Mode be so slow, yet the identical call from the minibuffer be 50 times as fast? My understanding is that scan-lists is a primitive operation, unaffected by virtually any context (apart from specific things like parse-sexp-ignore-comments and syntax-table text properties which are meant to affect it). I'm at a loss for ideas right now. Suggestions would be most welcome. -- Alan Mackenzie (Nuremberg, Germany).