From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gregory Heytings Newsgroups: gmane.emacs.bugs Subject: bug#56682: Fix the long lines font locking related slowdowns Date: Mon, 01 Aug 2022 11:01:23 +0000 Message-ID: References: <837d46mjen.fsf@gnu.org> <8a3eaeef01be5bfaa5ef@heytings.org> <05388e8d8812bfa3695d@heytings.org> <83v8rf5894.fsf@gnu.org> <65cb7c73fd4a999cca00@heytings.org> <8c7321f2f3400a5db9be@heytings.org> <8c7321f2f388e5343475@heytings.org> <6ea376f6-d503-06d8-6d83-50c52b695394@yandex.ru> <8c7321f2f3ac52bfee4b@heytings.org> <8c7321f2f3ec1ef81af9@heytings.org> <02e83b0e-1b5c-fe75-6e59-1f8ddff82d37@yandex.ru> <96f28fd8-6744-1925-0631-0095099362dd@yandex.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="B6REzwZp80" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18491"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 56682@debbugs.gnu.org, Eli Zaretskii , Stefan Monnier To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Aug 01 13:02:48 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 1oITCC-0004c0-7g for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 01 Aug 2022 13:02:48 +0200 Original-Received: from localhost ([::1]:40010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oITCB-0002RS-4f for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 01 Aug 2022 07:02:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oITBT-0002Op-BZ for bug-gnu-emacs@gnu.org; Mon, 01 Aug 2022 07:02:08 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49695) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oITBS-0000dw-6Y for bug-gnu-emacs@gnu.org; Mon, 01 Aug 2022 07:02:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oITBS-0005e7-1o for bug-gnu-emacs@gnu.org; Mon, 01 Aug 2022 07:02:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Gregory Heytings Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 01 Aug 2022 11:02: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.165935168721645 (code B ref 56682); Mon, 01 Aug 2022 11:02:02 +0000 Original-Received: (at 56682) by debbugs.gnu.org; 1 Aug 2022 11:01:27 +0000 Original-Received: from localhost ([127.0.0.1]:39438 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oITAt-0005d3-2G for submit@debbugs.gnu.org; Mon, 01 Aug 2022 07:01:27 -0400 Original-Received: from heytings.org ([95.142.160.155]:33588) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oITAq-0005ct-UU for 56682@debbugs.gnu.org; Mon, 01 Aug 2022 07:01:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org; s=20220101; t=1659351683; bh=jX12EYVwO4xYtoujrse9P8Lnp/lofoSFinr6AfTmigM=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From; b=9xR6zNxVy3cPexO6R5rkps6LbalZsy6eU+kjrA/pLlbLKrJCyigV50MuQYulDLJt8 Lj+ZtzwsiBg+/DaDmYoQ0bCESOmR6BIYi05l4U4XIxnRYqJkWp4s4lHM5NO5qezORy 2BP/RdLrEsH6cyNPzUTBMQuHY9yf/N6glgyh7Of3qHL1NQ3fBYWm8wd5CtqbPgPijI oeF01Sq6TI2TGJJl0eEiCMoBE5WcvLSaXfo188f7qUes0q6/wo7SbxxKpFnB0aBePe 9R06y9Vv94BQmLfoZ11G4JDE/TcXZmTbjXCCHWi3E8P1/Vv4csVwh4F0Q0WhrmQay/ XRly/zLFne3Wg== In-Reply-To: <96f28fd8-6744-1925-0631-0095099362dd@yandex.ru> 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:238405 Archived-At: --B6REzwZp80 Content-Type: text/plain; format=flowed; charset=utf-8 Content-Transfer-Encoding: quoted-printable >> No, it happens when the buffer is opened.=C2=A0 Given the importance tha= t=20 >> you and Stefan seem to give to that function, it is, with the patch I=20 >> sent in my previous post, called once on the whole buffer (without any= =20 >> narrowing) when the file is opened. > > But if the buffer is not scrolled to the end, shouldn't it be called=20 > with a position that's close to the beginning? > > That shouldn't force the full buffer scan, meaning this call should=20 > complete quickly. > I'm trying to reconcile two conflicting constraints. It is necessary to add a locked narrowing around fontification-functions=20 and pre/post-command-hook to ensure that Emacs remains responsive. At the same time, you and Stefan tell me that syntax-ppss does an=20 important job and will not do it correctly with such a locked narrowing,=20 IOW, that at least syntax-ppss should be called without a locked=20 narrowing. But you also tell me that its result is cached so that a full= =20 buffer scan isn't necessary anymore when it has happened at least once. So what I'm suggesting is to do a full buffer scan immediately, when the=20 file is opened, without any narrowing. If that happens, later calls to=20 syntax-ppss inside fontification-functions and pre/post-command-hook will= =20 use the cached result of the initial scan, and will do their job correctly= =20 even with a locked narrowing. Unless I misunderstand something, I think (and my tests seem to confirm)=20 that that would be a workable solution, provided that the initial scan is= =20 reasonably fast, that is, at least six times faster than it is now. --B6REzwZp80--