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: Tue, 26 Jul 2022 20:55:05 +0000 Message-ID: References: <837d46mjen.fsf@gnu.org> <174616cd5c33bfc14b1f@heytings.org> <837d44jr4p.fsf@gnu.org> <83bktghrn0.fsf@gnu.org> <8a3eaeef010995a5da8d@heytings.org> <837d40ds09.fsf@gnu.org> <83zggwcby5.fsf@gnu.org> <83o7xccagi.fsf@gnu.org> <831qu7daxb.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2507"; mail-complaints-to="usenet@ciao.gmane.io" Cc: gerd.moellmann@gmail.com, 56682@debbugs.gnu.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 Tue Jul 26 22:58:05 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 1oGRcz-0000T6-5t for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 26 Jul 2022 22:58:05 +0200 Original-Received: from localhost ([::1]:36792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGRcy-0004JX-91 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 26 Jul 2022 16:58:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38042) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGRb0-0002fx-PE for bug-gnu-emacs@gnu.org; Tue, 26 Jul 2022 16:56:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36517) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGRb0-0000Eq-Gj for bug-gnu-emacs@gnu.org; Tue, 26 Jul 2022 16:56:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oGRb0-0007Kq-4q for bug-gnu-emacs@gnu.org; Tue, 26 Jul 2022 16:56: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: Tue, 26 Jul 2022 20:56: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.165886891028113 (code B ref 56682); Tue, 26 Jul 2022 20:56:02 +0000 Original-Received: (at 56682) by debbugs.gnu.org; 26 Jul 2022 20:55:10 +0000 Original-Received: from localhost ([127.0.0.1]:54499 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oGRa9-0007JN-JQ for submit@debbugs.gnu.org; Tue, 26 Jul 2022 16:55:10 -0400 Original-Received: from heytings.org ([95.142.160.155]:54056) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oGRa6-0007JE-Uu for 56682@debbugs.gnu.org; Tue, 26 Jul 2022 16:55:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org; s=20220101; t=1658868905; bh=EU5TYXmKuFqjUomcvfGpNQIOJz4ST2AqjWATIEuetUQ=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From; b=BrTrhuIO/ewgNNQFjqHjxuq8YsqRpJCYctmXXbS7W0R1xA31lmPQHWX+q0LnzFV+D gH+HVmMMihu7KR+5tN5uLbGBonyz0iNQHQxgRwIDi430X5oMKJ8Ev11IrT9B5d+enD uXyMLQ3zQ+lKJX2uG5qbL2/ibUnplpimnAjDv8Akejlfm8SSAXZ08dQwjVASmNXYrU fAx7+ywr81Lzfl2CtVOcjjyndt6n6CsvlbnoQKRs+DZpkG9lMu/5lSLXgGkVfGY0ap mBItBIdJNmm0EX3KDjYMBytd4lWW+m7O+dF5iAsagLXv2ApcNed8QL0drqzg4Am2PR 7EK/RWdVKVwWQ== In-Reply-To: <831qu7daxb.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:237989 Archived-At: > > Heh, it's a case of "better is worse". There's nothing wrong with the > change in commit 350e97d78e: it does indeed make redisplay of > long-and-truncated lines significantly faster. And that speedup is > what's causing the problem: because the initial redisplay of the buffer, > before the results of C-s are displayed, is much faster, the > lazy-highlighting starts very soon, and it inserts thousands of overlays > into the buffer (because it by default highlights all the matches till > window-end, which is EOB in this case). And once it inserts enough > overlays, we are dead in the water: the shortcut in > forward_to_next_line_start can no longer be taken, and we instead > iterate the slow way, one character at a time, all the way to EOB, and > on top of that need on the way to examine every one of the overlays > inserted by lazy-highlighting. > Thanks; as far as I can see your analysis is correct. At 304e2a3a05, if I press C-s > At this point, I think the only way to produce reasonable performance > from C-s in this case is to turn off lazy-highlighting when lines are > truncated and the buffer has long lines. Which means we need to expose > the value of long_line_optimizations_p to Lisp, via an accessor > function. I already have one other use for this: "C-x =", which > attempts to report the column of the character, something that is very > slow in a long-and-truncated line. And I think we will see more cases > where Lisp code needs to know about this in order to adapt itself to > long lines. > My conclusion is different: we will see more such cases, but only with truncate-lines enabled, and that means that truncate-lines should be disabled in such buffers. The fundamental problem is that with truncate-lines we cannot really narrow the buffer to a smaller (contiguous) portion without creating problems. What would be necessary would be some kind of non-contiguous narrowing. If we are on line 1, on column 10000, of a buffer with 80 lines each of which is 20000 characters wide, what we see on screen are characters 9960-10040, 29960-30040, 49960-50040, 69960-70040, and so forth. Without such a non-continguous narrowing, all kinds of problems like the C-s and C-x = one you identified will appear. These problems can indeed, in principle, be solved by adding local fixes depending on (long-line-optimizations-p) whenever we encounter such a bug, but doing that would be most regrettable, as the simplicity of these optimizations would be largely lost. Doing that while knowing that, as I said, we'll hit another ceil very soon is clearly (to me at least) not TRT.