From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: Reliable after-change-functions (via: Using incremental parsing in Emacs) Date: Wed, 1 Apr 2020 16:47:02 +0300 Message-ID: <74f34b72-725d-2390-faea-c61daad43350@yandex.ru> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="60092"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 Cc: casouri@gmail.com, monnier@iro.umontreal.ca, akrl@sdf.org To: Eli Zaretskii , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Apr 01 15:47:52 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 1jJdii-000FZU-6N for ged-emacs-devel@m.gmane-mx.org; Wed, 01 Apr 2020 15:47:52 +0200 Original-Received: from localhost ([::1]:60544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJdih-0003Se-7X for ged-emacs-devel@m.gmane-mx.org; Wed, 01 Apr 2020 09:47:51 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43864) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJdhz-00031T-Ux for emacs-devel@gnu.org; Wed, 01 Apr 2020 09:47:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jJdhy-0008Ms-VM for emacs-devel@gnu.org; Wed, 01 Apr 2020 09:47:07 -0400 Original-Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:38855) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jJdhy-0008Ky-Mp; Wed, 01 Apr 2020 09:47:06 -0400 Original-Received: by mail-wm1-x335.google.com with SMTP id f6so7271472wmj.3; Wed, 01 Apr 2020 06:47:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=HPcRmosRF7FUz6/QzYdzjpj5Ayz/fKbi4IbH+30kxLY=; b=JlOa11Zw7lJbh26nAnK6SM8NcTdJalecMmpUP/Yd79IrFW/4isdlDyA9ke2Cof4nIK y4IHZZtM9hwgv1aSXMu90Q/n/bG2BPWX3oImtKJ8g2ZI3zPQtWbbx/grdvEV3P/ZlYZs jHoPvlTJ9w6KJU1FKeKpxaHB2xIU+r7ha9sXhUBxPzK6Rb2IwTyAT/sKsWjjDxJHW++x Ut2+Y6UZciVNDPdFdr6Eurgbq/pjcE15FYi52G54rKEf7Gucf30Mi6imv+0WQbplVoTa KdADkC6IxL7/KA771ZEMBkiNDPyT0zEkgM4JNFjY59GLrBj6IfL3t+hbiMq0sm/0RRz3 WPHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=HPcRmosRF7FUz6/QzYdzjpj5Ayz/fKbi4IbH+30kxLY=; b=t4qKQlinBj7LFYoZnFFw61C3sR1NimHZixzgRE5+fa26ITIJY4Rvs+WYed+V5otqaG 3bcdPNUgQjUBBaHrHSsQAZbHA2fYcjFAV3zA1RrsLY32j6jlK1f4IXC+FvlHZXZ7p3lF NxurEEhzW0G5i0shQxfZdAfdVYCtUNZMTXNxrm9v1e8hSagjNXCvOd9ggnJ088oEZC1w rIU4q9U+MJhEXs3eJ9nNakw4BsLiEXs71PN96bM+5FfyAeUoe9yFRZOp/PqU1CrJFInS kb6ai5J80fBoyeIIbBMFMwA4LB8+xB//PuNx7j1+oTP8dchiIcmNMklmEj0338J7QDFF jPhw== X-Gm-Message-State: AGi0PuZktLNEk0KZZynDBHz804F5zcz54YKzvF8CzZChayV5eYxL3Y49 GxckSDorBLdAwzB+PZNghGw= X-Google-Smtp-Source: APiQypJjeRijdlFPwqt6vfqmGVvGFhyA5VcTZAcEfZ4uR+eSoDDopQga9rp13mVjY9n0OSqTn707Eg== X-Received: by 2002:a1c:2d95:: with SMTP id t143mr4470820wmt.89.1585748825590; Wed, 01 Apr 2020 06:47:05 -0700 (PDT) Original-Received: from [192.168.0.2] ([66.205.73.129]) by smtp.googlemail.com with ESMTPSA id n2sm3126479wro.25.2020.04.01.06.47.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Apr 2020 06:47:04 -0700 (PDT) In-Reply-To: Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::335 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:246192 Archived-At: 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% You can also compare CC Mode's init with JS Mode's. 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". And there will be more of that during redisplay itself. > 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.