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: Thu, 13 Apr 2023 13:45:07 +0300 Message-ID: <83ttxk3vt8.fsf@gnu.org> References: <87mt3e8d50.fsf@localhost> <83y1my8bmi.fsf@gnu.org> <87h6tm8awi.fsf@localhost> <83bkjt8t4l.fsf@gnu.org> <87bkjsf72g.fsf@localhost> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26243"; 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 Thu Apr 13 12:45:17 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 1pmuS5-0006ci-BK for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 13 Apr 2023 12:45:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pmuRt-0005D7-Hs; Thu, 13 Apr 2023 06:45:05 -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 1pmuRr-0005Cj-2t for bug-gnu-emacs@gnu.org; Thu, 13 Apr 2023 06:45:03 -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 1pmuRq-0000xC-QL for bug-gnu-emacs@gnu.org; Thu, 13 Apr 2023 06:45:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pmuRq-0001sR-4u for bug-gnu-emacs@gnu.org; Thu, 13 Apr 2023 06:45: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: Thu, 13 Apr 2023 10:45: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.16813826737157 (code B ref 62780); Thu, 13 Apr 2023 10:45:02 +0000 Original-Received: (at 62780) by debbugs.gnu.org; 13 Apr 2023 10:44:33 +0000 Original-Received: from localhost ([127.0.0.1]:42593 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pmuRM-0001rM-Tc for submit@debbugs.gnu.org; Thu, 13 Apr 2023 06:44:33 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:54678) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pmuRI-0001r6-Dv for 62780@debbugs.gnu.org; Thu, 13 Apr 2023 06:44:30 -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 1pmuRC-0000im-BP; Thu, 13 Apr 2023 06:44:22 -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=DykV/vW7eXMPVIUVRZS7AVjzljdg3bMENS2RyezoNxQ=; b=HtE3joT1uI2M HZlBehpRIWewlBRmjdDnpRNIK1pWfyZ9owllR0i0SRKaz7cTVRQnFYHqkvkAAz3VEl5iL1zVyGBRa j6ywwX3q3ZD5LW5cIZiaAS82h5jf6WgHBv/64fFsPr+OoWcqPpdDDB2OwUpNLGTPP9xW0u2WN9z6w aQGD9CJTGncHH6C/sLappO9opO/2foqEMOAaXbLSEz5tlZwcM7diCBHwIb0FVmiQAQt7rzRsOiFme YZrD/bYeLb7pjuT9+E/ekW8kdyO2eboJIEKeXodpc6f5VsPMpGQMqSWk0eorTND0Uno3CxPle/NTx p8abSXqSEvlJSX5gIdIsfw==; 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 1pmuRB-0005XA-FF; Thu, 13 Apr 2023 06:44:21 -0400 In-Reply-To: <87bkjsf72g.fsf@localhost> (message from Ihor Radchenko on Thu, 13 Apr 2023 09:46:31 +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:259847 Archived-At: > From: Ihor Radchenko > Cc: 62780@debbugs.gnu.org > Date: Thu, 13 Apr 2023 09:46:31 +0000 > > Eli Zaretskii writes: > > > 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. > > Here are perf results when typing, using the same recipe. > > Full summary: > > 29.89% emacs emacs [.] lookup_char_property > 16.58% emacs emacs [.] next_interval > 13.99% emacs emacs [.] Fassq > 5.44% emacs emacs [.] find_interval > 5.17% emacs emacs [.] Fcdr > 3.97% emacs emacs [.] Fnext_single_property_change > 2.32% emacs emacs [.] composition_compute_stop_pos > 1.51% emacs emacs [.] validate_interval_range > 1.03% emacs emacs [.] get_char_property_and_overlay > 0.99% emacs emacs [.] textget > 0.79% emacs emacs [.] plist_get > 0.77% emacs emacs [.] produce_stretch_glyph > 0.76% emacs emacs [.] balance_an_interval > 0.54% emacs emacs [.] lface_hash > > Call graph: > > (next_interval is spread thin across the call graph, used all over the place) > > 99.10%--command_loop_1 > 97.65%--read_key_sequence > 97.55%--read_char > 97.51%--redisplay redisplay_internal > 97.49%--redisplay_windows internal_condition_case_1 redisplay_window_0 > 97.49%--redisplay_window > |65.03%--try_window > ||32.55%--display_line > || 28.90%--get_next_display_element > || 28.83%--next_element_from_buffer > || 28.75%--handle_stop > || 23.87%--compute_stop_pos > || 23.52%--composition_compute_stop_pos > || 21.61%--find_composition > || 21.31%--Fnext_single_property_change > || 17.84%--textget > || 16.84%--lookup_char_property > || 6.15%--builtin_lisp_symbol > || 5.28%--make_lisp_symbol > || 5.94%--Fassq > || 32.47%--partial_line_height move_it_to > | 31.11%--move_it_in_display_line_to > | 28.95%--get_next_display_element > | 28.86%--next_element_from_buffer > | 28.80%--handle_stop > | ... 16.75%--lookup_char_property > |32.42%--set_vertical_scroll_bar > 32.41%--move_it_to > 31.05%--move_it_in_display_line_to > 28.86%--get_next_display_element > ... 16.54%--lookup_char_property This unfortunately says that looking up text properties is what takes a large fraction of the time, which is consistent with the fact that there are a lot of text properties in the buffer, and they happen almost every character. So maybe the immediate band-aid would be to offer a user option, by default off, which will control whether these 'display' properties are used: only users who actually need to type bidirectional text inside the table will need to turn on the option. Another possibility is to use "Method 1" I described in https://lists.gnu.org/archive/html/emacs-orgmode/2017-12/msg00526.html I know I said afterwards that Method 2 was better (and it is), but I obviously didn't consider the effect on performance, and neither had a test case for that back then. So maybe Method 1, while theoretically less desirable, will in practice do the job and avoid the performance issues, assuming that the invisibility aspect can be ignored (i.e. users won't mind having 1-pixel thin spaces in the cells).