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: locked narrowing Date: Tue, 29 Nov 2022 05:20:30 +0200 Message-ID: References: <831qtgff78.fsf@gnu.org> <83zgg4dw4y.fsf@gnu.org> <83r11gdrr4.fsf@gnu.org> <83edxfds7s.fsf@gnu.org> <83r11fc80o.fsf@gnu.org> <83o7wjc6o2.fsf@gnu.org> <83lernc5gu.fsf@gnu.org> <83k076dd7d.fsf@gnu.org> <83czcyd8jf.fsf@gnu.org> <83a682d66r.fsf@gnu.org> <837d36ceno.fsf@gnu.org> <37dd2827f54f8bbda5e3@heytings.org> <735c1d5b-0d64-a8e1-3aaa-91fc0248abd3@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38273"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Cc: 56682@debbugs.gnu.org, Eli Zaretskii , Stefan Monnier To: Gregory Heytings Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 29 04:21:26 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 1ozrBV-0009qq-R4 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 29 Nov 2022 04:21:25 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ozrBB-0005mh-Cb; Mon, 28 Nov 2022 22:21:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ozrB8-0005mT-PF for bug-gnu-emacs@gnu.org; Mon, 28 Nov 2022 22:21:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ozrB8-0002pL-Gc for bug-gnu-emacs@gnu.org; Mon, 28 Nov 2022 22:21:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ozrB7-0002Pe-Ti for bug-gnu-emacs@gnu.org; Mon, 28 Nov 2022 22:21:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 29 Nov 2022 03:21:01 +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.16696920429245 (code B ref 56682); Tue, 29 Nov 2022 03:21:01 +0000 Original-Received: (at 56682) by debbugs.gnu.org; 29 Nov 2022 03:20:42 +0000 Original-Received: from localhost ([127.0.0.1]:52615 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozrAn-0002P2-Tn for submit@debbugs.gnu.org; Mon, 28 Nov 2022 22:20:42 -0500 Original-Received: from mail-wm1-f51.google.com ([209.85.128.51]:54183) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ozrAl-0002Ow-8u for 56682@debbugs.gnu.org; Mon, 28 Nov 2022 22:20:39 -0500 Original-Received: by mail-wm1-f51.google.com with SMTP id p16so9937293wmc.3 for <56682@debbugs.gnu.org>; Mon, 28 Nov 2022 19:20:39 -0800 (PST) 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:subject:date:message-id:reply-to; bh=3U/68ZnKfO+nxG9MKc/E6gWMLr+4JH5BJdEEJuve0NM=; b=kwN9Bz02RLuM8RYNNNfGTIG7BvFQavwfOu5yAmEwMp/U4aaNjuTpXP6o898b/Sl7+c ey1XlnHdNU6CqNuLSLpSKY+js81usAKiX6ma+tK+wLU/ZbLG6SrcH8u73vkuIL2IyC3f 9MrVCVxT6E2/E42sNWcBqIdd3ueaAqdGmYZ6ja1mx2sCtk7MZFDQV5rsGwvLmDMIHdHh /itaQTprDVXVEgR3IoWL9ErXI+HQo5syYSN1rpNzACxsmP1agKzLMEiYQWIHtDGGQWPm sxTso0vGHMMVsUQs8OCPq6RbUirqbpMitRwvS5NQaRsxFjHkjuLCwC+czo8cwpOxrvcn LTqg== 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:subject:date:message-id :reply-to; bh=3U/68ZnKfO+nxG9MKc/E6gWMLr+4JH5BJdEEJuve0NM=; b=snbWZlONTD0YVFmCfgByawI1M4gSVegTFflwhgeqEfUEiFNQPthyPzxfYBdfslShTJ isOf6iLmzLy4CvNab5fYwoskpmnNDZSoYTH/Ir52I4aSmkXAEQv6oPA6oY7HAquTHqbR X9hJun1AsC18aJPwnGgX23hyq+RgCCR/vSwqe1KPQVTGGKxRbFExqXkOuoO9iohoU4ZM 9I/TEdMkkEi9RuBxpJMr8/LkYGHDX1PDCtTs5qZpZ1oiuCVUabSI8alWIPobnpWaDGUZ Rjd4vfr2SgprfPSr7haRvkNzyzf+2dIjwBC7YR3UmEi/4m2/TbnGkVq3TOjIwMTIYjxd DyvA== X-Gm-Message-State: ANoB5pmHqZXwEU8buxhtaEAjrwvXjdyaFBcLg2SeiN1kiZixjI3Zg7AE 9OeDudjZ6l1QSZbZBIFWCC0= X-Google-Smtp-Source: AA0mqf5TZGk0/Xvg+a3mvt+wn9QVFi+mgTyeSFH/oqe/8R8EM10xNl5dFBLO0EL0DnB8uKSYMZ4Wvw== X-Received: by 2002:a05:600c:4f10:b0:3b4:ff86:25af with SMTP id l16-20020a05600c4f1000b003b4ff8625afmr25261091wmq.68.1669692033098; Mon, 28 Nov 2022 19:20:33 -0800 (PST) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id f18-20020a05600c4e9200b003c6c182bef9sm502524wmq.36.2022.11.28.19.20.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 28 Nov 2022 19:20:32 -0800 (PST) Content-Language: en-US In-Reply-To: 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:249362 Archived-At: Hi Gregory, On 26/11/2022 16:14, Gregory Heytings wrote: > I pushed another change to the feature/improved-locked-narrowing branch, > which makes the locked narrowing around low-level hooks (and therefore > around fontification-functions) configurable.  I hope that addresses > your concerns. Thank you, this looks like a step in the right direction. But I tried to see the effects of this new variable (long-line-locked-narrowing-region-size), and it was a little puzzling. With the default value (500000) I open dictionary.json and start hitting PgDn a lot. Syntax highlighting starts to look broken at the buffer position that's around half that: at my last attempt it was at point 259999. Looking at the code, there is indeed some halving going on, so maybe it would be more easier to understand if the variable was called locked-narrowing-radius, and used as such -- without division. Either way, though, if I set the var to a very large value, the syntax highlighting looks okay. Another thing that bothered me when testing: going from eob to bob in dictionary.json took ~4 seconds every time, independent of buffer being edited or not. And that delay didn't show up anywhere in the profiler. (setq bidi-inhibit-bpa nil) didn't help at all, but (setq bidi-display-reordering nil) eliminated that delay. So I'm still kind of puzzled why we bother to restrict font-lock, but didn't do that with this significantly more costly computation. The value of long-line-locked-narrowing-region-size (big or small) has no effect on it. Going back higher level, I wanted to repeat that don't understand why we apply narrowing around font-lock in buffers with long lines, but not in large buffers without long lines. Or vice versa. And we'll probably come back to this question sometime later, but here's something that looks like a regression. Editing dictionary.json is snappier than dictionary-pp.json (same file but pretty-printed so without long lines). Even with with common setup (and emacs -Q): 1. (setq long-line-locked-narrowing-region-size 50000) 2. (setq bidi-display-reordering nil) 3. Toggle show-paren-mode off, just in case. 4. electric-pair-mode off, same. typing in the latter file exhibits random pauses in redisplay up to 0.5s (and sometimes 1s+). I haven't managed to catch the exact source of those pauses (and they're longer with my personal config), but even regular editing is slower: evaluating (benchmark 1 '(progn (insert " ") (redisplay t))) in dictionary.json reports something like 0.038906s, but in dictionary-pp.json it prints ~0.136387s. Commit 89a10ffc (before the last merge) behaves the same, but going further back, this commit from July behaves differently: b283e36cf19. Emacs built from that version reports ~0.033022s in dictionary-pp.json and 0.114781s at bob in dictionary.json (scrolling to the end predictably freezes that Emacs build).