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: Sat, 28 Jun 2014 13:00:59 +0000 Message-ID: <20140628130059.GA4144@acm.acm> References: <20140202192007.GB5365@acm.acm> <831tzl44ox.fsf@gnu.org> <20140205230001.GB3381@acm.acm> <8338jw230j.fsf@gnu.org> <83wqc8sxd2.fsf@gnu.org> <20140625213206.GA3604@acm.acm> <20140627203416.GA4395@acm.acm> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1403960797 12822 80.91.229.3 (28 Jun 2014 13:06:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 28 Jun 2014 13:06:37 +0000 (UTC) Cc: 16526-done@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jun 28 15:06:30 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 1X0sKq-0001iB-8i for geb-bug-gnu-emacs@m.gmane.org; Sat, 28 Jun 2014 15:06:28 +0200 Original-Received: from localhost ([::1]:54667 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0sKp-0006Td-De for geb-bug-gnu-emacs@m.gmane.org; Sat, 28 Jun 2014 09:06:27 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0sKg-0006Sc-Af for bug-gnu-emacs@gnu.org; Sat, 28 Jun 2014 09:06:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X0sKY-0000OR-Ev for bug-gnu-emacs@gnu.org; Sat, 28 Jun 2014 09:06:18 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:44575) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0sKQ-0000N5-F4; Sat, 28 Jun 2014 09:06:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1X0sKQ-0000qz-0f; Sat, 28 Jun 2014 09:06: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: Sat, 28 Jun 2014 13:06:01 +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.14039607373239 (code D ref 16526); Sat, 28 Jun 2014 13:06:01 +0000 Original-Received: (at 16526-done) by debbugs.gnu.org; 28 Jun 2014 13:05:37 +0000 Original-Received: from localhost ([127.0.0.1]:35724 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X0sK0-0000qB-E1 for submit@debbugs.gnu.org; Sat, 28 Jun 2014 09:05:36 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:56575 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1X0sJw-0000pw-FL for 16526-done@debbugs.gnu.org; Sat, 28 Jun 2014 09:05:33 -0400 Original-Received: (qmail 75849 invoked by uid 3782); 28 Jun 2014 13:05:30 -0000 Original-Received: from acm.muc.de (pD951AE09.dip0.t-ipconnect.de [217.81.174.9]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 28 Jun 2014 15:05:28 +0200 Original-Received: (qmail 4474 invoked by uid 1000); 28 Jun 2014 13:00:59 -0000 Content-Disposition: inline In-Reply-To: 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:90935 Archived-At: Hi, Stefan. On Fri, Jun 27, 2014 at 06:54:55PM -0400, Stefan Monnier wrote: > >> Could scan-lists be exhausting some sort of resource in this particular > >> invocation which needs ~0.7s to replenish? Or something like that? > > Or a GC call or something like that? Can't think of any reason why that > > could happen, no. > One way to figure it out is to change your code such that scan-lists is > always called twice in a row. If the time spend is the same both time, > then it's definitely not some sort of resources exhaustion that just > happens to slow down this one particular call. Yes, the second call takes as long as the first call. One thing that did make a big difference was binding parse-sexp-ignore-comments to nil around a call to scan-lists. My two calls to (scan-lists 947171 -1 1) give these results: parse-sexp-ignore-comments | end position time --------------------------------------------------------------------- t | 919215 0.6976802349090576 nil | 899080 0.0021085739135742188 So, although with parse-..-comments nil, the distance traversed was greater, the time taken was a factor ~300 less. This suggests that comments have something to do with the problem. parse_sexp_ignore_comments is only tested twice in scan_lists. The first time, it is only setting up syntax table variables and suchlike after having half-detected a comment closer. The second time, back_comment gets called. It seems likely the problem is in back_comment. AH!!!!! GOT IT!!!! What causes the slowdown is binding open-paren-in-column-0-is-defun-start to nil around the scan-lists. In CC Mode's "engine" parts, that variable is bound to nil. There are good reasons for this (which I can't precisely recall just at the moment). In CC Mode, "'" has string syntax. So any C comment with an odd number of apostrophes looks, to back_comment, like it has an "unbalanced string", and the code ends up at label lossage: in back_comment. Here find_defun_start is called, and this returns BOB when open-paren-..-0 is nil. From here (BOB) the code scans forward to check this putative "unbalanced string". It's a long way from BOB to ~900k, hence the sluggishness. Where do we go from here? > Stefan -- Alan Mackenzie (Nuremberg, Germany).