From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: The current state of the comment-cache branch Date: Sun, 25 Dec 2016 11:07:46 -0500 Message-ID: References: <20161223215056.GA2771@acm.fritz.box> <83fuldzre1.fsf@gnu.org> <20161224083054.GA2212@acm.fritz.box> <83bmw1zoy8.fsf@gnu.org> <20161224094246.GD2212@acm.fritz.box> <8360m9zf4h.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1482682102 4538 195.159.176.226 (25 Dec 2016 16:08:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 25 Dec 2016 16:08:22 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Dec 25 17:08:17 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cLBLF-00083F-OQ for ged-emacs-devel@m.gmane.org; Sun, 25 Dec 2016 17:08:09 +0100 Original-Received: from localhost ([::1]:47264 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cLBLK-0003xA-G3 for ged-emacs-devel@m.gmane.org; Sun, 25 Dec 2016 11:08:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cLBLA-0003x4-J4 for emacs-devel@gnu.org; Sun, 25 Dec 2016 11:08:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cLBL7-000532-E3 for emacs-devel@gnu.org; Sun, 25 Dec 2016 11:08:04 -0500 Original-Received: from [195.159.176.226] (port=35530 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cLBL7-00052s-72 for emacs-devel@gnu.org; Sun, 25 Dec 2016 11:08:01 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1cLBKw-0005mH-GW for emacs-devel@gnu.org; Sun, 25 Dec 2016 17:07:50 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 42 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:T6yXRldu8okjziQgbLDi71NnLSk= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:210806 Archived-At: > Also, I wonder why do we need all these changes in syntax.c, when the > problem is AFAIK only with C mode and its derivatives. Are these > changes beneficial in any way to modes with non-C syntax? The core of the problem is calls to (forward-comment -1). Both this comment-cache and my syntax-ppss patch attack this specific operation only. This operation is currently implemented by trying to skip comments "locally" by parsing backward, but when that fails, we use parse-partial-sexp from point-min to find the matching opening of a comment closer. This expensive forward pass is not a problem in practice unless your buffer is huge, or unless it happens many times within a single command. These can happen in any major mode, basically. It's only a historical accident if it seems to affect CC-mode more. open-paren-in-column-0-is-defun-start is the current hack to try and reduce the occurrence of this problem by only calling parse-partial-sexp from the closest open-paren-in-column-0, which works fairly well in practice for typical Elisp code as well as for typical C code (tho not for all coding styles). [ AFAIK open-paren-in-column-0-is-defun-start was specifically designed for this (forward-comment -1) issue, but it is also used in beginning-of-defun, although the two uses are completely independent and of a different nature: the use in forward-comment is supposed to be only an optimization, whereas the use in beginning-of-defun is meant to really change the result. So beginning-of-defun is completely irrelevant to and independent from this thread. ] Also in the latest case where a major slow down showed up in CC-mode, the problem was reversed: CC-mode had some special code for when open-paren-in-column-0-is-defun-start is non-nil (can't remember what it was for), which was the cause of the slow down, IIRC. Both Alan's comment-cache and my syntax-ppss patch aim to replace the open-paren-in-column-0-is-defun-start hack so as to completely eliminate this pathological (forward-comment -1) case. Stefan