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: c-beginning-of-defun in the past and presence Date: Wed, 24 Sep 2014 22:25:54 +0000 Message-ID: <20140924222554.GA13747@acm.acm> References: <541E9C22.3030308@gmx.at> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1411597925 4444 80.91.229.3 (24 Sep 2014 22:32:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 24 Sep 2014 22:32:05 +0000 (UTC) Cc: emacs-devel To: martin rudalics Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 25 00:31:58 2014 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 1XWv6M-00014t-8W for ged-emacs-devel@m.gmane.org; Thu, 25 Sep 2014 00:31:58 +0200 Original-Received: from localhost ([::1]:35241 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XWv6L-0001J3-SL for ged-emacs-devel@m.gmane.org; Wed, 24 Sep 2014 18:31:57 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46860) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XWv6C-0001Iq-2Q for emacs-devel@gnu.org; Wed, 24 Sep 2014 18:31:55 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XWv64-0000BA-JS for emacs-devel@gnu.org; Wed, 24 Sep 2014 18:31:48 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:12482 helo=mail.muc.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XWv64-0000A2-9d for emacs-devel@gnu.org; Wed, 24 Sep 2014 18:31:40 -0400 Original-Received: (qmail 40777 invoked by uid 3782); 24 Sep 2014 22:31:32 -0000 Original-Received: from acm.muc.de (pD951B7DB.dip0.t-ipconnect.de [217.81.183.219]) by colin.muc.de (tmda-ofmipd) with ESMTP; Thu, 25 Sep 2014 00:31:32 +0200 Original-Received: (qmail 14669 invoked by uid 1000); 24 Sep 2014 22:25:54 -0000 Content-Disposition: inline In-Reply-To: <541E9C22.3030308@gmx.at> 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: FreeBSD 8.x 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:174695 Archived-At: Hi, Martin. On Sun, Sep 21, 2014 at 11:36:34AM +0200, martin rudalics wrote: > Dear Alan and friends > Running with emacs -Q > (with-current-buffer (find-file-noselect "~/src/xdisp.c") > (elp-instrument-function 'c-beginning-of-defun) > (goto-char (point-max)) > (condition-case nil > (beginning-of-defun 1000) > (error nil)) > (elp-results)) > gets me here as elapsed time > Emacs 24.3: 1.672 > Emacs 24.4: 4.516 > Emacs trunk: 27.375 > Running with emacs -Q > (with-current-buffer (find-file-noselect "~/src/xdisp.c") > (elp-instrument-function 'c-beginning-of-defun) > (goto-char (point-max)) > (condition-case nil > (while (beginning-of-defun) nil) > (error nil)) > (elp-results)) > gets me here > Call Count Elapsed Time Average Time > Emacs 24.3: 353 23.842999999 0.0675439093 > Emacs 24.4: 353 43.000000000 0.1218130311 > Emacs trunk: 353 136.48399999 0.3866402266 > Please try to make things behave reasonably again. , for some value of "reasonably". ;-) I've repeated your timings for the first case (i.e. (beginning-of-defun 1000)) and get pretty much the same results you do. What is taking the time in the trunk is (presumably) backwards `scan-lists's, which you can see if you elp-instrument `scan-lists' too. It is taking longer since Emacs-23 because `open-paren-in-column-0-is-defun-start' is being bound to nil in `c-parse-state' to avoid buggy processing. But I think you know this anyway. Stefan committed revision 117351 on 2014-07-04 to the Emacs-24 branch, which should have helped. This should have been merged into the trunk by revision 117499, committed by Glenn on 2014-07-08, and looking at the source code, it appears it did. I don't know, at this stage, why the trunk is so much slower that the Emacs-24 branch. I'll need to have a look at this. In the second case ((while (beginning-of-defun) nil)), it cannot but be much slower than the first case, since the expensive analysis to move from the top level '{' to BOD is repeated for every defun, rather than just being done once, when c-beginning-of-defun is given its repeat count. I expect the reason for the slow down between Emacs-24 and trunk will turn out to be the same as for the first case. > Thanks, martin -- Alan Mackenzie (Nuremberg, Germany).