Subject: bug#39598: 26.3; Emacs is extremely unresponsive on a trivial python file

From: Ivan Oreshnikov <[email-masked]>
Date: Fri, 14 Feb 2020 17:08:19 +0100

Sorry, didn't notice your first message (didn't expect such a quick
response :).

Yes, my profile is very similar to yours:

- redisplay_internal (C function)                               18208  92%
 - jit-lock-function                                            18198  92%
  - jit-lock-fontify-now                                        18197  92%
   - jit-lock--run-functions                                    18196  92%
    - run-hook-wrapped                                          18196  92%
     - #<compiled 0xf5b8a9>                                     18196  92%
      - font-lock-fontify-region                                18195  92%
       - font-lock-default-fontify-region                       18193  92%
        - font-lock-fontify-syntactically-region                18163  92%
         - python-font-lock-syntactic-face-function              18066  91%
          - python-info-docstring-p                             18054  91%
           - python-nav-backward-sexp                           17878  90%
            - python-nav-forward-sexp                           17872  90%
             - python-nav--forward-sexp                         17841  90%
              - python-info-beginning-of-block-p                 7363  37%
               - python-info-beginning-of-statement-p               4163
 21%
                - python-nav-beginning-of-statement               4132  20%
                 - python-info-line-ends-backslash-p               2566  13%
                  - syntax-ppss                                  2510  12%
                     #<compiled 0xc88ab5>                           1   0%
                 - syntax-ppss                                   1446   7%
                    #<compiled 0xec6b99>                            3   0%
                   back-to-indentation                             61   0%
               - python-info-statement-starts-block-p               3180
 16%
                - python-nav-beginning-of-statement               3133  15%
                 - syntax-ppss                                   1500   7%
                    #<compiled 0xf43645>                            5   0%
                 - python-info-line-ends-backslash-p               1492   7%
                  - syntax-ppss                                  1450   7%
                     #<compiled 0xc934cd>                           1   0%
                   back-to-indentation                             68   0%
              - python-info-end-of-block-p                       4882  24%
               - python-info-end-of-statement-p                  4869  24%
                - python-nav-end-of-statement                    4852  24%
                 - syntax-ppss                                   3048  15%
                    #<compiled 0xf62cf9>                            4   0%
                 - python-info-line-ends-backslash-p               1687   8%
                  - syntax-ppss                                  1649   8%
                     #<compiled 0xf58689>                           3   0%
              - python-info-beginning-of-statement-p               3078  15%
               - python-nav-beginning-of-statement               3051  15%
                - python-info-line-ends-backslash-p               1520   7%
                 - syntax-ppss                                   1454   7%
                    #<compiled 0xc8c561>                            1   0%
                  syntax-ppss                                    1408   7%
                  back-to-indentation                              52   0%
              - python-nav-beginning-of-statement                1473   7%
                 syntax-ppss                                      707   3%
               - python-info-line-ends-backslash-p                705   3%
                - syntax-ppss                                     681   3%
                   #<compiled 0xc84f2d>                             1   0%
                 back-to-indentation                               28   0%
              - python-syntax-context-type                        779   3%
               - syntax-ppss                                      765   3%
                  #<compiled 0xedb06d>                              3   0%
              - python-nav--lisp-forward-sexp                     149   0%
                 forward-sexp                                     139   0%
              - python-info-current-line-empty-p                   52   0%
                 match-string-no-properties                         1   0%
                syntax-after                                        5   0%
                syntax-class                                        1   0%
           - python-nav-beginning-of-statement                     73   0%
              syntax-ppss                                          42   0%
            - python-info-line-ends-backslash-p                    29   0%
               syntax-ppss                                         29   0%
           - python-info-assignment-statement-p                    61   0%
            - python-nav-beginning-of-statement                    58   0%
               syntax-ppss                                         31   0%
             - python-info-line-ends-backslash-p                   25   0%
                syntax-ppss                                        25   0%
               back-to-indentation                                  1   0%
             python-util-forward-comment                            1   0%
         - syntax-propertize                                       86   0%
          - #<compiled 0xe7bfcd>                                   85   0%
           - python-syntax-stringify                               76   0%
              syntax-ppss                                          75   0%
              match-string-no-properties                            1   0%
           syntax-ppss                                              8   0%
         + replace-regexp-in-string                                 2   0%
        + font-lock-fontify-keywords-region                        26   0%
