From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#56682: Fix the long lines font locking related slowdowns Date: Tue, 16 Aug 2022 02:33:56 +0300 Message-ID: <5b819177-2cc9-c492-0d98-846692b9ac3e@yandex.ru> References: <837d3lzv8n.fsf@gnu.org> <2c8d6755-cfe2-6559-3fde-3fa30ffb411e@yandex.ru> <83mtcgy44k.fsf@gnu.org> <83k07jx5jn.fsf@gnu.org> <866e510d-a060-7daa-d002-97861d056fa7@yandex.ru> <1144021660321893@iva5-64778ce1ba26.qloud-c.yandex.net> <12348081660379417@sas2-a098efd00d24.qloud-c.yandex.net> <66bbbb95983414e79637@heytings.org> <83wnb9hadb.fsf@gnu.org> <395454dd-7238-c5d0-e924-2f65a186baa7@yandex.ru> <83r11hh4pm.fsf@gnu.org> <3a1232a17b7bc39eb451@heytings.org> <7340244f-7343-64de-a0fe-c274ca6544b6@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="blaine.gmane.org:116.202.254.214"; logging-data="5370"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Cc: 56682@debbugs.gnu.org, Gregory Heytings , Eli Zaretskii To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 16 01:35:22 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1oNjc9-0001Db-Dh for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 Aug 2022 01:35:21 +0200 Original-Received: from localhost ([::1]:37692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNjc8-0000Zy-HC for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 15 Aug 2022 19:35:20 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNjbr-0000ZJ-1I for bug-gnu-emacs@gnu.org; Mon, 15 Aug 2022 19:35:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54579) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oNjbq-0004T9-PM for bug-gnu-emacs@gnu.org; Mon, 15 Aug 2022 19:35:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oNjbq-0002TO-JK for bug-gnu-emacs@gnu.org; Mon, 15 Aug 2022 19:35:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 15 Aug 2022 23:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56682 X-GNU-PR-Package: emacs Original-Received: via spool by 56682-submit@debbugs.gnu.org id=B56682.16606064509444 (code B ref 56682); Mon, 15 Aug 2022 23:35:02 +0000 Original-Received: (at 56682) by debbugs.gnu.org; 15 Aug 2022 23:34:10 +0000 Original-Received: from localhost ([127.0.0.1]:44328 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oNjb0-0002SF-8F for submit@debbugs.gnu.org; Mon, 15 Aug 2022 19:34:10 -0400 Original-Received: from mail-wm1-f45.google.com ([209.85.128.45]:36620) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oNjav-0002Ri-5X for 56682@debbugs.gnu.org; Mon, 15 Aug 2022 19:34:09 -0400 Original-Received: by mail-wm1-f45.google.com with SMTP id 206-20020a1c02d7000000b003a6062a4f81so70762wmc.1 for <56682@debbugs.gnu.org>; Mon, 15 Aug 2022 16:34:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc; bh=Xt0Z5NUFUrtAZiz9C6PkJCAFVk92KYYUjVd3MNT8gqE=; b=bUNxq4Bi7ia4i5Iy7dBMEp6KCovfkAF3P5+qFv3HVQbQcNTHbx25S2BdWMrA7wvdcS ukd22VGXe5TKP/C0JdBj8iTu9TJIIw/TBHDJw/m52nvOqwFD1fLLVk4sFvNAwXUM77LJ 9KMJ0tl144aTpnJjAsDsZMz3ItynF4KextJvS8NRA8MdVBeCM1gS7u13arZ+0USsGoC+ IxO0tov26i7CW9X1A3BSdu51lG+2K2TnPcuRD8kgsV+0uWessn1QFOg82r3K0Ut40uzk Dhcj0+ku5pvedc8My+oFgoLW6sUlStvvTxHpAOpkvCIAo8sO1iXcFVUOUeiWnqkASeZf 4ddQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc; bh=Xt0Z5NUFUrtAZiz9C6PkJCAFVk92KYYUjVd3MNT8gqE=; b=JpnWz4JTNmO6VbAgCBCUtmzyPQ07Aw2VH4kkQHzjlM7IzMdMHQVshwB69+ehaAIBjq eLz75psavmHqJpB/Qt/0vKwXCKBT67yvGRScS43hKoIIHvmMh9TCrOlGpZIJdZaWY5b6 X85COhHUXJhcECjr6HqCVkgKsf9FtvyWvnHJxqRytblCWK5Z3ce3B64mV+dHyFUpxuK3 9cqA/TMS8grJgOsDL+SwB7d9aVGedcEF3o7IXOnSUdIa7yJQESwN0Bb8Lr5OMU6dpcoG A23Rjsq3TXk1sfKNKh8zFiTEnRTR3QSe2JNA3FQMeNVbHxXVOGrUdjUPh0PR9o9RNlSZ bXtg== X-Gm-Message-State: ACgBeo2css/DHGATQCEOI6GvhKMDIjsBYbjkjjgyVFfGT0iJkiLRbNX2 PhIRGIJL4inqnltVvwfZ+zg= X-Google-Smtp-Source: AA6agR4GLxHeAcqXpNH6OyL09bSwKLWLQTpw8Y6rvbTrksPbZbkAWuWdIDhf498jkWp5p4Lbny9NsQ== X-Received: by 2002:a05:600c:5023:b0:3a6:3f9:a031 with SMTP id n35-20020a05600c502300b003a603f9a031mr1114987wmr.131.1660606439076; Mon, 15 Aug 2022 16:33:59 -0700 (PDT) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id p185-20020a1c29c2000000b003a4f1385f0asm11445889wmp.24.2022.08.15.16.33.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 15 Aug 2022 16:33:58 -0700 (PDT) Content-Language: en-US In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:239854 Archived-At: On 16.08.2022 00:57, Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: >>> AFAICT mmm-mode does not try to do that at all. >> >> It does the wrapping through custom font-lock-fontify-region-function and >> syntax-propertize-function. The major mode specific values are saved after >> the major mode is called. Any subsequent modifications are just ignored. > > I'm not sure why they decided to wrap `fontification-functions`, but in > theory it lets them support things like a submode that's using > `nhexl-mode`, another using `nlinum-mode`, and yet another using > `glasses-mode`. I'm guessing this could also be implemented through a wrapping jit-lock-functions element if mmm-mode, say, saved the value of this variable corresponding to each major mode. Similarly to mmm-fontify-region-function. But doing it in a caller up a level looks a little cleaner, of course. > In any case, these multi mode packages always need to "look back" in > order to find which mode to use at a given position, so they inevitably > need some kind of widening to work correctly. Right. Even if they need to skip back just a little bit (usually), being able to look back is useful. Although the "which mode" information is often available through an overlay or text property at point, so that need might be worked around in a lot of cases. >>>> They'll get all the corresponding performance improvements (just-in-time >>>> fontification) as a bonus. >>> Not sure what you mean by that. `fontification-functions` is already >>> called "just-in-time" (and those packages don't re-implement jit-lock on >>> their own, they just wrap themselves around jit-lock). >> Okay then. >> Sounds like somewhere in there there's a duplication of design still. > > I think the duplication is in the weird semantics of > `fontification-functions`: this supposedly holds a list of functions, > but it's difficult to make it work right with more than one function. > I think it should be replaced with a single `fontification-function` instead. I would try to go further: either document that `fontification-function' is ultimately supposed to call jit-lock, or call jit-lock-function directly (from handle_fontified_props or whatever), forcing polymode and multi-mode to use around-advice on that function (will that work on a function directly called from C?). If we clarify that fontification has to go through jit-lock-function either way, we can more confidently move the application of font-lock narrowing to jit-lock-fontify-now (that's where fontification-functions and font-lock-ensure meet).