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: Thu, 28 Jul 2022 16:29:44 +0000 Message-ID: <136c4fe0fc74196714aa@heytings.org> 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> <83sfmnb7yg.fsf@gnu.org> <837d3ybh5z.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="18581"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Gerd =?UTF-8?Q?M=C3=B6llmann?= , 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 Thu Jul 28 18:30:14 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 1oH6Os-0004cL-E8 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 28 Jul 2022 18:30:14 +0200 Original-Received: from localhost ([::1]:44700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oH6Oq-0005R4-Iu for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 28 Jul 2022 12:30:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oH6Oh-0005Qh-6b for bug-gnu-emacs@gnu.org; Thu, 28 Jul 2022 12:30:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41322) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oH6Og-0007KZ-TC for bug-gnu-emacs@gnu.org; Thu, 28 Jul 2022 12:30:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oH6Og-000310-KB for bug-gnu-emacs@gnu.org; Thu, 28 Jul 2022 12:30: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: Thu, 28 Jul 2022 16:30: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.165902579011537 (code B ref 56682); Thu, 28 Jul 2022 16:30:02 +0000 Original-Received: (at 56682) by debbugs.gnu.org; 28 Jul 2022 16:29:50 +0000 Original-Received: from localhost ([127.0.0.1]:59304 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oH6OT-000301-KK for submit@debbugs.gnu.org; Thu, 28 Jul 2022 12:29:50 -0400 Original-Received: from heytings.org ([95.142.160.155]:56458) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oH6OQ-0002zn-GO for 56682@debbugs.gnu.org; Thu, 28 Jul 2022 12:29:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heytings.org; s=20220101; t=1659025785; bh=94xHazTM3TagleEKcEYiIww+nqYByMMxB5/bzkVT7l0=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:From; b=lccmRBnyMUU4MT+OLjuvfmgzKOZqaU/EG8krt3NUooaCUVNVqEWXlHXwwlpx07Svn mvlGs87CFq8OOjLP3EjJATiLg9Po+wfWgODbPXj8wu9S/46qn7LKiWt3sfRx4Twbly g53teNzlUgvSWCi2v1CZ4a3QsPYVWI1aL0wfaLM9mR9JX7p4pD9/h9YboenJGBoHO/ Mw9iTgYhjCPjOgHtmTbG7vN1BXkFtQhxWhhSEGuPvLxdZ3lvvgAkRW8s76o/7/MmcN VtMZCl9zEXba5VS2AQYMrG8WNQNTBdmnw21SSiaJaMR6iBe8JZzdQI7nMPp6jmGQjc WWqvLeENc73tg== In-Reply-To: <837d3ybh5z.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:238120 Archived-At: > > Thanks, I installed an optimization, which makes Isearch faster in such > cases. > Thanks. Alas, as far as I can see, we're still quite far from a usable Emacs with long-and-truncated lines. A recipe: emacs -Q C-x C-f long-line.xml RET M-g g 12 C-u 12 M-x duplicate-line C-x C-s multiple-long-lines.xml RET C-x C-f multiple-long-lines.xml RET y C-x x t C-s > Turning off isearch-lazy-highlight in these cases is still a good idea, > though. > Indeed, (setq isearch-lazy-highlight nil) "fixes" the above recipe (but see below). > > The next problem with long-and-truncated lines is that in many places as > part of redisplay we begin from the line's beginning and then go to the > position of point or the first visible X coordinate or somesuch. This > becomes slow when point is very far to the right, like near the end of > the line. A typical place in the code where this happens is at > beginning of display_line, where we call move_it_in_display_line_to to > get to it->first_visible_x. This could take seconds if there are many > overlays on the line, which is what happens, for example, if we are in > the middle of Isearch and isearch-lazy-highlight is turned ON. > Indeed, Emacs isn't really usable. For example, with multiple-long-lines.xml, after M-g g 20 C-e (which already takes several seconds to complete) each motion, search or insertion command still takes several seconds (even with find-file-literally). For example (without isearch-lazy-highlight), C-s RET takes about 10 seconds. After that, C-s C-s takes another 10 seconds, an additional C-s also takes 10 seconds, and C-g to abort isearch takes about 90 seconds. And, even when you don't do anything, Emacs uses 100% of the CPU. All this is, in the same file, instantaneous without truncate-lines. > > (Searching for " That's (another sign of) the fundamental problem I mentioned earlier. Without truncate-lines the visible portion of the buffer remains small, and it is thus possible to reduce the portion of the buffer that display routines will see. With truncate-lines it can easily become huge. For example, with multiple-long-lines.xml, (- (window-end) (window-start)) is 7744464 with truncate-lines and 2454 without truncate-lines. And multiple-long-lines.xml is still a relatively "small" file, it's only 15 MB. > > I'll try to think how to speed up these move_it_* calls in those cases. > Ideas welcome. > I cannot claim I understand the display code enough, but I see no way to make the portion of the buffer that is considered by display routines smaller without introducing the kind of rectangular narrowing I mentioned earlier. As far as I understand, everything else is just a band-aid, that will make Emacs behave a bit faster only in some cases, and with which Emacs will remain unresponsive in too many cases. Perfect is the enemy of good. I strongly suggest we just admit that Emacs can't cope with long lines and truncate-lines together, which is true anyway given the DISP_INFINITY limit.