From debbugs-submit-bounces@debbugs.gnu.org Thu Nov 12 21:51:47 2020 Received: (at submit) by debbugs.gnu.org; 13 Nov 2020 02:51:47 +0000 Received: from localhost ([127.0.0.1]:46205 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdPBi-0001XP-St for submit@debbugs.gnu.org; Thu, 12 Nov 2020 21:51:47 -0500 Received: from lists.gnu.org ([209.51.188.17]:40372) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdPBe-0001XF-VA for submit@debbugs.gnu.org; Thu, 12 Nov 2020 21:51:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60032) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kdPBe-00006X-Mq for bug-gnu-emacs@gnu.org; Thu, 12 Nov 2020 21:51:42 -0500 Received: from outbound-smtp35.blacknight.com ([46.22.139.218]:60685) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kdPBb-0006EQ-4x for bug-gnu-emacs@gnu.org; Thu, 12 Nov 2020 21:51:42 -0500 Received: from mail.blacknight.com (pemlinmail05.blacknight.ie [81.17.254.26]) by outbound-smtp35.blacknight.com (Postfix) with ESMTPS id C7F40242A for ; Fri, 13 Nov 2020 02:51:34 +0000 (GMT) Received: (qmail 4724 invoked from network); 13 Nov 2020 02:51:34 -0000 Received: from unknown (HELO rt-inspiron-3480) (rt@robertthorpeconsulting.com@[51.37.30.105]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 13 Nov 2020 02:51:34 -0000 From: Robert Thorpe To: bug-gnu-emacs@gnu.org Subject: 27.1; Keyboard Macro Performance Problem Date: Fri, 13 Nov 2020 02:51:12 +0000 Message-ID: <87d00irmu7.fsf@robertthorpeconsulting.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=46.22.139.218; envelope-from=rt@robertthorpeconsulting.com; helo=outbound-smtp35.blacknight.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/12 21:51:35 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit 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: -2.3 (--) This bug report comes from a discussion on Emacs reddit. Start with a blank buffer and create about ~300 lines of the string: ffffffffffffffffffff (pppppppppppppppppppp); This will be turned into: 'ffffffffffffffffffff': That can be done using the following keyboard macro: M-m ' M-f ' : C-k C-n You can apply that to every line in the buffer using C-u 300 f4. Now here's the strange bit. In a fundamental-mode buffer this is extremely fast, nearly instantaneous. But, in a python-mode buffer it takes 20 to 30 seconds. If the mode is c-mode then it is also much slower than fundamental-mode. It will also exceed the variable binding depth in some cases. Oddly it is faster if you use forward-line instead of C-n. Here is the original thread: https://www.reddit.com/r/emacs/comments/joeno5/anyway_to_speed_up_macros_in= _emacs/ I understand it might not be worth fixing if it's a corner case. BR, Robert Thorpe In GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.22, cair= o version 1.17.3) of 2020-08-28 built on juergen Windowing system distributor 'The X.Org Foundation', version 11.0.12009000 System Description: Arch Linux Recent messages: Keyboard macro defined Commands: d, s, x, u; f, o, 1, 2, m, v; ~, %; q to quit; ? for help. Mark set [2 times] Saved text until "fffffffffffff (pppppppppppppppppppp); " Mark set [2 times] Defining kbd macro... You can run the command =E2=80=98forward-line=E2=80=99 with M-x fo-lin RET Keyboard macro defined Can=E2=80=99t guess python-indent-offset, using defaults: 4 Configured using: 'configure --prefix=3D/usr --sysconfdir=3D/etc --libexecdir=3D/usr/lib --localstatedir=3D/var --with-x-toolkit=3Dgtk3 --with-xft --with-wide-int --with-modules --with-cairo --with-harfbuzz 'CFLAGS=3D-march=3Dx86-64 -mtune=3Dgeneric -O2 -pipe -fno-plt' CPPFLAGS=3D-D_FORTIFY_SOURCE=3D2 LDFLAGS=3D-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now' Configured features: XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY INOTIFY ACL GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD JSON PDUMPER LCMS2 GMP Important settings: value of $LANG: en_GB.UTF-8 locale-coding-system: utf-8-unix Major mode: Python Minor modes in effect: shell-dirtrack-mode: t dynamic-completion-mode: t tooltip-mode: t global-eldoc-mode: t eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t column-number-mode: t line-number-mode: t global-visual-line-mode: t visual-line-mode: t transient-mark-mode: t Load-path shadows: None found. Features: (shadow mail-extr emacsbug sendmail eieio-opt cl-extra speedbar sb-image ezimage dframe find-func thingatpt help-fns radix-tree help-mode python tramp-sh tramp tramp-loaddefs trampver tramp-integration files-x tramp-compat shell pcomplete parse-time iso8601 ls-lisp comint ring ansi-color cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs dired-aux autorevert filenotify calc-alg calc-ext calc-menu calc calc-loaddefs calc-macs view sort disp-table tetris gamegrid rmailsum misearch multi-isearch noutline outline easy-mmode shr-color color shr url-cookie url-domsuf url-util url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs json map url-vars svg xml dom browse-url qp rmailout rmailmm message rmc puny dired-x dired dired-loaddefs format-spec rfc822 mml mml-sec password-cache epa derived epg epg-config gnus-util time-date subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies mm-encode mailabbrev gmm-utils mailheader mail-parse rfc2231 rmail rmail-loaddefs rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils bookmark easymenu text-property-search pp server completion avoid misc edmacro kmacro cl-loaddefs cl-lib tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame minibuffer 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 composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray 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 threads dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 212016 51202) (symbols 48 17470 1) (strings 32 53646 2929) (string-bytes 1 1713027) (vectors 16 29359) (vector-slots 8 1024997 53850) (floats 8 262 286) (intervals 56 13457 0) (buffers 1000 44)) From debbugs-submit-bounces@debbugs.gnu.org Fri Nov 13 03:56:04 2020 Received: (at 44610) by debbugs.gnu.org; 13 Nov 2020 08:56:04 +0000 Received: from localhost ([127.0.0.1]:46624 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdUsF-0006T9-UT for submit@debbugs.gnu.org; Fri, 13 Nov 2020 03:56:04 -0500 Received: from stw1.rcdrun.com ([217.170.207.13]:47283) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdUsC-0006Sa-Ea for 44610@debbugs.gnu.org; Fri, 13 Nov 2020 03:56:02 -0500 Received: from [10.127.43.172] ([::ffff:41.202.241.56]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_CHACHA20_POLY1305) by stw1.rcdrun.com with ESMTPSA id 000000000001E007.000000005FAE4A18.00006C8A; Fri, 13 Nov 2020 01:55:52 -0700 Date: Fri, 13 Nov 2020 08:55:45 +0000 In-Reply-To: <87d00irmu7.fsf@robertthorpeconsulting.com> References: <87d00irmu7.fsf@robertthorpeconsulting.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: bug#44610: 27.1; Keyboard Macro Performance Problem To: Robert Thorpe , 44610@debbugs.gnu.org From: Jean Louis Message-ID: <1A5505ED-F004-4798-8A5E-31599655045E@gnu.support> X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 44610 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 (-) Modes are programs and their checks slow down the macro execution=2E If it = happens to me I will simple temporarily switch the mode to fundamental=2E Maybe there is or could be an option that macro executes only in fundament= al mode and then automatically turns on whatever other mode was there=2E Jean From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 14 09:26:51 2020 Received: (at 44610) by debbugs.gnu.org; 14 Nov 2020 14:26:51 +0000 Received: from localhost ([127.0.0.1]:50191 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdwVv-000643-0Y for submit@debbugs.gnu.org; Sat, 14 Nov 2020 09:26:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40882) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdwVt-00063q-3k for 44610@debbugs.gnu.org; Sat, 14 Nov 2020 09:26:49 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:55117) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kdwVn-000652-A2; Sat, 14 Nov 2020 09:26:43 -0500 Received: from [176.228.60.248] (port=1869 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kdwVl-00006Z-Tr; Sat, 14 Nov 2020 09:26:42 -0500 Date: Sat, 14 Nov 2020 16:26:30 +0200 Message-Id: <83pn4gui95.fsf@gnu.org> From: Eli Zaretskii To: Robert Thorpe In-Reply-To: <87d00irmu7.fsf@robertthorpeconsulting.com> (message from Robert Thorpe on Fri, 13 Nov 2020 02:51:12 +0000) Subject: Re: bug#44610: 27.1; Keyboard Macro Performance Problem References: <87d00irmu7.fsf@robertthorpeconsulting.com> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 44610 Cc: 44610@debbugs.gnu.org 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: -3.3 (---) > From: Robert Thorpe > Date: Fri, 13 Nov 2020 02:51:12 +0000 > > > This bug report comes from a discussion on Emacs reddit. > > Start with a blank buffer and create about ~300 lines of the string: > > ffffffffffffffffffff (pppppppppppppppppppp); > > This will be turned into: > > 'ffffffffffffffffffff': > > That can be done using the following keyboard macro: M-m ' M-f ' : C-k > C-n > > You can apply that to every line in the buffer using C-u 300 f4. > > Now here's the strange bit. In a fundamental-mode buffer this is > extremely fast, nearly instantaneous. But, in a python-mode buffer it > takes 20 to 30 seconds. If the mode is c-mode then it is also much > slower than fundamental-mode. It will also exceed the variable binding > depth in some cases. Oddly it is faster if you use forward-line instead > of C-n. I suggest to produce and present a profile of this. Invoke this macro after "M-x profiler-start RET RET", then "M-x profiler-report RET", expand the profile fully by "C-u RET" on the top line, and post the result here. That should give some clues. From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 14 11:04:11 2020 Received: (at 44610) by debbugs.gnu.org; 14 Nov 2020 16:04:11 +0000 Received: from localhost ([127.0.0.1]:51659 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdy26-0004dG-UH for submit@debbugs.gnu.org; Sat, 14 Nov 2020 11:04:11 -0500 Received: from static.rcdrun.com ([95.85.24.50]:51747) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdy25-0004d7-J9 for 44610@debbugs.gnu.org; Sat, 14 Nov 2020 11:04:10 -0500 Received: from localhost ([::ffff:41.202.241.56]) (AUTH: PLAIN admin, TLS: TLS1.2,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by static.rcdrun.com with ESMTPSA id 00000000002C0004.000000005FAFFFF4.00000173; Sat, 14 Nov 2020 16:04:01 +0000 Date: Sat, 14 Nov 2020 19:03:11 +0300 From: Jean Louis To: Eli Zaretskii Subject: Re: bug#44610: 27.1; Keyboard Macro Performance Problem Message-ID: References: <87d00irmu7.fsf@robertthorpeconsulting.com> <83pn4gui95.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: <83pn4gui95.fsf@gnu.org> User-Agent: Mutt/2.0 (3d08634) (2020-11-07) X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 44610 Cc: Robert Thorpe , 44610@debbugs.gnu.org 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 (-) * Eli Zaretskii [2020-11-14 17:27]: > > From: Robert Thorpe > > Date: Fri, 13 Nov 2020 02:51:12 +0000 > > > > > > This bug report comes from a discussion on Emacs reddit. > > > > Start with a blank buffer and create about ~300 lines of the string: > > > > ffffffffffffffffffff (pppppppppppppppppppp); > > > > This will be turned into: > > > > 'ffffffffffffffffffff': > > > > That can be done using the following keyboard macro: M-m ' M-f ' : C-k > > C-n > > > > You can apply that to every line in the buffer using C-u 300 f4. > > > > Now here's the strange bit. In a fundamental-mode buffer this is > > extremely fast, nearly instantaneous. But, in a python-mode buffer it > > takes 20 to 30 seconds. If the mode is c-mode then it is also much > > slower than fundamental-mode. It will also exceed the variable binding > > depth in some cases. Oddly it is faster if you use forward-line instead > > of C-n. > > I suggest to produce and present a profile of this. Invoke this macro > after "M-x profiler-start RET RET", then "M-x profiler-report RET", > expand the profile fully by "C-u RET" on the top line, and post the > result here. That should give some clues. That is great advise to learn from. Macro took just about less than 2 seconds on my notebook Lenovo Thinkpad T410. I am not the initial reporter. I have tested it in python-mode in plain emacs -Q with the latest development version: - command-execute 20,601,881 99% - call-interactively 20,601,881 99% - funcall-interactively 19,934,160 96% - kmacro-end-or-call-macro 15,337,767 74% - kmacro-call-macro 15,337,767 74% - call-last-kbd-macro 15,242,727 73% - command-execute 15,102,838 73% - call-interactively 15,021,006 72% - funcall-interactively 14,985,294 72% - next-line 13,970,433 67% - line-move 13,968,321 67% - line-move-visual 12,842,225 62% - vertical-motion 9,925,619 48% - jit-lock-function 9,925,619 48% - jit-lock-fontify-now 9,925,619 48% - jit-lock--run-functions 7,165,300 34% - run-hook-wrapped 7,157,012 34% - # 7,157,012 34% - font-lock-fontify-region 7,157,012 34% - font-lock-default-fontify-region 7,153,844 34% - font-lock-fontify-keywords-region 5,169,903 25% # 369,664 1% # 308,861 1% - python--font-lock-f-strings 306,448 1% syntax-ppss 11,536 0% - font-lock-fontify-syntactically-region 1,975,653 9% - python-font-lock-syntactic-face-function 1,889,981 9% - python-info-docstring-p 1,878,263 9% - python-nav-backward-sexp 1,150,110 5% - python-nav-forward-sexp 1,144,830 5% - python-nav--forward-sexp 1,144,830 5% - python-info-beginning-of-block-p 519,389 2% - python-info-statement-starts-block-p 407,940 1% - python-nav-beginning-of-statement 100,032 0% - syntax-ppss 46,400 0% # 4,320 0% - python-info-line-ends-backslash-p 45,344 0% - syntax-ppss 45,344 0% # 4,320 0% - python-info-beginning-of-statement-p 103,161 0% - python-nav-beginning-of-statement 103,161 0% - syntax-ppss 54,825 0% make-byte-code 4,377 0% - python-info-line-ends-backslash-p 35,904 0% syntax-ppss 35,904 0% - python-info-current-line-empty-p 307,473 1% beginning-of-line 4,377 0% - python-info-end-of-block-p 130,384 0% - python-info-end-of-statement-p 130,384 0% - python-nav-end-of-statement 130,384 0% syntax-ppss 91,472 0% - python-info-line-ends-backslash-p 34,768 0% syntax-ppss 34,768 0% - python-info-beginning-of-statement-p 116,336 0% - python-nav-beginning-of-statement 116,336 0% - python-info-line-ends-backslash-p 55,648 0% syntax-ppss 55,648 0% syntax-ppss 44,112 0% - python-nav-beginning-of-statement 53,456 0% - python-info-line-ends-backslash-p 21,040 0% syntax-ppss 21,040 0% syntax-ppss 19,984 0% - python-syntax-context-type 9,504 0% syntax-ppss 9,504 0% - python-info-assignment-statement-p 314,499 1% - python-nav-beginning-of-statement 19,587 0% - python-info-line-ends-backslash-p 7,392 0% syntax-ppss 7,392 0% syntax-ppss 6,336 0% - python-nav-beginning-of-statement 36,902 0% - syntax-ppss 22,595 0% # 5,859 0% - python-info-line-ends-backslash-p 8,448 0% syntax-ppss 8,448 0% syntax-ppss 27,216 0% replace-regexp-in-string 2,112 0% font-lock-unfontify-region 4,144 0% - run-with-timer 2,730,692 13% - apply 2,730,692 13% - run-at-time 2,729,636 13% - timer-activate 2,717,252 13% - timer--activate 2,716,196 13% - timer--time-less-p 2,716,196 13% timer--time 36,054 0% time-less-p 24,036 0% - timer-set-time 12,384 0% timer--time-setter 12,384 0% make-byte-code 5,859 0% - posn-at-point 2,878,318 13% file-remote-p 2,360,868 11% - jit-lock-function 340,326 1% - jit-lock-fontify-now 340,326 1% - jit-lock--run-functions 335,086 1% - run-hook-wrapped 330,942 1% - # 330,942 1% - font-lock-fontify-region 330,942 1% - font-lock-default-fontify-region 329,886 1% - font-lock-fontify-keywords-region 202,469 0% # 15,872 0% - python--font-lock-f-strings 15,456 0% syntax-ppss 3,168 0% # 12,288 0% - font-lock-fontify-syntactically-region 123,273 0% - python-font-lock-syntactic-face-function 99,145 0% - python-info-docstring-p 99,145 0% - python-nav-backward-sexp 49,329 0% - python-nav-forward-sexp 48,273 0% - python-nav--forward-sexp 48,273 0% - python-info-beginning-of-block-p 15,105 0% python-info-statement-starts-block-p 15,105 0% - python-nav-beginning-of-statement 12,512 0% syntax-ppss 8,368 0% python-info-current-line-empty-p 12,288 0% - python-syntax-context-type 4,224 0% syntax-ppss 4,224 0% - python-info-beginning-of-statement-p 4,144 0% python-nav-beginning-of-statement 4,144 0% - python-info-assignment-statement-p 20,784 0% - python-nav-beginning-of-statement 8,368 0% - python-info-line-ends-backslash-p 3,168 0% syntax-ppss 3,168 0% syntax-ppss 1,056 0% - python-nav-beginning-of-statement 8,368 0% syntax-ppss 2,112 0% - python-info-line-ends-backslash-p 2,112 0% syntax-ppss 2,112 0% syntax-ppss 8,368 0% replace-regexp-in-string 4,144 0% font-lock-unfontify-region 4,144 0% - eval 144,979 0% if 132,784 0% unless 6,336 0% - default-line-height 1,089,216 5% default-font-height 1,089,216 5% - window-inside-pixel-edges 21,120 0% - window-edges 15,840 0% window-current-scroll-bars 11,616 0% - kill-line 498,749 2% - kill-region 498,749 2% - kill-new 424,312 2% menu-bar-update-yank-menu 340,984 1% - gui-select-text 74,880 0% - gui-set-selection 74,880 0% - gui-backend-set-selection 73,824 0% - apply 73,824 0% # 73,824 0% - filter-buffer-substring 74,437 0% - buffer-substring--filter 68,101 0% - # 68,101 0% - apply 68,101 0% - # 63,957 0% - delete-and-extract-region 21,901 0% - jit-lock-after-change 9,666 0% - run-hook-with-args 4,833 0% - font-lock-extend-jit-lock-region-after-change 4,833 0% get-text-property 4,833 0% - self-insert-command 485,032 2% - python-indent-post-self-insert-function 421,304 2% - syntax-ppss 421,304 2% - syntax-propertize 325,688 1% # 311,064 1% - run-hook-wrapped 1,056 0% # 1,056 0% - electric-indent-post-self-insert-function 22,016 0% - syntax-ppss 22,016 0% - syntax-propertize 3,168 0% - run-hook-wrapped 1,056 0% # 1,056 0% - jit-lock-after-change 12,432 0% run-hook-with-args 4,144 0% - undo-auto--undoable-change 32 0% - undo-auto--boundary-ensure-timer 32 0% - run-at-time 32 0% - timer-set-time 32 0% timer--time-setter 32 0% - jit-lock--antiblink-post-command 113,809 0% - syntax-ppss 79,729 0% vconcat 4,833 0% syntax-propertize 2,112 0% - run-with-idle-timer 29,936 0% - timer-activate-when-idle 25,712 0% - timer--activate 25,712 0% timer--time-less-p 25,712 0% - timer-set-idle-time 4,224 0% timer--time-setter 4,224 0% - undo-auto--add-boundary 4,224 0% undo-auto--boundaries 4,224 0% - execute-extended-command 4,593,217 22% - command-execute 3,494,291 16% - call-interactively 3,494,291 16% - funcall-interactively 3,494,275 16% - profiler-report 3,491,303 16% profiler-memory-running-p 5,863 0% - profiler-start 2,972 0% message 2,341 0% - sit-for 745,896 3% - redisplay 744,768 3% - redisplay_internal (C function) 277,761 1% - tool-bar-make-keymap 271,923 1% - tool-bar-make-keymap-1 271,923 1% - mapcar 271,923 1% - # 271,923 1% - eval 17,416 0% - find-image 17,416 0% image-search-load-path 17,416 0% - find-image 1,048 0% image-search-load-path 1,048 0% kill-this-buffer-enabled-p 1,024 0% - menu-bar-update-buffers 672 0% menu-bar-update-buffers-1 672 0% - substitute-command-keys 21 0% generate-new-buffer 21 0% - read-event 16 0% - command-execute 16 0% call-interactively 16 0% - execute-extended-command--shorter 195,259 0% - completion-try-completion 187,931 0% - completion--nth-completion 186,883 0% - completion--some 186,883 0% - # 185,827 0% - completion-pcm-try-completion 184,779 0% - completion-pcm--merge-try 148,675 0% - completion-pcm--merge-completions 23,355 0% string-match 2,099 0% completion-pcm--pattern->regex 2,096 0% completion-pcm--pattern->string 1,048 0% - completion-pcm--find-all-completions 35,048 0% - completion-pcm--all-completions 20,568 0% completion-pcm--pattern->regex 1,048 0% completion-pcm--optimize-pattern 1,056 0% completion-pcm--string->pattern 1,024 0% - execute-extended-command--shorter-1 7,328 0% - execute-extended-command--shorter-1 5,232 0% - execute-extended-command--shorter-1 2,096 0% - execute-extended-command--shorter-1 2,096 0% mapcar 1,048 0% - execute-extended-command--shorter-1 1,048 0% - execute-extended-command--shorter-1 1,048 0% mapcar 1,048 0% mapcar 1,048 0% commandp 5,863 0% # 42 0% - handle-focus-in 2,112 0% - # 2,112 0% - apply 2,112 0% - blink-cursor--rescan-frames 2,112 0% - blink-cursor-check 2,112 0% - blink-cursor--should-blink 2,112 0% frame-focus-state 2,112 0% - digit-argument 1,064 0% - universal-argument--mode 1,064 0% set-transient-map 1,064 0% - byte-code 667,721 3% - read-extended-command 667,721 3% - completing-read 667,721 3% - completing-read-default 667,721 3% - read-from-minibuffer 663,459 3% - redisplay_internal (C function) 208,291 1% - tool-bar-make-keymap 206,571 1% - tool-bar-make-keymap-1 206,571 1% - mapcar 206,571 1% - # 206,571 1% - eval 1,048 0% - find-image 1,048 0% image-search-load-path 1,048 0% - find-image 1,048 0% image-search-load-path 1,048 0% - menu-bar-update-buffers 672 0% menu-bar-update-buffers-1 672 0% - command-execute 1,320 0% - call-interactively 1,320 0% - funcall-interactively 1,080 0% - self-insert-command 1,080 0% # 1,048 0% - undo-auto--undoable-change 32 0% - undo-auto--boundary-ensure-timer 32 0% - run-at-time 32 0% - timer-set-time 32 0% timer--time-setter 32 0% + redisplay_internal (C function) 33,424 0% + internal-echo-keystrokes-prefix 15,490 0% + timer-event-handler 2,662 0% ... 0 0% From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 14 11:25:10 2020 Received: (at 44610) by debbugs.gnu.org; 14 Nov 2020 16:25:10 +0000 Received: from localhost ([127.0.0.1]:51737 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdyMQ-0007Iu-0B for submit@debbugs.gnu.org; Sat, 14 Nov 2020 11:25:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42336) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdyMN-0007IV-D3 for 44610@debbugs.gnu.org; Sat, 14 Nov 2020 11:25:08 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:57014) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kdyMH-0007Lp-G6; Sat, 14 Nov 2020 11:25:01 -0500 Received: from [176.228.60.248] (port=1326 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kdyMG-0003Xz-Rt; Sat, 14 Nov 2020 11:25:01 -0500 Date: Sat, 14 Nov 2020 18:24:48 +0200 Message-Id: <83a6vjvrcf.fsf@gnu.org> From: Eli Zaretskii To: Jean Louis In-Reply-To: (message from Jean Louis on Sat, 14 Nov 2020 19:03:11 +0300) Subject: Re: bug#44610: 27.1; Keyboard Macro Performance Problem References: <87d00irmu7.fsf@robertthorpeconsulting.com> <83pn4gui95.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 44610 Cc: rt@robertthorpeconsulting.com, 44610@debbugs.gnu.org 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: -3.3 (---) > Date: Sat, 14 Nov 2020 19:03:11 +0300 > From: Jean Louis > Cc: Robert Thorpe , > 44610@debbugs.gnu.org > > I am not the initial reporter. I have tested it in python-mode in > plain emacs -Q with the latest development version: > > - command-execute 20,601,881 99% > - call-interactively 20,601,881 99% > - funcall-interactively 19,934,160 96% > - kmacro-end-or-call-macro 15,337,767 74% > - kmacro-call-macro 15,337,767 74% > - call-last-kbd-macro 15,242,727 73% > - command-execute 15,102,838 73% > - call-interactively 15,021,006 72% > - funcall-interactively 14,985,294 72% > - next-line 13,970,433 67% > - line-move 13,968,321 67% > - line-move-visual 12,842,225 62% > - vertical-motion 9,925,619 48% > - jit-lock-function 9,925,619 48% > - jit-lock-fontify-now 9,925,619 48% > - jit-lock--run-functions 7,165,300 34% > - run-hook-wrapped 7,157,012 34% > - # 7,157,012 34% > - font-lock-fontify-region 7,157,012 34% > - font-lock-default-fontify-region 7,153,844 34% > - font-lock-fontify-keywords-region 5,169,903 25% Thanks, this seems to indicate that the mode's fontifications take the lion's share of the time. Which explains why Fundamental mode doesn't suffer from this problem. From debbugs-submit-bounces@debbugs.gnu.org Sat Nov 14 11:50:53 2020 Received: (at 44610) by debbugs.gnu.org; 14 Nov 2020 16:50:53 +0000 Received: from localhost ([127.0.0.1]:51829 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdylJ-0001gu-34 for submit@debbugs.gnu.org; Sat, 14 Nov 2020 11:50:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47714) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kdylH-0001gi-Ra for 44610@debbugs.gnu.org; Sat, 14 Nov 2020 11:50:52 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:57423) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kdylB-0008Qg-SC; Sat, 14 Nov 2020 11:50:45 -0500 Received: from [176.228.60.248] (port=2912 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kdylB-0007ik-86; Sat, 14 Nov 2020 11:50:45 -0500 Date: Sat, 14 Nov 2020 18:50:33 +0200 Message-Id: <838sb3vq5i.fsf@gnu.org> From: Eli Zaretskii To: Jean Louis In-Reply-To: (message from Jean Louis on Sat, 14 Nov 2020 19:03:11 +0300) Subject: Re: bug#44610: 27.1; Keyboard Macro Performance Problem References: <87d00irmu7.fsf@robertthorpeconsulting.com> <83pn4gui95.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 44610 Cc: rt@robertthorpeconsulting.com, 44610@debbugs.gnu.org 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: -3.3 (---) > Date: Sat, 14 Nov 2020 19:03:11 +0300 > From: Jean Louis > Cc: Robert Thorpe , > 44610@debbugs.gnu.org > > I am not the initial reporter. I have tested it in python-mode in > plain emacs -Q with the latest development version: > > - command-execute 20,601,881 99% > - call-interactively 20,601,881 99% Btw, did you activate the cpu profiler or the memory profiler? It looks like it was the latter, in which case the percents might be skewed, as the frequency of probing the program counter is not constant. From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 15 18:45:07 2020 Received: (at 44610) by debbugs.gnu.org; 15 Nov 2020 23:45:07 +0000 Received: from localhost ([127.0.0.1]:54567 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1keRhi-0003VV-A4 for submit@debbugs.gnu.org; Sun, 15 Nov 2020 18:45:07 -0500 Received: from outbound-smtp44.blacknight.com ([46.22.136.52]:47775) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1keRhf-0003Ug-Eq for 44610@debbugs.gnu.org; Sun, 15 Nov 2020 18:45:05 -0500 Received: from mail.blacknight.com (pemlinmail02.blacknight.ie [81.17.254.11]) by outbound-smtp44.blacknight.com (Postfix) with ESMTPS id 5BD3CF84D2 for <44610@debbugs.gnu.org>; Sun, 15 Nov 2020 23:44:57 +0000 (GMT) Received: (qmail 10509 invoked from network); 15 Nov 2020 23:44:57 -0000 Received: from unknown (HELO rt-inspiron-3480) (rt@robertthorpeconsulting.com@[51.37.30.105]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 15 Nov 2020 23:44:57 -0000 From: Robert Thorpe To: Eli Zaretskii , Jean Louis Subject: Re: bug#44610: 27.1; Keyboard Macro Performance Problem In-Reply-To: <83pn4gui95.fsf@gnu.org> (message from Eli Zaretskii on Sat, 14 Nov 2020 16:26:30 +0200) Date: Sun, 15 Nov 2020 23:44:32 +0000 Message-ID: <87zh3i6v8f.fsf@robertthorpeconsulting.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 44610 Cc: 44610@debbugs.gnu.org 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 (-) Eli Zaretskii writes: >> From: Robert Thorpe >> Date: Fri, 13 Nov 2020 02:51:12 +0000 >> >> >> This bug report comes from a discussion on Emacs reddit. >> >> Start with a blank buffer and create about ~300 lines of the string: >> >> ffffffffffffffffffff (pppppppppppppppppppp); >> >> This will be turned into: >> >> 'ffffffffffffffffffff': >> >> That can be done using the following keyboard macro: M-m ' M-f ' : C-k >> C-n >> >> You can apply that to every line in the buffer using C-u 300 f4. >> >> Now here's the strange bit. In a fundamental-mode buffer this is >> extremely fast, nearly instantaneous. But, in a python-mode buffer it >> takes 20 to 30 seconds. If the mode is c-mode then it is also much >> slower than fundamental-mode. It will also exceed the variable binding >> depth in some cases. Oddly it is faster if you use forward-line instead >> of C-n. > > I suggest to produce and present a profile of this. Invoke this macro > after "M-x profiler-start RET RET", then "M-x profiler-report RET", > expand the profile fully by "C-u RET" on the top line, and post the > result here. That should give some clues. Here is the report. I did it in Python-mode using Emacs -Q on Emacs 27.1. My machine is a Dell 14-3480. The profile I've got seems to be a bit different to the one Jean Louis got. It is a little faster using Emacs -Q than my own init, but it's still fairly slow. I notice that in my report the GC is taking about 39% of runtime. I'm not sure why it's taking longer than in Jen Louis' report. It's faster if I use forward-line rather than pressing C-n. Also the report looks very different. I've added that at the end. The first report is the one using C-n. - command-execute 3499 60% - call-interactively 3499 60% - funcall-interactively 3480 59% - kmacro-end-or-call-macro 3474 59% - kmacro-call-macro 3474 59% - call-last-kbd-macro 3464 59% - command-execute 3419 58% - call-interactively 3417 58% - funcall-interactively 3417 58% - next-line 3345 57% - line-move 3345 57% - line-move-visual 3339 57% - vertical-motion 3132 53% - jit-lock-function 3132 53% - jit-lock-fontify-now 3131 53% - jit-lock--run-functions 3112 53% - run-hook-wrapped 3112 53% - # 3111 53% - font-lock-fontify-region 3111 53% - font-lock-default-fontify-region 3111 53% - font-lock-fontify-syntactically-region 3082 53% - python-font-lock-syntactic-face-function 3063 52% - python-info-docstring-p 3055 52% - python-nav-backward-sexp 3016 51% - python-nav-forward-sexp 3007 51% - python-nav--forward-sexp 2968 51% - python-info-beginning-of-block-p 2005 34% - python-info-beginning-of-statement-p 1670 28% - python-nav-beginning-of-statement 1644 28% - syntax-ppss 1392 23% # 1 0% - python-info-line-ends-backslash-p 138 2% - syntax-ppss 103 1% # 1 0% back-to-indentation 56 0% - python-info-statement-starts-block-p 314 5% - python-nav-beginning-of-statement 277 4% - python-info-line-ends-backslash-p 112 1% syntax-ppss 76 1% - syntax-ppss 82 1% # 3 0% back-to-indentation 33 0% - python-info-end-of-block-p 385 6% - python-info-end-of-statement-p 370 6% - python-nav-end-of-statement 359 6% - syntax-ppss 185 3% # 2 0% - python-info-line-ends-backslash-p 104 1% - syntax-ppss 87 1% # 2 0% - python-info-beginning-of-statement-p 274 4% - python-nav-beginning-of-statement 252 4% - python-info-line-ends-backslash-p 105 1% - syntax-ppss 76 1% # 1 0% syntax-ppss 72 1% back-to-indentation 44 0% - python-nav-beginning-of-statement 107 1% - syntax-ppss 37 0% # 1 0% - python-info-line-ends-backslash-p 29 0% syntax-ppss 20 0% back-to-indentation 21 0% - python-nav--lisp-forward-sexp 63 1% forward-sexp 58 0% - python-info-current-line-empty-p 45 0% match-string-no-properties 6 0% - python-syntax-context-type 39 0% syntax-ppss 28 0% - python-info-statement-ends-block-p 2 0% - python-nav-end-of-block 1 0% - python-nav-beginning-of-block 1 0% python-info-current-line-empty-p 1 0% - python-nav-end-of-statement 1 0% syntax-ppss 1 0% syntax-after 2 0% syntax-class 1 0% - python-nav-beginning-of-statement 2 0% syntax-ppss 2 0% - python-info-assignment-statement-p 1 0% - python-nav-beginning-of-statement 1 0% python-info-line-ends-backslash-p 1 0% syntax-ppss 18 0% - font-lock-fontify-keywords-region 27 0% # 11 0% # 7 0% - run-with-timer 16 0% - apply 16 0% - run-at-time 15 0% - timer-activate 13 0% - timer--activate 12 0% timer--time-less-p 12 0% timer-relative-time 1 0% - posn-at-point 50 0% - jit-lock-function 40 0% - jit-lock-fontify-now 39 0% - jit-lock--run-functions 38 0% - run-hook-wrapped 38 0% - # 38 0% - font-lock-fontify-region 38 0% - font-lock-default-fontify-region 36 0% - font-lock-fontify-syntactically-region 33 0% - python-font-lock-syntactic-face-function 33 0% - python-info-docstring-p 32 0% - python-nav-backward-sexp 26 0% - python-nav-forward-sexp 26 0% - python-nav--forward-sexp 25 0% - python-syntax-context-type 7 0% syntax-ppss 7 0% - python-info-beginning-of-block-p 6 0% python-info-statement-starts-block-p 4 0% python-info-beginning-of-statement-p 1 0% - python-nav-beginning-of-statement 4 0% syntax-ppss 3 0% python-info-line-ends-backslash-p 1 0% - python-info-beginning-of-statement-p 2 0% python-nav-beginning-of-statement 1 0% - python-nav--lisp-forward-sexp 2 0% forward-sexp 2 0% - python-info-end-of-block-p 1 0% python-info-end-of-statement-p 1 0% python-info-current-line-empty-p 1 0% python-nav-beginning-of-statement 2 0% - python-info-assignment-statement-p 1 0% - python-nav-beginning-of-statement 1 0% - python-info-line-ends-backslash-p 1 0% syntax-ppss 1 0% - font-lock-fontify-keywords-region 3 0% # 2 0% - eval 6 0% if 2 0% mode-line-eol-desc 2 0% file-remote-p 4 0% - window-inside-pixel-edges 1 0% window-edges 1 0% - self-insert-command 51 0% - python-indent-post-self-insert-function 48 0% - syntax-ppss 48 0% - syntax-propertize 6 0% # 3 0% syntax-ppss-flush-cache 1 0% electric-indent-post-self-insert-function 1 0% - jit-lock-after-change 1 0% run-hook-with-args 1 0% - kill-line 14 0% - kill-region 14 0% - kill-new 14 0% - gui-select-text 12 0% - gui-set-selection 12 0% - gui-backend-set-selection 12 0% - apply 11 0% # 11 0% menu-bar-update-yank-menu 1 0% - jit-lock--antiblink-post-command 35 0% - syntax-ppss 29 0% - syntax-propertize 5 0% # 1 0% - run-with-idle-timer 2 0% - timer-set-idle-time 2 0% timer--time-setter 2 0% cancel-timer 1 0% - undo-auto--add-boundary 3 0% undo-auto--boundaries 1 0% - execute-extended-command 6 0% - sit-for 5 0% redisplay 3 0% - command-execute 1 0% - call-interactively 1 0% - funcall-interactively 1 0% profiler-report 1 0% - byte-code 19 0% - read-extended-command 19 0% - completing-read 19 0% - completing-read-default 19 0% - read-from-minibuffer 10 0% - redisplay_internal (C function) 1 0% - tool-bar-make-keymap 1 0% - tool-bar-make-keymap-1 1 0% - mapcar 1 0% - # 1 0% - eval 1 0% - find-image 1 0% image-search-load-path 1 0% + ... 2303 39% + redisplay_internal (C function) 1 0% The following report is from using M-x forward-line instead of C-n: - redisplay_internal (C function) 1237 38% - jit-lock-function 1212 37% - jit-lock-fontify-now 1212 37% - jit-lock--run-functions 1212 37% - run-hook-wrapped 1212 37% - # 1212 37% - font-lock-fontify-region 1212 37% - font-lock-default-fontify-region 1212 37% - font-lock-fontify-syntactically-region 1196 37% - python-font-lock-syntactic-face-function 1191 37% - python-info-docstring-p 1189 36% - python-nav-backward-sexp 1172 36% - python-nav-forward-sexp 1168 36% - python-nav--forward-sexp 1154 35% - python-info-beginning-of-block-p 767 23% - python-info-beginning-of-statement-p 666 20% - python-nav-beginning-of-statement 656 20% syntax-ppss 589 18% - python-info-line-ends-backslash-p 44 1% syntax-ppss 30 0% back-to-indentation 11 0% - python-info-statement-starts-block-p 97 3% - python-nav-beginning-of-statement 84 2% - python-info-line-ends-backslash-p 34 1% syntax-ppss 22 0% syntax-ppss 25 0% back-to-indentation 11 0% - python-info-end-of-block-p 162 5% - python-info-end-of-statement-p 158 4% - python-nav-end-of-statement 154 4% syntax-ppss 80 2% - python-info-line-ends-backslash-p 53 1% syntax-ppss 46 1% - python-info-beginning-of-statement-p 108 3% - python-nav-beginning-of-statement 101 3% - python-info-line-ends-backslash-p 43 1% syntax-ppss 34 1% syntax-ppss 27 0% back-to-indentation 17 0% - python-nav-beginning-of-statement 47 1% - python-info-line-ends-backslash-p 20 0% syntax-ppss 13 0% syntax-ppss 17 0% back-to-indentation 4 0% - python-syntax-context-type 20 0% syntax-ppss 18 0% - python-nav--lisp-forward-sexp 16 0% forward-sexp 15 0% - python-info-current-line-empty-p 15 0% match-string-no-properties 2 0% - python-info-statement-ends-block-p 1 0% python-nav-end-of-statement 1 0% syntax-class 1 0% syntax-after 1 0% - python-nav-beginning-of-statement 5 0% syntax-ppss 3 0% - python-info-line-ends-backslash-p 2 0% syntax-ppss 2 0% - python-info-assignment-statement-p 1 0% - python-nav-beginning-of-statement 1 0% syntax-ppss 1 0% syntax-ppss 3 0% - replace-regexp-in-string 1 0% apply 1 0% - font-lock-fontify-keywords-region 15 0% # 9 0% # 5 0% - eval 9 0% if 7 0% - unless 1 0% - if 1 0% - display-graphic-p 1 0% framep-on-display 1 0% - tool-bar-make-keymap 5 0% - tool-bar-make-keymap-1 5 0% - mapcar 5 0% - # 5 0% - eval 4 0% - find-image 4 0% image-search-load-path 3 0% - # 3 0% - apply 3 0% - redisplay--pre-redisplay-functions 3 0% - run-hook-with-args 2 0% - redisplay--update-region-highlight 1 0% # 1 0% - mode-line-default-help-echo 3 0% - window-at-side-p 2 0% - window-pixel-edges 2 0% window-edges 1 0% file-remote-p 3 0% x-gtk-map-stock 1 0% - command-execute 988 30% - call-interactively 986 30% - funcall-interactively 889 27% - kmacro-end-or-call-macro 617 19% - kmacro-call-macro 617 19% - call-last-kbd-macro 592 18% - command-execute 540 16% - call-interactively 531 16% - byte-code 412 12% - read-extended-command 412 12% - completing-read 410 12% - completing-read-default 409 12% - read-from-minibuffer 48 1% - command-execute 23 0% - call-interactively 15 0% - funcall-interactively 15 0% - self-insert-command 7 0% # 3 0% - minibuffer-complete-and-exit 4 0% - completion-complete-and-exit 4 0% - completion--complete-and-exit 2 0% - test-completion 2 0% - # 2 0% - complete-with-action 2 0% test-completion 2 0% - minibuffer-inactive-mode 11 0% - run-mode-hooks 7 0% - run-hooks 7 0% - global-font-lock-mode-enable-in-buffers 7 0% - turn-on-font-lock-if-desired 7 0% - turn-on-font-lock 7 0% - font-lock-mode 7 0% font-lock-default-function 3 0% called-interactively-p 2 0% - kill-all-local-variables 2 0% global-eldoc-mode-cmhh 1 0% - window--sanitize-window-sizes 3 0% - walk-window-tree 2 0% - walk-window-tree-1 2 0% - # 2 0% - window-min-size 2 0% - window--min-size-1 1 0% window-size-fixed-p 1 0% - frame-windows-min-size 2 0% - window-min-size 2 0% - window--min-size-1 1 0% - window-size-fixed-p 1 0% window--size-fixed-1 1 0% clear-minibuffer-message 1 0% # 1 0% add-hook 1 0% - funcall-interactively 116 3% - self-insert-command 47 1% - python-indent-post-self-insert-function 39 1% - syntax-ppss 39 1% - syntax-propertize 4 0% # 2 0% - electric-indent-post-self-insert-function 4 0% - syntax-ppss 4 0% syntax-propertize 1 0% - jit-lock-after-change 2 0% run-hook-with-args 1 0% - execute-extended-command 42 1% - sit-for 41 1% - redisplay 2 0% - redisplay_internal (C function) 2 0% - jit-lock-function 2 0% - jit-lock-fontify-now 2 0% - jit-lock--run-functions 2 0% - run-hook-wrapped 2 0% - # 2 0% - font-lock-fontify-region 2 0% - font-lock-default-fontify-region 2 0% - font-lock-fontify-keywords-region 2 0% # 2 0% input-pending-p 2 0% - kill-line 20 0% - kill-region 18 0% - kill-new 13 0% - gui-select-text 10 0% - gui-set-selection 10 0% - gui-backend-set-selection 10 0% - apply 10 0% # 10 0% menu-bar-update-yank-menu 2 0% - filter-buffer-substring 3 0% - buffer-substring--filter 3 0% - # 3 0% - apply 3 0% - # 3 0% delete-and-extract-region 1 0% back-to-indentation 1 0% - jit-lock--antiblink-post-command 42 1% syntax-ppss 36 1% - run-with-idle-timer 1 0% - timer-activate-when-idle 1 0% - timer--activate 1 0% timer--time-less-p 1 0% global-font-lock-mode-check-buffers 2 0% undo-auto--add-boundary 1 0% - execute-extended-command 224 6% - execute-extended-command--shorter 194 6% - completion-try-completion 194 6% - completion--nth-completion 194 6% - completion--some 194 6% - # 194 6% - completion-pcm-try-completion 127 3% - completion-pcm--find-all-completions 124 3% completion-pcm--all-completions 123 3% - completion-pcm--merge-try 2 0% completion-pcm--merge-completions 1 0% completion-basic-try-completion 67 2% - sit-for 17 0% redisplay 14 0% - command-execute 10 0% - call-interactively 10 0% - byte-code 5 0% - completing-read 5 0% - completing-read-default 5 0% read-from-minibuffer 1 0% - funcall-interactively 4 0% - profiler-report 3 0% - profiler-report-cpu 3 0% - profiler-report-profile-other-window 3 0% - profiler-report-setup-buffer 2 0% - profiler-report-render-calltree 2 0% - profiler-report-rerender-calltree 2 0% - profiler-report-render-calltree-1 2 0% - profiler-calltree-build 2 0% - profiler-calltree-build-unified 2 0% - maphash 2 0% # 1 0% - switch-to-buffer-other-window 1 0% - pop-to-buffer 1 0% - display-buffer 1 0% - display-buffer--maybe-pop-up-frame-or-window 1 0% - display-buffer--maybe-pop-up-window 1 0% - display-buffer-pop-up-window 1 0% window--maybe-raise-frame 1 0% - python-mode 1 0% python-indent-guess-indent-offset 1 0% # 1 0% - yank 26 0% - push-mark 17 0% mark 1 0% insert-for-yank 5 0% - current-kill 3 0% - gui-selection-value 3 0% - gui--selection-value-internal 3 0% gui-get-selection 3 0% - previous-line 9 0% - line-move 9 0% line-move-visual 7 0% - profiler-report-toggle-entry 5 0% - profiler-report-expand-entry 5 0% - profiler-report-expand-entry 5 0% - profiler-report-insert-calltree-children 5 0% - mapc 5 0% - profiler-report-insert-calltree 1 0% - profiler-report-line-format 1 0% - profiler-format 1 0% - apply 1 0% - profiler-format 1 0% apply 1 0% end-of-buffer 2 0% - yank-pop 2 0% insert-for-yank 1 0% - kill-line 2 0% - kill-region 2 0% - kill-new 1 0% - gui-select-text 1 0% - gui-set-selection 1 0% - gui-backend-set-selection 1 0% - apply 1 0% # 1 0% - filter-buffer-substring 1 0% - buffer-substring--filter 1 0% - # 1 0% - apply 1 0% - # 1 0% - delete-and-extract-region 1 0% jit-lock-after-change 1 0% - handle-focus-in 1 0% - # 1 0% - apply 1 0% - blink-cursor--rescan-frames 1 0% - blink-cursor-check 1 0% - blink-cursor--start-idle-timer 1 0% - run-with-idle-timer 1 0% - timer-set-idle-time 1 0% timer--time-setter 1 0% - kmacro-start-macro-or-insert-counter 1 0% kmacro-start-macro 1 0% - byte-code 90 2% - read-extended-command 80 2% - completing-read 80 2% - completing-read-default 80 2% - read-from-minibuffer 46 1% - undo-auto--add-boundary 2 0% - undo-auto--boundaries 2 0% undo-auto--ensure-boundary 2 0% - redisplay_internal (C function) 2 0% - tool-bar-make-keymap 1 0% - tool-bar-make-keymap-1 1 0% - mapcar 1 0% - # 1 0% - eval 1 0% - find-image 1 0% - cond 1 0% not 1 0% - eval 1 0% if 1 0% - command-execute 1 0% - call-interactively 1 0% - funcall-interactively 1 0% - self-insert-command 1 0% electric-indent-post-self-insert-function 1 0% - read-buffer-to-switch 10 0% - read-buffer 10 0% - completing-read-default 10 0% - read-from-minibuffer 6 0% - redisplay_internal (C function) 1 0% x-gtk-map-stock 1 0% - completing-read-default 7 0% read-from-minibuffer 3 0% + ... 974 30% + timer-event-handler 6 0% + gui-set-selection 3 0% + deactivate-mark 2 0% + xselect-convert-to-string 1 0% + # 1 0% clear-minibuffer-message 1 0% + undo-auto--add-boundary 1 0% internal-timer-start-idle 1 0% internal-echo-keystrokes-prefix 1 0% BR, Robert Thorpe From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 16 11:23:26 2020 Received: (at 44610) by debbugs.gnu.org; 16 Nov 2020 16:23:26 +0000 Received: from localhost ([127.0.0.1]:56894 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kehHq-0002vE-Fg for submit@debbugs.gnu.org; Mon, 16 Nov 2020 11:23:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33430) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kehHo-0002v2-Fh for 44610@debbugs.gnu.org; Mon, 16 Nov 2020 11:23:24 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:36066) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kehHf-0003yJ-V0; Mon, 16 Nov 2020 11:23:18 -0500 Received: from [176.228.60.248] (port=2873 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kehHf-0002Ry-B7; Mon, 16 Nov 2020 11:23:15 -0500 Date: Mon, 16 Nov 2020 18:23:08 +0200 Message-Id: <837dqltgnn.fsf@gnu.org> From: Eli Zaretskii To: Robert Thorpe In-Reply-To: <87zh3i6v8f.fsf@robertthorpeconsulting.com> (message from Robert Thorpe on Sun, 15 Nov 2020 23:44:32 +0000) Subject: Re: bug#44610: 27.1; Keyboard Macro Performance Problem References: <87zh3i6v8f.fsf@robertthorpeconsulting.com> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 44610 Cc: 44610@debbugs.gnu.org, bugs@gnu.support 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: -3.3 (---) > From: Robert Thorpe > Cc: 44610@debbugs.gnu.org > Date: Sun, 15 Nov 2020 23:44:32 +0000 > > > I suggest to produce and present a profile of this. Invoke this macro > > after "M-x profiler-start RET RET", then "M-x profiler-report RET", > > expand the profile fully by "C-u RET" on the top line, and post the > > result here. That should give some clues. > > Here is the report. I did it in Python-mode using Emacs -Q on Emacs > 27.1. My machine is a Dell 14-3480. The profile I've got seems to be a > bit different to the one Jean Louis got. > > It is a little faster using Emacs -Q than my own init, but it's > still fairly slow. > > I notice that in my report the GC is taking about 39% of runtime. I'm > not sure why it's taking longer than in Jen Louis' report. > > It's faster if I use forward-line rather than pressing C-n. Also the > report looks very different. I've added that at the end. The first > report is the one using C-n. Thanks. I think the conclusion is quite clear: > - command-execute 3499 60% > - call-interactively 3499 60% > - funcall-interactively 3480 59% > - kmacro-end-or-call-macro 3474 59% > - kmacro-call-macro 3474 59% > - call-last-kbd-macro 3464 59% > - command-execute 3419 58% > - call-interactively 3417 58% > - funcall-interactively 3417 58% > - next-line 3345 57% > - line-move 3345 57% > - line-move-visual 3339 57% > - vertical-motion 3132 53% > - jit-lock-function 3132 53% > - jit-lock-fontify-now 3131 53% > - jit-lock--run-functions 3112 53% > - run-hook-wrapped 3112 53% > - # 3111 53% > - font-lock-fontify-region 3111 53% > - font-lock-default-fontify-region 3111 53% > - font-lock-fontify-syntactically-region 3082 53% > - python-font-lock-syntactic-face-function 3063 52% > - python-info-docstring-p 3055 52% > - python-nav-backward-sexp 3016 51% > - python-nav-forward-sexp 3007 51% > - python-nav--forward-sexp 2968 51% > - python-info-beginning-of-block-p 2005 34% > - python-info-beginning-of-statement-p 1670 28% > - python-nav-beginning-of-statement 1644 28% > - syntax-ppss 1392 23% > # 1 0% The culprit is indeed fontifications, and specifically the code in python-nav--forward-sexp and its subroutines. So this is where optimizations or simplifications will yield the greatest speedup. From debbugs-submit-bounces@debbugs.gnu.org Tue Nov 17 01:50:13 2020 Received: (at 44610) by debbugs.gnu.org; 17 Nov 2020 06:50:13 +0000 Received: from localhost ([127.0.0.1]:58130 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1keuof-0007tK-Cu for submit@debbugs.gnu.org; Tue, 17 Nov 2020 01:50:13 -0500 Received: from static.rcdrun.com ([95.85.24.50]:53139) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1keuoa-0007s1-CI for 44610@debbugs.gnu.org; Tue, 17 Nov 2020 01:50:09 -0500 Received: from localhost ([::ffff:41.202.241.56]) (AUTH: PLAIN admin, TLS: TLS1.2,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by static.rcdrun.com with ESMTPSA id 00000000002C0006.000000005FB3729F.0000633D; Tue, 17 Nov 2020 06:50:06 +0000 Date: Mon, 16 Nov 2020 20:50:47 +0300 From: Jean Louis To: Eli Zaretskii Subject: Re: bug#44610: 27.1; Keyboard Macro Performance Problem Message-ID: References: <87zh3i6v8f.fsf@robertthorpeconsulting.com> <837dqltgnn.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline In-Reply-To: <837dqltgnn.fsf@gnu.org> User-Agent: Mutt/2.0 (3d08634) (2020-11-07) X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 44610 Cc: Robert Thorpe , 44610@debbugs.gnu.org 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: -0.2 (/) * Eli Zaretskii [2020-11-16 19:23]: > > From: Robert Thorpe > > Cc: 44610@debbugs.gnu.org > > Date: Sun, 15 Nov 2020 23:44:32 +0000 > > > > > I suggest to produce and present a profile of this. Invoke this macro > > > after "M-x profiler-start RET RET", then "M-x profiler-report RET", > > > expand the profile fully by "C-u RET" on the top line, and post the > > > result here. That should give some clues. > > > > Here is the report. I did it in Python-mode using Emacs -Q on Emacs > > 27.1. My machine is a Dell 14-3480. The profile I've got seems to be a > > bit different to the one Jean Louis got. I was in empty buffer with python-mode. Maybe you had some python code already inside? I did not have. From debbugs-submit-bounces@debbugs.gnu.org Wed Nov 18 00:22:51 2020 Received: (at 44610) by debbugs.gnu.org; 18 Nov 2020 05:22:51 +0000 Received: from localhost ([127.0.0.1]:33762 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kfFve-0008C3-OU for submit@debbugs.gnu.org; Wed, 18 Nov 2020 00:22:51 -0500 Received: from outbound-smtp31.blacknight.com ([81.17.249.62]:56514) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kfFva-0008Bn-9w for 44610@debbugs.gnu.org; Wed, 18 Nov 2020 00:22:48 -0500 Received: from mail.blacknight.com (pemlinmail02.blacknight.ie [81.17.254.11]) by outbound-smtp31.blacknight.com (Postfix) with ESMTPS id 1DC3FC0EF2 for <44610@debbugs.gnu.org>; Wed, 18 Nov 2020 05:22:40 +0000 (GMT) Received: (qmail 6800 invoked from network); 18 Nov 2020 05:22:39 -0000 Received: from unknown (HELO rt-inspiron-3480) (rt@robertthorpeconsulting.com@[51.37.30.105]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 18 Nov 2020 05:22:39 -0000 From: Robert Thorpe To: Jean Louis Subject: Re: bug#44610: 27.1; Keyboard Macro Performance Problem In-Reply-To: (message from Jean Louis on Mon, 16 Nov 2020 20:50:47 +0300) Date: Wed, 18 Nov 2020 05:22:18 +0000 Message-ID: <875z63b5o5.fsf@robertthorpeconsulting.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 44610 Cc: eliz@gnu.org, 44610@debbugs.gnu.org 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 (-) Jean Louis writes: > * Eli Zaretskii [2020-11-16 19:23]: >> > From: Robert Thorpe >> > Cc: 44610@debbugs.gnu.org >> > Date: Sun, 15 Nov 2020 23:44:32 +0000 >> > >> > > I suggest to produce and present a profile of this. Invoke this macro >> > > after "M-x profiler-start RET RET", then "M-x profiler-report RET", >> > > expand the profile fully by "C-u RET" on the top line, and post the >> > > result here. That should give some clues. >> > >> > Here is the report. I did it in Python-mode using Emacs -Q on Emacs >> > 27.1. My machine is a Dell 14-3480. The profile I've got seems to be a >> > bit different to the one Jean Louis got. > > I was in empty buffer with python-mode. Maybe you had some python code > already inside? I did not have. In my buffer I did what I described in the bug report. I had the string: ffffffffffffffffffff (pppppppppppppppppppp); Copied 300 times. That way the macro could operate on it. BR, Robert Thorpe