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. The purpose of revision 116070. Date: Sat, 25 Jan 2014 20:27:21 +0000 Message-ID: <20140125202721.GA3630__19391.3637580865$1390681899$gmane$org@acm.acm> References: <52E38286.1050306@gmx.at> <838uu4cq11.fsf@gnu.org> <52E3D131.2090705@gmx.at> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1390681887 26296 80.91.229.3 (25 Jan 2014 20:31:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 25 Jan 2014 20:31:27 +0000 (UTC) Cc: 16526@debbugs.gnu.org To: martin rudalics , Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jan 25 21:31: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 1W79t3-0003GT-RP for geb-bug-gnu-emacs@m.gmane.org; Sat, 25 Jan 2014 21:31:30 +0100 Original-Received: from localhost ([::1]:52467 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W79t3-0000Xz-Ea for geb-bug-gnu-emacs@m.gmane.org; Sat, 25 Jan 2014 15:31:29 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48075) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W79ss-0000PJ-Gl for bug-gnu-emacs@gnu.org; Sat, 25 Jan 2014 15:31:25 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W79sk-0005kW-Ul for bug-gnu-emacs@gnu.org; Sat, 25 Jan 2014 15:31:18 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:50151) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W79sc-0005jS-W0; Sat, 25 Jan 2014 15:31:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1W79sc-0002dx-GC; Sat, 25 Jan 2014 15:31:02 -0500 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, 25 Jan 2014 20:31: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-submit@debbugs.gnu.org id=B16526.13906818428761 (code B ref 16526); Sat, 25 Jan 2014 20:31:02 +0000 Original-Received: (at 16526) by debbugs.gnu.org; 25 Jan 2014 20:30:42 +0000 Original-Received: from localhost ([127.0.0.1]:35937 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W79sG-0002FL-4E for submit@debbugs.gnu.org; Sat, 25 Jan 2014 15:30:41 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:16474 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W79sA-000283-RW for 16526@debbugs.gnu.org; Sat, 25 Jan 2014 15:30:36 -0500 Original-Received: (qmail 69487 invoked by uid 3782); 25 Jan 2014 20:30:33 -0000 Original-Received: from acm.muc.de (pD95187E7.dip0.t-ipconnect.de [217.81.135.231]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 25 Jan 2014 21:30:32 +0100 Original-Received: (qmail 4094 invoked by uid 1000); 25 Jan 2014 20:27:21 -0000 Content-Disposition: inline In-Reply-To: <52E3D131.2090705@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-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:84013 Archived-At: Hello, Martin and Eli. On Sat, Jan 25, 2014 at 03:58:57PM +0100, martin rudalics wrote: > > Probably. I actually don't understand how come scroll-conservatively > > affects non-scrolling commands. Can you elaborate on that? > How should I know? I suppose redisplay_window eventually winds up > calling the fontification function and sooner or later the c-code calls > back_comment. Yes. > > You also mentioned back_comment doing something unreasonable. Can you > > expand on that, too? This part specifically I don't understand: > >> What happens is that apparently back_comment 530 times scans the buffer > >> from the beginning of the buffer to the first comment before the current > >> position where the list of current positions goes like this: > > Since the problem happens as result of beginning-of-buffer, why would > > back_comment need to "scan the buffer from the beginning of the buffer > > to the first comment before the current position"? And what is the > > current position in this case? > I earlier posted the first and last positions here: > (780 14143 15852 18026 20032 20480 21464 21846 22845 23484 25453 26968 > ... > 942907 943099 944334 948653 948830 948653 948830 948653 948830 948653 > 948830 780 12) > You can try by yourself. I gathered the positions in the following > excerpt > find_defun_start (ptrdiff_t pos, ptrdiff_t pos_byte) > { > ptrdiff_t opoint = PT, opoint_byte = PT_BYTE; > if (!open_paren_in_column_0_is_defun_start) > { > find_start_value = BEGV; > find_start_value_byte = BEGV_BYTE; > find_start_buffer = current_buffer; > find_start_modiff = MODIFF; > find_start_begv = BEGV; > find_start_pos = pos; > <---------------------------- right here > return BEGV; > } > > Btw, if I disable font-lock ("M-x global-font-lock-mode RET") before > > repeating the recipe, the move to bob is instantaneous, and turning on > > font-lock after that doesn't seem to have any adverse effects on > > responsiveness. > Sure. The problem happens obviously via jit-lock. But IMHO disabling > `open-paren-in-column-0-is-defun-start' IS asking for trouble as long as > back_comment doesn't rely on `syntax-ppss' to find a safe position. The reason I disabled open-paren-etc. was a bug report from Michael Welsh Duggan, where commented out code was causing the CC Mode "state cache" to get corrupted. The critical bit of his source looks like this (note the commenting out at L3): 1. #define PARTIAL_MD5_SIZE 4096 2. 3. /* 4. 5. TODO: Partial sums (for working with very large files). 6. 7. typedef struct _signature 8. { 9. md5_state_t state; 10. md5_byte_t digest[16]; 11. } signature_t; 12. 13. typedef struct _signatures 14. { 15. int num_signatures; 16. signature_t *signatures; 17. } signatures_t; 18. 19. */ 20. 21. typedef struct _file { With pos at BOL21, (scan-lists pos -1 -1) was returning BOL17. It was ignoring the commenting out. Fscan_lists calls scan_lists which calls back_comment. Because open-paren-etc. was t, back_comment was tripping up on the brace at BOL14 and thus not recognising the comment at all. The "solution" to the bug was to bind open-paren-etc. to nil around the critical code. This is almost certainly what is causing the slow down. Though for some reason, I don't see this slow down myself. This is quite worrying. I am using an up-to-date (as of yesterday evening) bzr Emacs and following your (Martin's) recipe by yanking it into a buffer and doing C-x C-e on it. If I've understood correctly, I think the root cause of the slowness is the lack of optimisation of find_defun_start when open-paren-etc. is nil - it brutally returns BOB, no matter what. Perhaps some sort of cache of safe positions (doesn't one exist already?) could accelerate find_defun_start to acceptable speed in this use case. > martin -- Alan Mackenzie (Nuremberg, Germany).