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: Fri, 5 Aug 2022 17:41:51 +0300 Message-ID: <14845631-c2ef-8371-8606-c858092e3192@yandex.ru> References: <837d46mjen.fsf@gnu.org> <8a3eaeef01be5bfaa5ef@heytings.org> <05388e8d8812bfa3695d@heytings.org> <83v8rf5894.fsf@gnu.org> <65cb7c73fd4a999cca00@heytings.org> <8c7321f2f3400a5db9be@heytings.org> <8c7321f2f388e5343475@heytings.org> <8c7321f2f36494299e61@heytings.org> <83v8rc2n1h.fsf@gnu.org> <64084296-1953-8ef8-5938-adfb6fb9b43f@yandex.ru> <83r11uzs8n.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="8196"; 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 Fri Aug 05 16:43:20 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 1oJyXo-0001zE-5u for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 05 Aug 2022 16:43:20 +0200 Original-Received: from localhost ([::1]:43036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJyXn-0007r6-5q for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 05 Aug 2022 10:43:19 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJyXW-0007kD-IV for bug-gnu-emacs@gnu.org; Fri, 05 Aug 2022 10:43:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42241) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oJyXW-0001E0-90 for bug-gnu-emacs@gnu.org; Fri, 05 Aug 2022 10:43:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oJyXW-0004Zq-39 for bug-gnu-emacs@gnu.org; Fri, 05 Aug 2022 10:43: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: Fri, 05 Aug 2022 14:43: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.165971052317521 (code B ref 56682); Fri, 05 Aug 2022 14:43:02 +0000 Original-Received: (at 56682) by debbugs.gnu.org; 5 Aug 2022 14:42:03 +0000 Original-Received: from localhost ([127.0.0.1]:60223 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oJyWY-0004YU-Ft for submit@debbugs.gnu.org; Fri, 05 Aug 2022 10:42:03 -0400 Original-Received: from mail-wm1-f50.google.com ([209.85.128.50]:52112) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oJyWV-0004Xy-2H for 56682@debbugs.gnu.org; Fri, 05 Aug 2022 10:42:00 -0400 Original-Received: by mail-wm1-f50.google.com with SMTP id s13so1058329wmj.1 for <56682@debbugs.gnu.org>; Fri, 05 Aug 2022 07:41:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=G1lBJxxQcpgKy0CM33ZMqsn+np+N6bJbYSdwvIUjn0g=; b=S6FHZM35FORW7SYFW+EHKjZAXBbBTVzJNOZMEjG9drJX128O83XYgliFMT8MKwYDTf gRarkkjJS417BS3i1BSXouqOJ8mLEiZgVgDSoo9zAIISYdC8IiyQ2Asu1lCwnVbJI/F7 WBTi3UKSk3ixPxyk+RZc8DvF0b1BOTR1QdiZcfz4SmXdTYmEHLg9tqFUCcDH7Av8+yCP iGvIUctdWwiulO3woxlP9dVG9KC9qHlMuhYgMy1XH0PLePvuimQ+folPl4NwU8kupYwY KWYVTAHog7uLtHD0f2MVpy7OpH1Y0XquH/roeNsQHxjkmHxYTwVjhVnI97dU9kmPxDON A4uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :subject:content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=G1lBJxxQcpgKy0CM33ZMqsn+np+N6bJbYSdwvIUjn0g=; b=KJJUg7oSe3LV7ZwLtwYJN7SSq9NaKssnO0HqO6VVEpBfmI8oFrPVdl5Dg8lN4I9ohm m28A+HmpBDzxRhpBLZhtVcTnZEHke0I6iMRCBcbnzvSVJkR2QpgPisvRMLJ1ZFZyvHIc s0SLuqHNCQEnF2DGaxEqTNren01anchAwNup7qTsdOd/HalphlQ9TV4V6IoCmKJ2HHuI dmwrbzYisslqpIFbXo/OeTRge+w5uPfOar4ZX6OfZ/cX4rrUQ255CgeMOCicsoVYPFMW iOMo3BYEaHa7jn//61OjVv4jyGxoddnbnaJdzkxqLdjTbgGKpSmNcpNPv1w7b8BYhHuS txhA== X-Gm-Message-State: ACgBeo0zMHrcD9pQbh6+8Ny5liYED5djxZKgr+xudX28I/CppRaaigV5 DtsLUL/AsQLfLmePcQZQbTI= X-Google-Smtp-Source: AA6agR6Njty//UBnCdP3UabnDeRAoKO7eEYxTuUXsmrRl8sWPtO/gDwa1jK+b2w7n/7IXE77V9JxyA== X-Received: by 2002:a05:600c:10cb:b0:3a5:1a6:2e86 with SMTP id l11-20020a05600c10cb00b003a501a62e86mr5141183wmd.160.1659710513195; Fri, 05 Aug 2022 07:41:53 -0700 (PDT) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id r16-20020a05600c2c5000b003a2e42ae9a4sm5451019wmg.14.2022.08.05.07.41.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 05 Aug 2022 07:41:52 -0700 (PDT) Content-Language: en-US In-Reply-To: <83r11uzs8n.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:238925 Archived-At: On 05.08.2022 17:20, Eli Zaretskii wrote: >> Date: Fri, 5 Aug 2022 15:59:57 +0300 >> Cc: 56682@debbugs.gnu.org, gregory@heytings.org >> From: Dmitry Gutov >> >> On 01.08.2022 14:58, Eli Zaretskii wrote: >> >>> As I wrote elsewhere, I'm okay with extending 'widen' so that it could >>> "unlock" the locked narrowing, which could then be used in major modes >>> that convince us their performance is adequate (or clearly announce in >>> their docs that they don't care about files with long lines ;-). >> >> And to address the idea of "unlocking" the narrowing: I think I have >> demonstrated that the remaining slowdown can be caused purely by the >> length of the buffer and how long 'parse-partial-sexp' takes to parse >> it. > > No, you haven't demonstrated that. Apply the patch for xdisp.c that I have sent previously (it will be at the end of this email too) and recompile Emacs. Now try two different scenarios. 1,2a and 1,2b. 1. Visit dictionary.json. It will ask you whether to open such big file literally, but after you answer 'y', it will display the beginning of the file quickly. 2a) Evaluate (benchmark 1 '(save-excursion (parse-partial-sexp 1 (point-max)))), note the reported delay. Kill and re-visit the file. 1. (same as before) 2b) Press M->, note the delay you see. The delays in scenarios 1,2a and 1,2b should be ~the same. They are so in my testing. Or try this scenario: 1,2a,2b. Step 2b should work instantly here. The patch: diff --git a/src/xdisp.c b/src/xdisp.c index 099efed2db..02d7f6c562 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -4391,19 +4391,19 @@ handle_fontified_prop (struct it *it) eassert (it->end_charpos == ZV); - if (current_buffer->long_line_optimizations_p) - { - ptrdiff_t begv = it->narrowed_begv; - ptrdiff_t zv = it->narrowed_zv; - ptrdiff_t charpos = IT_CHARPOS (*it); - if (charpos < begv || charpos > zv) - { - begv = get_narrowed_begv (it->w, charpos); - zv = get_narrowed_zv (it->w, charpos); - } - narrow_to_region_internal (make_fixnum (begv), make_fixnum (zv), true); - specbind (Qrestrictions_locked, Qt); - } + /* if (current_buffer->long_line_optimizations_p) */ + /* { */ + /* ptrdiff_t begv = it->narrowed_begv; */ + /* ptrdiff_t zv = it->narrowed_zv; */ + /* ptrdiff_t charpos = IT_CHARPOS (*it); */ + /* if (charpos < begv || charpos > zv) */ + /* { */ + /* begv = get_narrowed_begv (it->w, charpos); */ + /* zv = get_narrowed_zv (it->w, charpos); */ + /* } */ + /* narrow_to_region_internal (make_fixnum (begv), make_fixnum (zv), true); */ + /* specbind (Qrestrictions_locked, Qt); */ + /* } */ /* Don't allow Lisp that runs from 'fontification-functions' clear our face and image caches behind our back. */