unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#44610: 27.1; Keyboard Macro Performance Problem
@ 2020-11-13  2:51 Robert Thorpe
  2020-11-13  8:55 ` Jean Louis
  2020-11-14 14:26 ` Eli Zaretskii
  0 siblings, 2 replies; 10+ messages in thread
From: Robert Thorpe @ 2020-11-13  2:51 UTC (permalink / raw)
  To: 44610


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, cairo 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 ‘forward-line’ with M-x fo-lin RET
Keyboard macro defined
Can’t guess python-indent-offset, using defaults: 4

Configured using:
 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --with-x-toolkit=gtk3 --with-xft --with-wide-int
 --with-modules --with-cairo --with-harfbuzz 'CFLAGS=-march=x86-64
 -mtune=generic -O2 -pipe -fno-plt' CPPFLAGS=-D_FORTIFY_SOURCE=2
 LDFLAGS=-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))





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#44610: 27.1; Keyboard Macro Performance Problem
  2020-11-13  2:51 bug#44610: 27.1; Keyboard Macro Performance Problem Robert Thorpe
@ 2020-11-13  8:55 ` Jean Louis
  2020-11-14 14:26 ` Eli Zaretskii
  1 sibling, 0 replies; 10+ messages in thread
From: Jean Louis @ 2020-11-13  8:55 UTC (permalink / raw)
  To: Robert Thorpe, 44610

Modes are programs and their checks slow down the macro execution. If it happens to me I will simple temporarily switch the mode to fundamental.

Maybe there is or could be an option that macro executes only in fundamental mode and then automatically turns on whatever other mode was there.


Jean





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#44610: 27.1; Keyboard Macro Performance Problem
  2020-11-13  2:51 bug#44610: 27.1; Keyboard Macro Performance Problem Robert Thorpe
  2020-11-13  8:55 ` Jean Louis
@ 2020-11-14 14:26 ` Eli Zaretskii
  2020-11-14 16:03   ` Jean Louis
  2020-11-15 23:44   ` Robert Thorpe
  1 sibling, 2 replies; 10+ messages in thread
From: Eli Zaretskii @ 2020-11-14 14:26 UTC (permalink / raw)
  To: Robert Thorpe; +Cc: 44610

> From: Robert Thorpe <rt@robertthorpeconsulting.com>
> 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.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#44610: 27.1; Keyboard Macro Performance Problem
  2020-11-14 14:26 ` Eli Zaretskii
@ 2020-11-14 16:03   ` Jean Louis
  2020-11-14 16:24     ` Eli Zaretskii
  2020-11-14 16:50     ` Eli Zaretskii
  2020-11-15 23:44   ` Robert Thorpe
  1 sibling, 2 replies; 10+ messages in thread
From: Jean Louis @ 2020-11-14 16:03 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Robert Thorpe, 44610

* Eli Zaretskii <eliz@gnu.org> [2020-11-14 17:27]:
> > From: Robert Thorpe <rt@robertthorpeconsulting.com>
> > 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%
                 - #<compiled 0x5b100c193163db5>            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%
                       #<compiled 0x19a45f465d8aaf17>         369,664   1%
                       #<compiled -0x1210e8980f7ecafc>        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%
                                #<compiled 0x1c65d0f034163548>         4,320   0%
                             - python-info-line-ends-backslash-p        45,344   0%
                              - syntax-ppss                    45,344   0%
                                 #<compiled 0x1c65d0f034163548>         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%
                           #<compiled 0x1c65d0f034163548>         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%
                 - #<compiled 0x5b100c193163db5>              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%
                       #<compiled 0x19a45f465d8aaf17>          15,872   0%
                     - python--font-lock-f-strings             15,456   0%
                        syntax-ppss                             3,168   0%
                       #<compiled -0x1210e8980f7ecafc>         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%
                  #<compiled -0x1ef4cefd5124968d>              73,824   0%
           - filter-buffer-substring                           74,437   0%
            - buffer-substring--filter                         68,101   0%
             - #<compiled -0x1e2a987f6542516b>                 68,101   0%
              - apply                                          68,101   0%
               - #<compiled 0xd88b599ee0a5190>                 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%
               #<compiled 0x14be23ea75627c25>                 311,064   1%
             - run-hook-wrapped                                 1,056   0%
                #<compiled -0x10385ae61af9e5a6>                 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%
                #<compiled -0x1038556930f9e5a6>                 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%
          - #<compiled -0xe8295ef54b23da6>                    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%
        - #<compiled 0x81c0cf17cf07668>                       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%
      #<compiled -0x1910b770d84f49d5>                              42   0%
   - handle-focus-in                                            2,112   0%
    - #<compiled 0x189e2a0a0dde442>                             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%
           - #<compiled -0xe8295ef54b23da6>                   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%
             #<compiled 0x23be74412ab8ae>                       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%





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#44610: 27.1; Keyboard Macro Performance Problem
  2020-11-14 16:03   ` Jean Louis