...

On Fri, 14 Feb 2020 at 14:50, Eli Zaretskii <[email-masked]> wrote:

> > Date: Fri, 14 Feb 2020 15:35:58 +0200
> > From: Eli Zaretskii <[email-masked]>
> > Cc: [email-masked]
> >
> > Please show the entire expanded profile.
>
> My profile is below.  Is yours similar?  If so, I thing
> python-nav-beginning-of-statement, python-nav-end-of-statement, and
> python-nav--forward-sexp are the main culprits.
>
>   - redisplay_internal (C function)                                1600
> 46%
>    - jit-lock-function                                             1600
> 46%
>     - jit-lock-fontify-now                                         1600
> 46%
>      - jit-lock--run-functions                                     1600
> 46%
>       - run-hook-wrapped                                           1600
> 46%
>        - #<compiled -0x1ffffffff8c1b778>                           1600
> 46%
>         - font-lock-fontify-region                                 1600
> 46%
>          - font-lock-default-fontify-region                        1600
> 46%
>           - font-lock-fontify-syntactically-region                 1600
> 46%
>            - python-font-lock-syntactic-face-function               1600
> 46%
>             - python-info-docstring-p                              1599
> 46%
>              - python-nav-backward-sexp                            1583
> 46%
>               - python-nav-forward-sexp                            1583
> 46%
>                - python-nav--forward-sexp                          1580
> 46%
>                 - python-info-end-of-block-p                        893
> 26%
>                  - python-info-end-of-statement-p                   893
> 26%
>                   - python-nav-end-of-statement                     892
> 26%
>                      syntax-ppss                                    591
> 17%
>                    - python-info-line-ends-backslash-p                292
>  8%
>                       syntax-ppss                                   289
>  8%
>                 - python-info-beginning-of-statement-p                533
> 15%
>                  - python-nav-beginning-of-statement                531
> 15%
>                     syntax-ppss                                     275
>  8%
>                   - python-info-line-ends-backslash-p                251
>  7%
>                    - syntax-ppss                                    244
>  7%
>                       #<compiled -0x1ffffffff8326490>                  1
>  0%
>                     back-to-indentation                               4
>  0%
>                 - python-nav-beginning-of-statement                  79
>  2%
>                    syntax-ppss                                       70
>  2%
>                    back-to-indentation                                3
>  0%
>                    python-info-line-ends-backslash-p                  2
>  0%
>                 - python-syntax-context-type                         52
>  1%
>                    syntax-ppss                                       52
>  1%
>                 - python-nav--lisp-forward-sexp                       7
>  0%
>                    forward-sexp                                       7
>  0%
>                 - python-info-beginning-of-block-p                    7
>  0%
>                    python-info-statement-starts-block-p
> 3   0%
>                    python-info-beginning-of-statement-p
> 2   0%
>                 - python-info-current-line-empty-p                    5
>  0%
>                    match-string-no-properties                         1
>  0%
>                   syntax-class                                        1
>  0%
>              - python-nav-beginning-of-statement                      8
>  0%
>                 syntax-ppss                                           7
>  0%
>               - python-info-line-ends-backslash-p                     1
>  0%
>                  syntax-ppss                                          1
>  0%
>              - python-info-assignment-statement-p                     4
>  0%
>               - python-nav-beginning-of-statement                     4
>  0%
>                - python-info-line-ends-backslash-p                    3
>  0%
>                   syntax-ppss                                         3
>  0%
>                  syntax-ppss                                          1
>  0%
>   - command-execute                                                1414
> 41%
>    - call-interactively                                            1414
> 41%
>     - funcall-interactively                                        1413
> 41%
>      - scroll-up-command                                           1412
> 41%
>       - scroll-up                                                  1412
> 41%
>        - jit-lock-function                                         1412
> 41%
>         - jit-lock-fontify-now                                     1412
> 41%
>          - jit-lock--run-functions                                 1412
> 41%
>           - run-hook-wrapped                                       1412
> 41%
>            - #<compiled -0x1ffffffff8c1b778>                       1412
> 41%
>             - font-lock-fontify-region                             1412
> 41%
>              - font-lock-default-fontify-region                    1412
> 41%
>               - font-lock-fontify-syntactically-region               1412
> 41%
>                - python-font-lock-syntactic-face-function
>  1412  41%
>                 - python-info-docstring-p                          1411
> 41%
>                  - python-nav-backward-sexp                        1402
> 40%
>                   - python-nav-forward-sexp                        1402
> 40%
>                    - python-nav--forward-sexp                      1400
> 40%
>                     - python-info-beginning-of-block-p               1137
> 33%
>                      - python-info-beginning-of-statement-p
> 585  17%
>                       - python-nav-beginning-of-statement
> 585  17%
>                        - python-info-line-ends-backslash-p
> 327   9%
>                           syntax-ppss                               322
>  9%
>                          syntax-ppss                                248
>  7%
>                          back-to-indentation                          7
>  0%
>                      - python-info-statement-starts-block-p
> 550  16%
>                       - python-nav-beginning-of-statement
> 546  15%
>                          syntax-ppss                                270
>  7%
>                        - python-info-line-ends-backslash-p
> 262   7%
>                           syntax-ppss                               256
>  7%
>                          back-to-indentation                          6
>  0%
>                     - python-nav-beginning-of-statement
> 190   5%
>                      - python-info-line-ends-backslash-p
> 113   3%
>                         syntax-ppss                                 110
>  3%
>                        syntax-ppss                                   74
>  2%
>                        back-to-indentation                            1
>  0%
>                     - python-syntax-context-type                     61
>  1%
>                        syntax-ppss                                   61
>  1%
>                     - python-info-beginning-of-statement-p
>   4   0%
>                        python-nav-beginning-of-statement
> 3   0%
>                     - python-nav--lisp-forward-sexp                   3
>  0%
>                        forward-sexp                                   2
>  0%
>                       python-info-current-line-empty-p                  2
>  0%
>                     - python-info-end-of-block-p                      1
>  0%
>                        python-info-end-of-statement-p                  1
>  0%
>                  - python-nav-beginning-of-statement                  4
>  0%
>                   - python-info-line-ends-backslash-p                  3
>  0%
>                      syntax-ppss                                      3
>  0%
>                     syntax-ppss                                       1
>  0%
>                  - python-info-assignment-statement-p                  4
>  0%
>                   - python-nav-beginning-of-statement                  4
>  0%
>                      syntax-ppss                                      2
>  0%
>                    - python-info-line-ends-backslash-p                  2
>  0%
>                       syntax-ppss                                     2
>  0%
>      - execute-extended-command                                       1
>  0%
>       - sit-for                                                       1
>  0%
>        - redisplay                                                    1
>  0%
>         - redisplay_internal (C function)                             1
>  0%
>          - tool-bar-make-keymap                                       1
>  0%
>           - tool-bar-make-keymap-1                                    1
>  0%
>            - mapcar                                                   1
>  0%
>             - #<compiled -0x1ffffffffa0b8700>                         1
>  0%
>              - eval                                                   1
>  0%
>               - find-image                                            1
>  0%
>                  image-type-available-p                               1
>  0%
>     - byte-code                                                       1
>  0%
>      - read-extended-command                                          1
>  0%
>       - completing-read                                               1
>  0%
>          completing-read-default                                      1
>  0%
>   - ...                                                             406
> 11%
>      Automatic GC                                                   406
> 11%
>