From unknown Fri Jun 20 20:04:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23327: 25.0.92; show-trailing-whitespace uses too much cpu Resent-From: Mohammed Sadik Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 21 Apr 2016 06:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 23327 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 23327@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.146121869413728 (code B ref -1); Thu, 21 Apr 2016 06:05:02 +0000 Received: (at submit) by debbugs.gnu.org; 21 Apr 2016 06:04:54 +0000 Received: from localhost ([127.0.0.1]:41877 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1at7jR-0003ZM-LO for submit@debbugs.gnu.org; Thu, 21 Apr 2016 02:04:53 -0400 Received: from eggs.gnu.org ([208.118.235.92]:46338) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1at7jQ-0003Z7-23 for submit@debbugs.gnu.org; Thu, 21 Apr 2016 02:04:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1at7jK-0006kt-3h for submit@debbugs.gnu.org; Thu, 21 Apr 2016 02:04:47 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:45821) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1at7jK-0006kp-1C for submit@debbugs.gnu.org; Thu, 21 Apr 2016 02:04:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1at7jI-0004ve-UO for bug-gnu-emacs@gnu.org; Thu, 21 Apr 2016 02:04:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1at7jD-0006kJ-T0 for bug-gnu-emacs@gnu.org; Thu, 21 Apr 2016 02:04:44 -0400 Received: from md-77.webhostbox.net ([199.79.62.63]:46107) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1at7jD-0006Y8-Nr for bug-gnu-emacs@gnu.org; Thu, 21 Apr 2016 02:04:39 -0400 Received: from mail-wm0-f41.google.com ([74.125.82.41]:38063) by md-77.webhostbox.net with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.86_1) (envelope-from ) id 1at7iW-002zPy-Im for bug-gnu-emacs@gnu.org; Thu, 21 Apr 2016 06:03:57 +0000 Received: by mail-wm0-f41.google.com with SMTP id u206so113967273wme.1 for ; Wed, 20 Apr 2016 23:03:57 -0700 (PDT) X-Gm-Message-State: AOPr4FV956JuxN2vjcP7+7hYsUunjPzFqxKjlzp6RZSWfh3fWexCKJ8jeDZHcYQSMIh2CR4YRdrO5WXAXOPJNg== MIME-Version: 1.0 X-Received: by 10.194.189.38 with SMTP id gf6mr11878090wjc.72.1461218635930; Wed, 20 Apr 2016 23:03:55 -0700 (PDT) Received: by 10.194.74.227 with HTTP; Wed, 20 Apr 2016 23:03:55 -0700 (PDT) Date: Thu, 21 Apr 2016 11:33:55 +0530 X-Gmail-Original-Message-ID: Message-ID: From: Mohammed Sadik Content-Type: text/plain; charset=UTF-8 X-Authenticated_sender: sadiq@sadiqpk.org X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - md-77.webhostbox.net X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - sadiqpk.org X-Get-Message-Sender-Via: md-77.webhostbox.net: authenticated_id: sadiq@sadiqpk.org X-Authenticated-Sender: md-77.webhostbox.net: sadiq@sadiqpk.org X-Source: X-Source-Args: X-Source-Dir: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) Enabling show-trailing-whitespace and navigating through buffer uses too much CPU. An increase of about 4-6% of CPU on my 2.4 GHz Quad-core system. How to reproduce: 1. Open a large source code file (I opened cc-engine.el from Emacs source). 2. Enable show-trailing-whitespace (setq show-trailing-whitespace t) 3. Press and hold the arrow keys to navigate. See the processor usage (use top/htop or similar program). 4. Now disable show-trailing-whitespace (setq show-trailing-whitespace nil) 5. Repeat 3 This also happens when pressing any other key (eg:while typing). Also this creates minor glitches in displaying text on buffer (sudden disappearance and appearence of some text) when CPU is already enough busy. In GNU Emacs 25.0.92.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.18.9) of 2016-04-20 built on fedora.localdomain Windowing system distributor 'Fedora Project', version 11.0.11800000 Configured features: XPM JPEG TIFF GIF PNG SOUND DBUS GSETTINGS NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 Important settings: value of $LC_MONETARY: en_IN.UTF-8 value of $LC_NUMERIC: en_IN.UTF-8 value of $LC_TIME: en_IN.UTF-8 value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: Emacs-Lisp Minor modes in effect: tooltip-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. t Mark set [2 times] nil Making completion list... Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message dired format-spec rfc822 mml mml-sec epg epg-config gnus-util mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util help-fns help-mode easymenu cl-loaddefs pcase cl-lib mail-prsvr mail-utils time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese charscript case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote dbusbind inotify dynamic-setting system-font-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 89437 9618) (symbols 48 19612 0) (miscs 40 83 185) (strings 32 14290 4341) (string-bytes 1 410796) (vectors 16 11670) (vector-slots 8 421100 7008) (floats 8 166 119) (intervals 56 962 0) (buffers 976 13) (heap 1024 35720 1005)) From unknown Fri Jun 20 20:04:48 2025 X-Loop: help-debbugs@gnu.org Subject: bug#23327: 25.0.92; show-trailing-whitespace uses too much cpu Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 21 Apr 2016 14:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23327 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Mohammed Sadik Cc: 23327@debbugs.gnu.org Reply-To: Eli Zaretskii Received: via spool by 23327-submit@debbugs.gnu.org id=B23327.146124818411529 (code B ref 23327); Thu, 21 Apr 2016 14:17:01 +0000 Received: (at 23327) by debbugs.gnu.org; 21 Apr 2016 14:16:24 +0000 Received: from localhost ([127.0.0.1]:42447 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1atFP6-0002zt-IN for submit@debbugs.gnu.org; Thu, 21 Apr 2016 10:16:24 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34844) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1atFP4-0002zd-GB for 23327@debbugs.gnu.org; Thu, 21 Apr 2016 10:16:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1atFOw-00020z-2K for 23327@debbugs.gnu.org; Thu, 21 Apr 2016 10:16:17 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:38345) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1atFOv-00020u-Uz; Thu, 21 Apr 2016 10:16:13 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4740 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1atFOv-0006wl-8g; Thu, 21 Apr 2016 10:16:13 -0400 Date: Thu, 21 Apr 2016 17:16:08 +0300 Message-Id: <837ffr6o9j.fsf@gnu.org> From: Eli Zaretskii In-reply-to: (message from Mohammed Sadik on Thu, 21 Apr 2016 11:33:55 +0530) References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -6.0 (------) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) > Date: Thu, 21 Apr 2016 11:33:55 +0530 > From: Mohammed Sadik > > Enabling show-trailing-whitespace and navigating through buffer uses too > much CPU. An increase of about 4-6% of CPU on my 2.4 GHz Quad-core > system. > > How to reproduce: > > 1. Open a large source code file (I opened cc-engine.el from Emacs source). > 2. Enable show-trailing-whitespace (setq show-trailing-whitespace t) > 3. Press and hold the arrow keys to navigate. See the processor usage > (use top/htop or similar program). > 4. Now disable show-trailing-whitespace (setq show-trailing-whitespace > nil) > 5. Repeat 3 > > This also happens when pressing any other key (eg:while typing). The Emacs display engine employs several aggressive optimizations for simple operations like cursor motion and inserting a single character. When you turn on show-trailing-whitespace, most of these optimizations are disabled, so it's very small wonder that redisplay becomes more expensive. The reason that these optimizations are disable is this feature of show-trailing-whitespace: This feature does not apply when point is at the end of the line containing the whitespace. Strictly speaking, that is trailing whitespace nonetheless, but displaying it specially in that case looks ugly while you are typing in new text. In this special case, the location of point is enough to show you that the spaces are present. Because of this, when you move the cursor, the display engine cannot assume that the display remains unchanged, because it needs to see if the cursor happens to be after a stretch of trailing whitespace, in which case, that whole stretch of whitespace needs to be redrawn as well. For the same reason, other optimizations, like those which reuse portions of the previously displayed window, are abandoned. I've looked at the optimizations we disable in this case, and I cannot see anything wrong in those decisions, given the way this feature works. We could try adding an optional feature which doesn't turn off the special display of trailing whitespace when the cursor is at the end of a line that ends in whitespace, that might allow us to re-enable these optimizations. Would users like that? Other than that, I don't see how this could be helped, except by some thorough redesign of how this feature works. I don't immediately see how to do that, but maybe someone else does, and is motivated to work on this. > Also this creates minor glitches in displaying text on buffer > (sudden disappearance and appearence of some text) when CPU is already > enough busy. If your CPU is very busy, then adding a few percents to it might indeed produce such jerky redisplay, I think. From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 21 11:34:45 2016 Received: (at control) by debbugs.gnu.org; 21 Apr 2016 15:34:45 +0000 Received: from localhost ([127.0.0.1]:42480 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1atGcv-00051D-9E for submit@debbugs.gnu.org; Thu, 21 Apr 2016 11:34:45 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56904) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1atGct-00050y-9J for control@debbugs.gnu.org; Thu, 21 Apr 2016 11:34:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1atGcn-0007lw-JF for control@debbugs.gnu.org; Thu, 21 Apr 2016 11:34:38 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:39683) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1atGcn-0007lc-DV for control@debbugs.gnu.org; Thu, 21 Apr 2016 11:34:37 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1atGcn-00078d-2o for control@debbugs.gnu.org; Thu, 21 Apr 2016 11:34:37 -0400 Subject: control message for bug 23327 To: X-Mailer: mail (GNU Mailutils 2.99.98) Message-Id: From: Glenn Morris Date: Thu, 21 Apr 2016 11:34:37 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -6.0 (------) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) severity 23327 minor tag 23327 wontfix From debbugs-submit-bounces@debbugs.gnu.org Sun Jul 28 16:03:01 2019 Received: (at control) by debbugs.gnu.org; 28 Jul 2019 20:03:01 +0000 Received: from localhost ([127.0.0.1]:47208 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hrpNk-00006I-HA for submit@debbugs.gnu.org; Sun, 28 Jul 2019 16:03:00 -0400 Received: from quimby.gnus.org ([80.91.231.51]:32788) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hrpNi-000068-Qk for control@debbugs.gnu.org; Sun, 28 Jul 2019 16:02:59 -0400 Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=marnie) by quimby.gnus.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hrpNf-0007Hn-5j for control@debbugs.gnu.org; Sun, 28 Jul 2019 22:02:57 +0200 Date: Sun, 28 Jul 2019 22:02:54 +0200 Message-Id: <87imrm9bbl.fsf@mouse.gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #23327 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: close 23327 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) close 23327 quit