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: Sat, 13 Aug 2022 22:08:25 +0300 Message-ID: <8e884ebe-2d2e-d599-15c3-a5cfe5e6b295@yandex.ru> 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> <83wnbckp0q.fsf@gnu.org> 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="31698"; 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.org, monnier@iro.umontreal.ca To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 13 21:09:13 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 1oMwVU-000833-M1 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 13 Aug 2022 21:09:12 +0200 Original-Received: from localhost ([::1]:35212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oMwVT-0003NN-46 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 13 Aug 2022 15:09:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oMwVL-0003N6-Fo for bug-gnu-emacs@gnu.org; Sat, 13 Aug 2022 15:09:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45357) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oMwVK-0002uC-CU for bug-gnu-emacs@gnu.org; Sat, 13 Aug 2022 15:09:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oMwVK-0001Ao-6V for bug-gnu-emacs@gnu.org; Sat, 13 Aug 2022 15:09: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: Sat, 13 Aug 2022 19:09: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.16604177204482 (code B ref 56682); Sat, 13 Aug 2022 19:09:02 +0000 Original-Received: (at 56682) by debbugs.gnu.org; 13 Aug 2022 19:08:40 +0000 Original-Received: from localhost ([127.0.0.1]:35106 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oMwUx-0001AD-N5 for submit@debbugs.gnu.org; Sat, 13 Aug 2022 15:08:40 -0400 Original-Received: from mail-wr1-f46.google.com ([209.85.221.46]:37502) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oMwUt-00019y-1A for 56682@debbugs.gnu.org; Sat, 13 Aug 2022 15:08:38 -0400 Original-Received: by mail-wr1-f46.google.com with SMTP id b4so1405733wrn.4 for <56682@debbugs.gnu.org>; Sat, 13 Aug 2022 12:08:35 -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=C8xZCgJRWsQ9ksYf//vFUA2CHx+fO0EVDVkTHeA8y48=; b=LG/z5qRgzYUlQ4EXHs5gNe97ziRp6N2Hxk2nYmXKSFlg5/IpL2J6ELB6Kz5rMOjKle CzctSTu2QO2kP5HTPjtvNR7mRfhEO9V8HY5YON2SB927aZARS8HJvX79UwTrwvFI0DFe GvO2v0QHQRuQScRqVEdJbEkfZ4VzBgWsDJIaYI9Q3F0yyFk0SkjJ0JR9EGCzkj9pxUyp QLfsRBvxhY5YXVysVSesoBG1kT+Qed7uuiu5oa2GvLvzdyiYZVgz1KLO2CJ4NMxGoUac sFt2suIZtJruoHsY8vk+TLvRmZXwDSMdNNLg6ChIWpz/jdSG56kFhFyflwsBUe8vdpAw 86NQ== 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=C8xZCgJRWsQ9ksYf//vFUA2CHx+fO0EVDVkTHeA8y48=; b=dUTK143i+LTRoK5vu+O5c8YhuOp46yqsgLdqJsMuJHVCKAa+yYJmxpSlUPoGeN4moM p8XTzT3S8SHY+eXH+lrI3lxYjVdqr2tT8js71FV0SpiPmDon2JBpTqvDur//VB78bu2F saWApMkce7DxYEJ7/OXZgoND0TT6FEcaCDoEzUjAct0266yazYC130lrVc/HYMrWRvya tu4m+OP4akAgiI8+NbN9NBmJRvLOaEVMzxyPpP7bonwtKHr4vxwJudjxVNUGNykaOLcM xu8mbUHqNEFHpo3q5fl7olk7uePNUcQd4EXR5rowtZTvVu3qgtKangjAjky/5+uwPuqd HlZw== X-Gm-Message-State: ACgBeo1n8880ZxlzohFjFRnYb1rVUW0zsxWKWQsqmpPqcq6qQ1hx+hlW TUudTSP0SwhFnrCg49IMiqU= X-Google-Smtp-Source: AA6agR4ZW9y49iin/ShCCIQaVPiJY1BldxS6A0JEbRFHxpafsWbrJ0hRkd0ooI4KTBjmP6s6/Z4+0w== X-Received: by 2002:a05:6000:1ac8:b0:220:6af3:935d with SMTP id i8-20020a0560001ac800b002206af3935dmr4859939wry.549.1660417709128; Sat, 13 Aug 2022 12:08:29 -0700 (PDT) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id b3-20020a05600010c300b002217339ce90sm2692642wrx.8.2022.08.13.12.08.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 13 Aug 2022 12:08:28 -0700 (PDT) Content-Language: en-US In-Reply-To: <83wnbckp0q.fsf@gnu.org> 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:239585 Archived-At: On 13.08.2022 20:54, Eli Zaretskii wrote: >> Date: Sat, 13 Aug 2022 20:20:04 +0300 >> Cc:56682@debbugs.gnu.org, Eli Zaretskii, >> monnier@iro.umontreal.ca >> From: Dmitry Gutov >> >> As soon as the file becomes very large, such that font-lock actually >> becomes costly even in properly written major modes, we can still do one >> of the two things: apply narrowing during font-lock, or fontify only the >> beginning of the file. > Fontifying only the beginning of the file doesn't help when the file > is first shown at another point, like when Emacs or emacsclient is > invoked with the +NN[:nn] argument, or the user uses saveplace or > similar package. That's admittedly rarer than starting at the > beginning, but it's a valid use case, and I wouldn't like us to > dismiss it. The beginning of the file is the part of it which we can fontify quickly enough while still doing it correctly. Starting with some position P, jumping to it will show a larger initial delay than you might be comfortable with. Maybe it's 1 MB, maybe 10 MB, maybe 100 MB. Or more. But such file size exists because syntax-ppss's performance depends linearly on the buffer size. So after that position we'll not fontify it anymore. That's really the simplest solution. Because the main alternative on offer is to use narrowing and thus risk getting invalid syntax information. The effect is very noticeable in dictionary.json: you can just as easily get strings and non-strings inverted (the odds are pretty much 50/50). So the "don't fontify past X" strategy is simply based on the idea that no fontification is probably better than unreliable and obviously incorrect one. Now, we could develop more complex approaches from there. But this can be a starting point, and the user option allows people to choose the strategy they're most comfortable with.