@ 2020-11-14 16:24     ` Eli Zaretskii
  2020-11-14 16:50     ` Eli Zaretskii
  1 sibling, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2020-11-14 16:24 UTC (permalink / raw)
  To: Jean Louis; +Cc: rt, 44610

> Date: Sat, 14 Nov 2020 19:03:11 +0300
> From: Jean Louis <bugs@gnu.support>
> Cc: Robert Thorpe <rt@robertthorpeconsulting.com>,
>   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%
>                  - #<compiled 0x5b100c193163db5>            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.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#44610: 27.1; Keyboard Macro Performance Problem
  2020-11-14 16:03   ` Jean Louis
  2020-11-14 16:24     ` Eli Zaretskii
@ 2020-11-14 16:50     ` Eli Zaretskii
  1 sibling, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2020-11-14 16:50 UTC (permalink / raw)
  To: Jean Louis; +Cc: rt, 44610

> Date: Sat, 14 Nov 2020 19:03:11 +0300
> From: Jean Louis <bugs@gnu.support>
> Cc: Robert Thorpe <rt@robertthorpeconsulting.com>,
>   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.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#44610: 27.1; Keyboard Macro Performance Problem
  2020-11-14 14:26 ` Eli Zaretskii
  2020-11-14 16:03   ` Jean Louis
@ 2020-11-15 23:44   ` Robert Thorpe
  2020-11-16 16:23     ` Eli Zaretskii
  1 sibling, 1 reply; 10+ messages in thread
From: Robert Thorpe @ 2020-11-15 23:44 UTC (permalink / raw)
  To: Eli Zaretskii, Jean Louis; +Cc: 44610

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Robert Thorpe <rt@robertthorpeconsulting.com>
>> 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%
                 - #<compiled 0x15629e8957cd>                    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%
                                #<compiled 0x15629eb1977d>                  1   0%
                             - python-info-line-ends-backslash-p                138   2%
                              - syntax-ppss                       103   1%
                                 #<compiled 0x15629ea9bac1>                  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%
                                #<compiled 0x15629ea55d29>                  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%
                                #<compiled 0x15629eb2ece5>                  2   0%
                             - python-info-line-ends-backslash-p                104   1%
                              - syntax-ppss                        87   1%
                                 #<compiled 0x15629ea943f5>                  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%
                                #<compiled 0x15629eb1e6a1>                  1   0%
                              syntax-ppss                          72   1%
                              back-to-indentation                  44   0%
                          - python-nav-beginning-of-statement                107   1%
                           - syntax-ppss                           37   0%
                              #<compiled 0x15629eb2a9b5>                  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%
                       #<compiled 0x15629e89743d>                  11   0%
                       #<compiled 0x15629e897459>                   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%
                 - #<compiled 0x15629eb1cfd5>                      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%
                       #<compiled 0x15629e89743d>                   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%
               #<compiled 0x15629e89748d>                           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%
                  #<compiled 0x1fd8bb00bf7f>                       11   0%
              menu-bar-update-yank-menu                             1   0%
      - jit-lock--antiblink-post-command                           35   0%
       - syntax-ppss                                               29   0%
        - syntax-propertize                                         5   0%
           #<compiled 0x15629e89748d>                               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%
           - #<compiled 0x1fd8bb03930b>                             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%
     - #<compiled 0x15629ead2fe5>                                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%
           #<compiled 0x15629e89743d>                               9   0%
           #<compiled 0x15629e897459>                               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%
    - #<compiled 0x1fd8bb03930b>                                    5   0%
     - eval                                                         4   0%
      - find-image                                                  4   0%
         image-search-load-path                                     3   0%
 - #<compiled 0x1fd8bb05b46f>                                       3   0%
  - apply                                                           3   0%
   - redisplay--pre-redisplay-functions                             3   0%
    - run-hook-with-args                                            2   0%
     - redisplay--update-region-highlight                           1   0%
        #<compiled 0x1fd8baff3977>                                  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%
                   #<compiled 0x1fd8baffa1bd>                       3   0%
                - minibuffer-complete-and-exit                      4   0%
                 - completion-complete-and-exit                     4   0%
                  - completion--complete-and-exit                   2   0%
                   - test-completion                                2   0%
                    - #<compiled 0x1fd8baff9e61>                    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%
                - #<compiled 0x15629e90c20d>                        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%
               #<compiled 0x15629ea97fd1>                           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%
               #<compiled 0x15629e89748d>                           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%
                 - #<compiled 0x15629e917a4d>                       2   0%
                  - font-lock-fontify-region                        2   0%
                   - font-lock-default-fontify-region                  2   0%
                    - font-lock-fontify-keywords-region                  2   0%
                       #<compiled 0x15629e89743d>                   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%
                  #<compiled 0x1fd8bb00bf7f>                       10   0%
              menu-bar-update-yank-menu                             2   0%
           - filter-buffer-substring                                3   0%
            - buffer-substring--filter                              3   0%
             - #<compiled 0x15629ea7fcf5>                           3   0%
              - apply                                               3   0%
               - #<compiled 0x1fd8bafd224d>                         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%
        - #<compiled 0x15629eb8865d>                              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%
                   #<compiled 0x15629e778d71>                       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%
      #<compiled 0x15629eacb3e5>                                    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%
            #<compiled 0x1fd8bb00bf7f>                              1   0%
     - filter-buffer-substring                                      1   0%
      - buffer-substring--filter                                    1   0%
       - #<compiled 0x15629e83a3c1>                                 1   0%
        - apply                                                     1   0%
         - #<compiled 0x1fd8bafd224d>                               1   0%
          - delete-and-extract-region                               1   0%
             jit-lock-after-change                                  1   0%
   - handle-focus-in                                                1   0%
    - #<compiled 0x15629e827df9>                                    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%
           - #<compiled 0x1fd8bb03930b>                             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%
+ #<compiled 0x1fd8bb09a70d>                                        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






^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#44610: 27.1; Keyboard Macro Performance Problem
  2020-11-15 23:44   ` Robert Thorpe
