From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Reliable after-change-functions (via: Using incremental parsing in Emacs) Date: Wed, 01 Apr 2020 17:04:24 +0300 Message-ID: <83eet7z4if.fsf@gnu.org> References: <83o8sf3r7i.fsf@gnu.org> <2E218879-0F24-4A20-B210-263C8D0BEEA4@gmail.com> <838sjh2red.fsf@gnu.org> <83369o3bvb.fsf@gnu.org> <83imik1qbq.fsf@gnu.org> <835zek1kpv.fsf@gnu.org> <83v9mkz5oo.fsf@gnu.org> <83pncsym6l.fsf@gnu.org> <4a9d6bb2-458d-89b0-5389-d1f883ef24a1@yandex.ru> <74f34b72-725d-2390-faea-c61daad43350@yandex.ru> Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="5512"; mail-complaints-to="usenet@ciao.gmane.io" Cc: casouri@gmail.com, akrl@sdf.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Apr 01 16:05:00 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jJdzI-0001Il-0s for ged-emacs-devel@m.gmane-mx.org; Wed, 01 Apr 2020 16:05:00 +0200 Original-Received: from localhost ([::1]:60726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJdzH-0003Yc-3g for ged-emacs-devel@m.gmane-mx.org; Wed, 01 Apr 2020 10:04:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46795) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJdyW-00030s-2x for emacs-devel@gnu.org; Wed, 01 Apr 2020 10:04:13 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:33340) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jJdyV-0008NX-Dv; Wed, 01 Apr 2020 10:04:11 -0400 Original-Received: from [176.228.60.248] (port=4542 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jJdyU-0001QJ-GP; Wed, 01 Apr 2020 10:04:11 -0400 In-Reply-To: <74f34b72-725d-2390-faea-c61daad43350@yandex.ru> (message from Dmitry Gutov on Wed, 1 Apr 2020 16:47:02 +0300) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:246194 Archived-At: > Cc: casouri@gmail.com, monnier@iro.umontreal.ca, akrl@sdf.org > From: Dmitry Gutov > Date: Wed, 1 Apr 2020 16:47:02 +0300 > > On 01.04.2020 07:14, Eli Zaretskii wrote: > > > There's no need to guess. Just profile this use case, and you will clearly see what takes most of this time. > > - c-mode 772 75% > - c-common-init 766 74% > - mapc 764 74% > - # 509 49% > + c-neutralize-syntax-in-CPP 276 26% > + c-after-change-mark-abnormal-strings 204 19% > + c-parse-quotes-after-change 18 1% > - # 255 24% > + c-before-change-check-unbalanced-strings 199 19% > + c-depropertize-CPP 46 4% > c-font-lock-init 1 0% > c-basic-common-init 1 0% I see a very different picture here: the above takes something like 15%. Most of the time is spent in functions called by jit-lock. > If I just (push '("\\.c\\'" . js-mode) auto-mode-alist), the same > benchmark takes ~60ms. So yes, CC Mode does a lot during initialization, > and that stuff can be described as "preliminary parsing". Except that I cannot reproduce these results, so I'm not really sure what we are looking at. What I did was start the profiler, then manually call got-char, then produce the profiler report. What did you do to collect the above profile? > And there will be more of that during redisplay itself. Which is not what your benchmark measures. > > In general, there's no "preliminary processing" by the major mode's fontification facilities except what happens as part of jit-lock, i.e. at redisplay time or as side effect of functions that simulate display for redisplay purposes. I'd be very surprised to see a major mode which somehow preprocesses the buffer on its own in preparation for fontification. CC Mode certainly doesn't seem to do that. > > Now you know. Do I?