From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#56682: Fix the long lines font locking related slowdowns Date: Mon, 15 Aug 2022 17:57:24 -0400 Message-ID: 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> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25128"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 56682@debbugs.gnu.org, Gregory Heytings , Eli Zaretskii To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Aug 15 23:58:15 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 1oNi6A-0006JF-M7 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 15 Aug 2022 23:58:15 +0200 Original-Received: from localhost ([::1]:50610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNi69-0005Ds-Cw for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 15 Aug 2022 17:58:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNi5y-0005DV-0Q for bug-gnu-emacs@gnu.org; Mon, 15 Aug 2022 17:58:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54515) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oNi5x-0007Bs-OF for bug-gnu-emacs@gnu.org; Mon, 15 Aug 2022 17:58:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oNi5x-00007V-Jw for bug-gnu-emacs@gnu.org; Mon, 15 Aug 2022 17:58:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 15 Aug 2022 21:58:01 +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.1660600661434 (code B ref 56682); Mon, 15 Aug 2022 21:58:01 +0000 Original-Received: (at 56682) by debbugs.gnu.org; 15 Aug 2022 21:57:41 +0000 Original-Received: from localhost ([127.0.0.1]:44264 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oNi5d-00006v-1S for submit@debbugs.gnu.org; Mon, 15 Aug 2022 17:57:41 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:29356) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oNi5b-00006j-97 for 56682@debbugs.gnu.org; Mon, 15 Aug 2022 17:57:39 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 05D258004C; Mon, 15 Aug 2022 17:57:33 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 5FB3C80470; Mon, 15 Aug 2022 17:57:27 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1660600647; bh=zLQ0NtToMIGpBjuKBqS047dz5bAWD8V5D8+KJLMI4wc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=JoNymKjf/wjcCj6MIywvM5yUonTJ8vcbAygygeTuDkXDm4fFo+8KOlAz4qE3Bh9qZ NryJPOe/PyCuow6xBI5HfPGCwd3sXcGXw23gTQFhW8WLDmjbvbk5gsA5Qd0EpTxWZl vs64LoNgx1r2lDNJ65To+pQBLuAXomgDyYKuKG8uZxSnBqWFQ9KmagRjSBcIwASjAM V4MHvaWi1aamGNJqyoW8WRB6FZzQPesVXXi7jMC7y+9qbZJAIlyaO96O8AW+ICUs9g wA2hyzqiJRE+mi88+DVLAlP5lUKuDqGFX+daNv9HDuK0LTYtFCeVBiYnzZywzGAmQS BPuUv9C4r8lng== Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 4CDE01202C5; Mon, 15 Aug 2022 17:57:27 -0400 (EDT) In-Reply-To: <7340244f-7343-64de-a0fe-c274ca6544b6@yandex.ru> (Dmitry Gutov's message of "Mon, 15 Aug 2022 23:40:35 +0300") 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:239847 Archived-At: >> IIUC they use `fontification-functions` to wrap the "select the current >> major mode" operation around the call to `jit-lock-function` so that >> each submode can use its own set of jit-lock clients. >> It's harder to hook into `jit-lock-functions` to do that because you >> need to detect when `jit-lock-functions` is modified. > > Do they detect when fontification-functions are modified? Sounds like just > as much of a rare occurrence. Could be. >> 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`. 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. >>> 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. > But also: if they go on to call jit-lock anyway, then they would go through > whatever application of narrowing that we put in there. Be that in > font-lock-fontify-region, or in jit-lock-function. Indeed. But before doing so, they may(?) scan the whole buffer to find out which submode to use at the current location. I think it's OK to "break" those packages with some forced narrowing until they get improved to do something sane in large files or long lines. But of course it should be possible to unbreak them without recompiling Emacs. Stefan