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#62780: 30.0.50; Redisplay gets slow when using Org tables + show-trailing-whitespace Date: Wed, 12 Apr 2023 10:19:38 +0300 Message-ID: <83bkjt8t4l.fsf@gnu.org> References: <87mt3e8d50.fsf@localhost> <83y1my8bmi.fsf@gnu.org> <87h6tm8awi.fsf@localhost> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34146"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 62780@debbugs.gnu.org To: Ihor Radchenko Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Apr 12 09:20:21 2023 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 1pmUmC-0008fN-6i for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 12 Apr 2023 09:20:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pmUm2-0007FQ-42; Wed, 12 Apr 2023 03:20:10 -0400 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 1pmUlw-0007Ez-26 for bug-gnu-emacs@gnu.org; Wed, 12 Apr 2023 03:20:06 -0400 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 1pmUlu-00032j-QD for bug-gnu-emacs@gnu.org; Wed, 12 Apr 2023 03:20:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pmUlu-0001WI-3t for bug-gnu-emacs@gnu.org; Wed, 12 Apr 2023 03:20: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: Wed, 12 Apr 2023 07:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62780 X-GNU-PR-Package: emacs Original-Received: via spool by 62780-submit@debbugs.gnu.org id=B62780.16812839435771 (code B ref 62780); Wed, 12 Apr 2023 07:20:02 +0000 Original-Received: (at 62780) by debbugs.gnu.org; 12 Apr 2023 07:19:03 +0000 Original-Received: from localhost ([127.0.0.1]:38869 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pmUkw-0001V0-W7 for submit@debbugs.gnu.org; Wed, 12 Apr 2023 03:19:03 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:36068) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pmUkt-0001UF-CJ for 62780@debbugs.gnu.org; Wed, 12 Apr 2023 03:19:01 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pmUkn-0002ux-S5; Wed, 12 Apr 2023 03:18:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=6cUumKfvd3Wb4OvJdSp5ZqqBX53T/sT7v93fXniXtJg=; b=az7OMiUeokqq B6Mz6aH/PHRgjjVmOONGvStdyck38eiq69bH05NMzkO0i/hd9LOAGLaq2iB8K98JB/QDbZIZhiszw /DNQVWhMH04YQ2Eiw+JO3InN6/a26F/rePMJIXvK1iYTD4zUX7WiSOMw0nL3RHSH0WCeITaql59UR ft5l0hXPegQ4dFnRemCn7G266PXC+oKkdEa1yQZ7PGd09F36c+weSi0wQHSvSpgnec0sGmmuHHQj0 xjpjCZnoRZTE0rNgiypdr29dUja1g6qR/9dXavL6fzYf09gusta9gEK0XWVqX6KFWhaF1eKuXh91t Y7lMGjILRz37cSe3e0o9xQ==; Original-Received: from [87.69.77.57] (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 1pmUkn-0004eK-9M; Wed, 12 Apr 2023 03:18:53 -0400 In-Reply-To: <87h6tm8awi.fsf@localhost> (message from Ihor Radchenko on Tue, 11 Apr 2023 19:41:01 +0000) 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:259699 Archived-At: > From: Ihor Radchenko > Cc: 62780@debbugs.gnu.org > Date: Tue, 11 Apr 2023 19:41:01 +0000 > > Eli Zaretskii writes: > > > show-trailing-whitespace disables quite a few redisplay optimizations, > > including even the cursor-motion optimization (when nothing has > > changed on display except the position of point). And full thorough > > redisplay becomes slow when you have relatively long lines, because > > Emacs is forced to consider all of them. > > Well. But it is not even that big of a file. The size of the file doesn't matter, only what's shown in the window matters. > And the lines are shorter than window width. Not here, they aren't: a 50x30 table takes more than twice the default window width of "emacs -Q". However, I don't think this aspect is important, either. > > In addition, org-table seems to put a large number of 'display' > > properties (like, 2 per cell?), which also slows down redisplay. > > These properties are for the purpose of bidirectional ordering: > > (defconst org-table--separator-space-pre > (propertize " " 'display '(space :relative-width 1)) > "Space used in front of fields when aligning the table. > This space serves as a segment separator for the purposes of the > bidirectional reordering. > Note that `org-table--separator-space-pre' is not `eq' to > `org-table--separator-space-post'. This is done to prevent Emacs from > visually merging spaces in an empty table cell. See bug#45915.") I understand. But it's definitely what causes most of the slowdown; show-trailing-whitespace just adds the last straw. With the patch below I can see no slowdown at all with your recipe. > Maybe there is a better way? Maybe. Can you point me to the discussion which caused you to use these display properties there? I think this was done in two steps: first you added the same display property as pre and post, then made them subtly different; I need to re-read the discussions that led to both of these. Alternatively, if you can describe the use cases where these properties are needed, that could be enough for me to try to look for alternative solutions. > > Are you saying there's been a regression in Emacs 30 in this situation > > wrt Emacs 29 and Emacs 28? I don't think I see a regression in my > > testing here. > > No, I do not mean a regression. But the slowdown appears to be > unreasonable for such a small test case. What is the point having > `show-trailing-whitespace' if it is this much inefficient? Maybe a > simple font-lock rule can be better? See above: show-trailing-whitespace is not the main culprit here; these particular display properties are. If you could produce a perf profile with this recipe, it might give ideas for speeding up the C code without any changes on the Lisp level. Btw, these properties were introduced into org-table.el some time ago, so how come this issue comes up only now? Aren't Org tables used quite a lot? diff --git a/lisp/org/org-table.el b/lisp/org/org-table.el index 5116b11..658b5aa 100644 --- a/lisp/org/org-table.el +++ b/lisp/org/org-table.el @@ -4354,11 +4354,12 @@ org-table--align-field ("r" (make-string spaces ?\s)) ("c" (make-string (/ spaces 2) ?\s)))) (suffix (make-string (- spaces (length prefix)) ?\s))) - (concat org-table--separator-space-pre + (concat " " ;org-table--separator-space-pre prefix field suffix - org-table--separator-space-post))) + " " ;org-table--separator-space-post + ))) (defun org-table-align () "Align the table at point by aligning all vertical bars."