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: Wed, 10 Aug 2022 20:02:20 +0300 Message-ID: <2aa80c8f-5fb8-1892-72cd-60f050261104@yandex.ru> References: <83mtcizov2.fsf@gnu.org> <83h72qzheq.fsf@gnu.org> <25717d84-3411-a93a-3620-e04fe0571aff@yandex.ru> <83edxuzemr.fsf@gnu.org> <83a68hzz0a.fsf@gnu.org> <6ae35c93062c589b2e02@heytings.org> <7b7fbad7-55ac-49b8-840f-7f89a7e8771a@yandex.ru> <6ae35c93064b3588974c@heytings.org> <6ae35c9306c515f420d8@heytings.org> <87k07gwkjq.fsf@gmx.net> <87fsi4wiel.fsf@gmx.net> <837d3gs4p0.fsf@gnu.org> <83tu6kqnf1.fsf@gnu.org> <83fsi4qdxp.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="26801"; 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, stephen.berman@gmx.net, monnier@iro.umontreal.ca To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 10 19:03:36 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 1oLp7H-0006ft-5t for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 10 Aug 2022 19:03:35 +0200 Original-Received: from localhost ([::1]:33174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oLp7G-0007j2-7s for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 10 Aug 2022 13:03:34 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oLp6l-0007gr-B7 for bug-gnu-emacs@gnu.org; Wed, 10 Aug 2022 13:03:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60879) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oLp6k-00008M-LV for bug-gnu-emacs@gnu.org; Wed, 10 Aug 2022 13:03:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oLp6k-0001Td-Gf for bug-gnu-emacs@gnu.org; Wed, 10 Aug 2022 13:03: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: Wed, 10 Aug 2022 17:03: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.16601509575643 (code B ref 56682); Wed, 10 Aug 2022 17:03:02 +0000 Original-Received: (at 56682) by debbugs.gnu.org; 10 Aug 2022 17:02:37 +0000 Original-Received: from localhost ([127.0.0.1]:50628 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oLp6K-0001Sx-QP for submit@debbugs.gnu.org; Wed, 10 Aug 2022 13:02:37 -0400 Original-Received: from mail-wm1-f51.google.com ([209.85.128.51]:51063) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oLp6F-0001Sf-Lr for 56682@debbugs.gnu.org; Wed, 10 Aug 2022 13:02:35 -0400 Original-Received: by mail-wm1-f51.google.com with SMTP id v5so8129293wmj.0 for <56682@debbugs.gnu.org>; Wed, 10 Aug 2022 10:02:31 -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=DDfdHZLkHlwajEOZjIzIsoPSuHs8d8BjSYnSnTFlCMM=; b=B91G/Pkyr5xMHsNqh4MuM58JbvJzmgYiK9DC7Eib8yCzaqLwsvgPrJThDF/riAkrNq 6d8dNn6Z92nbSei4nzkPm44+EY7IW6cNTVFC5b7QkpZ9Ukv/9AT8tamKta/8TRsY5lWB l+6jc4eSBbwARxOg2ETZIXFvxEMn6yqEs5RBv+wetFacy/PflPF5wtNYGDiw4r2B5ML7 aBID1XA9J7xcL0vu7gli1VsVmvBMQRPJwDSgydznMHJ6otVdpJN/3YAVDpL1SOrC5Pr3 Ln+Jr9YF24o/wTPiPdpWSpUjg8rX1Dr56OR7yhoPcdS6Mfob2i1wVstYgSe2KGFEljoV NgmQ== 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=DDfdHZLkHlwajEOZjIzIsoPSuHs8d8BjSYnSnTFlCMM=; b=sioAG6Z77IxvJ7bS6HETs0Gbbx84uyQ3Kq5/HlV/AYQy61Dfb4GIYNC7UF1djWKgXF LQfbYVQ25dDJcbdf0ppomJYck2yQwQR7zxiak+afY1U67s9ba1lPA3yZ9BQHHPCuyXKv 7nE8wGK+kpTQuEr3iCFELNH8EjMzYcVSKrpXfMxL0OQFUJNTJYf8IR0EsNdc0GLWdFxg 9doiQ1IDSuWspm4MuX21TrjTwg5jJsk/wccHolkQaCBX9vO98YNOuGnkavrfBjPEt0Fo /BfxEmHrZLeDfF6/rtY02yeAVihITIbFgS0/fzCNPXkbud/PzCnBMcABM+CIgw5bGeM5 YY1w== X-Gm-Message-State: ACgBeo3hN4tneX4hLP2Hprq68mduHpvikLMxw+fonsrvSKpqGx9vb8c7 4Le7tLwkfxazUsdpolFJhGs= X-Google-Smtp-Source: AA6agR5iQhBe3nvTYZMcyRmmwsiWVbLKQiRpoehd8r2oVMX02dHmzcD2IqHDlqVbiBHKohOyUtx1pQ== X-Received: by 2002:a05:600c:1906:b0:3a3:4315:682d with SMTP id j6-20020a05600c190600b003a34315682dmr2996079wmq.54.1660150944692; Wed, 10 Aug 2022 10:02:24 -0700 (PDT) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id p10-20020a05600c064a00b003a54f49c1c8sm3061346wmm.12.2022.08.10.10.02.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 10 Aug 2022 10:02:23 -0700 (PDT) Content-Language: en-US In-Reply-To: <83fsi4qdxp.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:239311 Archived-At: On 10.08.2022 19:08, Eli Zaretskii wrote: >> Date: Wed, 10 Aug 2022 18:44:53 +0300 >> Cc: 56682@debbugs.gnu.org, stephen.berman@gmx.net, monnier@iro.umontreal.ca >> From: Dmitry Gutov >> >> Shouldn't the scanner be limited by the same narrowing that the >> long-line optimizations create? Given its existing effect on font-lock, >> limiting bidi searches seems like a no-brainer. > > Like I said: it _is_ limited. But the limitation is smarter than just > some arbitrary number of character positions, because it is tuned to > this particular processing. > > Note that the effect of it in this case is not as dramatic as > font-lock: it does slow down C-n/C-p, but not catastrophically so, It's much worse. In the aforementioned dictionary.json, with fully-featured font-lock (narrowing disabled in handle_fontified_props) the buffer is perfectly responsive to edit as long as I (setq bidi-inhibit-bpa nil). Even with show-paren-mode enabled. Without that, however, simple navigation commands take a significant amount of time. These measurements are with show-paren-mode off: Near BOB: (benchmark 1 '(next-line 1)) => Elapsed time: 0.246551s Elapsed time: 0.247237s Elapsed time: 0.247392s Near EOB: (benchmark 1 '(next-line 1)) => Elapsed time: 0.059583s Elapsed time: 0.040372s Elapsed time: 0.059508s > not > like we've seen with the files we used for the long-lines speedups. > And if someone does think it's a catastrophe, they can always disable > the BPA, perhaps even globally, That reminds me of "the user can always disable font-lock" and your dismissal of Alan's advice to change font-lock-maximum-decoration to 2, saying that we should have good editing performance OOTB. > if they know they will never need to > look closely at bidirectional text: the effects are hardly visible > unless you actually read the text. We could add (setq bidi-inhibit-bpa nil) to prog-mode, I suppose. It already has a bidi-paragraph-direction setting anyway. >> Alternatively, I would perhaps propose to perform said searching at two >> junctions: when the buffer is visited (and the text is inserted and, >> thus, unavoidably read), and when the buffer is saved (perhaps at that >> point Emacs might have info about the added ranges, to avoid searching >> through the whole buffer). The downside would be that the first added >> R2L character might be displayed incorrectly until the buffer is saved. > > This is impossible without a complete redesign of how the bidi display > works: it saves no information in the buffer object, none whatsoever. > The information is recomputed every time the display code is called, > and only for the portion of the buffer that needs to be traversed or > displayed; then it is discarded. There are no caches of any kind that > keep the information after redisplay has done its job. Perhaps a cache similar to syntax-ppss one could do the job? Not sure what would be the trafeoffs, though. Like, how that would change the performance in the simple case.