@ 2020-11-16 16:23     ` Eli Zaretskii
  2020-11-16 17:50       ` Jean Louis
  0 siblings, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2020-11-16 16:23 UTC (permalink / raw)
  To: Robert Thorpe; +Cc: bugs, 44610

> From: Robert Thorpe <rt@robertthorpeconsulting.com>
> 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%
>                  - #<compiled 0x15629e8957cd>                    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%
>                                 #<compiled 0x15629eb1977d>                  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.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#44610: 27.1; Keyboard Macro Performance Problem
  2020-11-16 16:23     ` Eli Zaretskii
@ 2020-11-16 17:50       ` Jean Louis
  2020-11-18  5:22         ` Robert Thorpe
  0 siblings, 1 reply; 10+ messages in thread
From: Jean Louis @ 2020-11-16 17:50 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Robert Thorpe, 44610

* Eli Zaretskii <eliz@gnu.org> [2020-11-16 19:23]:
> > From: Robert Thorpe <rt@robertthorpeconsulting.com>
> > 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.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#44610: 27.1; Keyboard Macro Performance Problem
  2020-11-16 17:50       ` Jean Louis
@ 2020-11-18  5:22         ` Robert Thorpe
  0 siblings, 0 replies; 10+ messages in thread
From: Robert Thorpe @ 2020-11-18  5:22 UTC (permalink / raw)
  To: Jean Louis; +Cc: 44610

Jean Louis <bugs@gnu.support> writes:

> * Eli Zaretskii <eliz@gnu.org> [2020-11-16 19:23]:
>> > From: Robert Thorpe <rt@robertthorpeconsulting.com>
>> > 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






^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-11-18  5:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-13  2:51 bug#44610: 27.1; Keyboard Macro Performance Problem Robert Thorpe
2020-11-13  8:55 ` Jean Louis
2020-11-14 14:26 ` Eli Zaretskii
2020-11-14 16:03   ` Jean Louis
2020-11-14 16:24     ` Eli Zaretskii
2020-11-14 16:50     ` Eli Zaretskii
2020-11-15 23:44   ` Robert Thorpe
2020-11-16 16:23     ` Eli Zaretskii
2020-11-16 17:50       ` Jean Louis
2020-11-18  5:22         ` Robert Thorpe

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).