From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#56682: Fix the long lines font locking related slowdowns Date: Sat, 23 Jul 2022 16:42:43 +0300 Message-ID: <83bktghrn0.fsf@gnu.org> References: <837d46mjen.fsf@gnu.org> <174616cd5c33bfc14b1f@heytings.org> <837d44jr4p.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5533"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 56682@debbugs.gnu.org, gregory@heytings.org, monnier@iro.umontreal.ca To: Gerd =?UTF-8?Q?M=C3=B6llmann?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 23 15:43:10 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 1oFFPR-0001GM-Qi for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 23 Jul 2022 15:43:10 +0200 Original-Received: from localhost ([::1]:44898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oFFPQ-0003Xk-Di for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 23 Jul 2022 09:43:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33544) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFFPK-0003Xc-Nz for bug-gnu-emacs@gnu.org; Sat, 23 Jul 2022 09:43:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54063) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oFFPK-0007vK-FY for bug-gnu-emacs@gnu.org; Sat, 23 Jul 2022 09:43:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oFFPK-0001mx-7c for bug-gnu-emacs@gnu.org; Sat, 23 Jul 2022 09:43:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 23 Jul 2022 13: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.16585837766851 (code B ref 56682); Sat, 23 Jul 2022 13:43:02 +0000 Original-Received: (at 56682) by debbugs.gnu.org; 23 Jul 2022 13:42:56 +0000 Original-Received: from localhost ([127.0.0.1]:43812 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oFFPD-0001mQ-G8 for submit@debbugs.gnu.org; Sat, 23 Jul 2022 09:42:55 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:48832) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oFFPC-0001mA-1m for 56682@debbugs.gnu.org; Sat, 23 Jul 2022 09:42:54 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:39280) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFFP4-0007uG-U3; Sat, 23 Jul 2022 09:42:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=X+tvfLBiIlkbH5mUwQkRkO+FjnzKnb0HlhBYGtRcD9Q=; b=l30GZnybnWGZSsO9GRZv fd2ELqWJLhao54eifiPQWWnTeWZp9Iq2Xj2Fa5kjeqpmmnAo9e68/AkGKBTjZAD8HPxXzzzK2AHoX ua4WOhFexjhWCcUonKSJ4CLgvmboEWv87Tol2uUGxaPpKsculRKqBritYoLLHWtuj768iR3+YvGuK nrOG+44J5rr98HOu8nhjTvuj/gCwwqwVfwrAw2KMVgHFRpMZqDjrGJoyyHNdxPg10mKBcVJ9Tgcj/ KpBz1ZBDYyz58nSuOa6tOPsz1RqfZX8AvUktnod6XBisMxGjLCcoJ6tqFacWvNoXSci/CrIZDzssp Y/Q6JOFevqJYZQ==; Original-Received: from [87.69.77.57] (port=2714 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFFP4-0002ZN-B8; Sat, 23 Jul 2022 09:42:46 -0400 In-Reply-To: (message from Gerd =?UTF-8?Q?M=C3=B6llmann?= on Sat, 23 Jul 2022 10:11:04 +0200) 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:237742 Archived-At: > From: Gerd Möllmann > Cc: 56682@debbugs.gnu.org, Gregory Heytings , Stefan > Monnier > Date: Sat, 23 Jul 2022 10:11:04 +0200 > > Gerd Möllmann writes: > > > Gerd Möllmann writes: > > > >>> Gerd Möllmann writes: > >>> > >>>> Font-lock Output > >>>> ------------------------------------------------------------ > >>>> on GCs: 14 Elapsed time: 7.880788 seconds > >>> on, and large gc-const-threshold > >>> GCs: 0 Elapsed time: 7.720531 seconds > > on, without scroll-bar > > GCs: 15 Elapsed time: 5.574946 seconds > on without scroll-bar, auto-composition-mode off > GCs: 15 Elapsed time: 4.166101 seconds > >>>> off GCs: 2 Elapsed time: 0.885791 seconds > > Hm. scroll-bar could be an issue only if we enter the new code that doesn't use window_end_pos if it cannot be trusted. Perhaps when long-line optimizations are turned on for a buffer, we shouldn't try to be holier than the Pope, and should use window_end_pos even if not reliable? And I've found a serious sink of CPU cycles under truncate-lines, and installed a fix on the feature branch. Gerd, if you have time to eyeball the fix and comment on it, I'd appreciate. It's commit 350e97d on the branch. (I can post a more detailed explanation of what I did and why, if that would help, because the code and the functions it calls are somewhat tricky.) After these changes, display of very long lines is quite reasonable, when truncate-lines or truncate-partial-width-windows is in effect, even without turning off font-lock and even in an unoptimized build. Amusingly enough, show-paren-mode is now a serious performance killer in these cases, because it puts overlays on buffer text, and that disables a shortcut in the code that finds the next visible line start, which is called a lot when lines are truncated. Maybe we need a smarter optimization there, one that doesn't immediately give up as soon as it sees an overlay. Hmm...