From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#56682: Fix the long lines font locking related slowdowns Date: Mon, 15 Aug 2022 19:05:57 +0300 Message-ID: <83r11hh4pm.fsf@gnu.org> References: <834jyq29o1.fsf@gnu.org> <92da07bd028e3ede61a6@heytings.org> <47894c57-dd8b-5778-240a-3fa6540e4d37@yandex.ru> <92da07bd02941d5537e9@heytings.org> <5308e3b5-a160-17d7-77ee-b1d00acfa20d@yandex.ru> <92da07bd02a6cc861e1a@heytings.org> <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> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16008"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 56682@debbugs.gnu.org, gregory@heytings.org, monnier@iro.umontreal.ca To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Aug 15 18:16:42 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 1oNcle-000411-5k for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 15 Aug 2022 18:16:42 +0200 Original-Received: from localhost ([::1]:50354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNcld-0004Lr-50 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 15 Aug 2022 12:16:41 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNccK-0006Vd-0Y for bug-gnu-emacs@gnu.org; Mon, 15 Aug 2022 12:07:12 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54171) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oNccI-0003Gb-Mu for bug-gnu-emacs@gnu.org; Mon, 15 Aug 2022 12:07:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oNccI-000852-BZ for bug-gnu-emacs@gnu.org; Mon, 15 Aug 2022 12:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 15 Aug 2022 16:07: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.166057958130995 (code B ref 56682); Mon, 15 Aug 2022 16:07:02 +0000 Original-Received: (at 56682) by debbugs.gnu.org; 15 Aug 2022 16:06:21 +0000 Original-Received: from localhost ([127.0.0.1]:43920 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oNcbd-00083q-6V for submit@debbugs.gnu.org; Mon, 15 Aug 2022 12:06:21 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:44414) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oNcba-00083b-DU for 56682@debbugs.gnu.org; Mon, 15 Aug 2022 12:06:20 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:45650) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNcbT-0003D2-OM; Mon, 15 Aug 2022 12:06:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=+v3QCUfkiw+h/F/jZjXRfsRoCCe4DpuuLk3VR4P60T0=; b=dYw0Bxl2RQc/ 8bqPj+NS/5yaUb9Ouk8M16QZahE8okC2IaWnbNwmt7zempLwA8WQtWgKs5gZqbekH6vRi8zGhbqBV EJz9Vz4w+9/QQOYRMnr7K4oJW8aIWvjtR0tvsGzQpilGq1gFgmxKFyNVsWVvKLbmuGn6NTU8tIm15 O//T+fVn4Uc2Q5C05tjHH9ZTG+YUijcMffqABD5/XGPHb0u7KTfoaXyi1f0Yu7iXxy5e6KhLv0x9t Ky2nBEt1RTsyTPDO1xxoAoPvz1I255r5HjG4HtvjrXshuHHmHQGlQP3OBqRj+iKTryW1ERLYzcwj0 Qx4E59X4Uraul0zwbNRbVg==; Original-Received: from [87.69.77.57] (port=4091 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNcbT-0004bM-8j; Mon, 15 Aug 2022 12:06:11 -0400 In-Reply-To: <395454dd-7238-c5d0-e924-2f65a186baa7@yandex.ru> (message from Dmitry Gutov on Mon, 15 Aug 2022 18:52:41 +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:239814 Archived-At: > Date: Mon, 15 Aug 2022 18:52:41 +0300 > Cc: 56682@debbugs.gnu.org, gregory@heytings.org, monnier@iro.umontreal.ca > From: Dmitry Gutov > > On 15.08.2022 17:03, Eli Zaretskii wrote: > > > I tested this branch with an unoptimized build and a 416MB file made > > of 23 copies of dictionary.json, after disabling show-paren-mode. > > > > Observations: > > > > . With the default value of font-lock-large-files, which allows > > font-lock to widen as it pleases, the initial M-> in takes 5 min > > here. That's way too long. On master, this is instantaneous. > > . Thereafter jumping into various random places inside the file is > > much faster, but still takes between 1 min and 2.25 min -- again > > too long, even if I divide by 10 to get an approximation to your > > faster machine. On master this takes maybe 1 sec, maybe less. > > . Horizontal and vertical motion commands are as fast (or as slow) > > as on master, which is not surprising. > > > > Bottom line: with the default value of font-lock-large-files, this > > scales much worse than the master branch -- which again is no > > surprise. > > So we change the default, then? > > (setq font-lock-large-files '(narrow . 5000)) No, I want a simple variable that just gives the size of the narrowed region, with nil meaning don't narrow at all. > > My conclusion is that we do need to prevent uncontrolled > > widening in fontification-functions, if we want a scalable solution. > > Do you mean the widening inside font-lock-fontify-region that's > controlled by font-lock-dont-widen? No, I mean _any_ widening in _any_ function placed on the fontification-functions hook. > > I honestly don't see any reason to explore more sophisticated > > alternatives for where and how to narrow, until and unless major modes > > will on their side develop capabilities which will make such > > complications (both in code, but mainly on the user part) justified. > > I'm pretty sure that doing all that in Lisp is a good thing, and would > be conducive to whatever improvements we might want to add later... No, because quite a few packages use jit-lock-register to run stuff that is not font-lock at all, and I don't want that to slow down redisplay when long lines are involved. And trying various values of a variable exposed to Lisp is easy enough. > > If you agree, I'll add on master a variable to control the narrowing > > when we call fontification-functions. > > ...but if you've sure in your decision, okay, please add that additional > var which will decide the narrowing bounds for fontification-functions > (and whether to narrow at all). Will do soon. Thanks.