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:31:48 +0100

Ok, here's the full expansion of the relevant part of the profiler report:

- redisplay_internal (C function)                               22195  91%
 - jit-lock-function
                                                           22181  91%
  - jit-lock-fontify-now
                                                           22181  91%
   - jit-lock--run-functions
                                                           22179  91%
    - run-hook-wrapped
                                                           22179  91%
     - #<compiled 0x1727cc5>
                                                           22178  91%
      - font-lock-fontify-region
                                                           22178  91%
       - font-lock-default-fontify-region
                                                          22177  91%
        - font-lock-fontify-syntactically-region
                                                           22142  90%
         - python-font-lock-syntactic-face-function
                                                          22044  90%
          - if
                                                           22043  90%
           - if
                                                          22043  90%
            - python-info-docstring-p
                                                          22041  90%
             - save-excursion
                                                          22038  90%
              - let
                                                          21959  90%
               - if
                                                          21957  90%
                - and
                                                          21957  90%
                 - >=
                                                          21881  89%
                  - let
                                                          21881  89%
                   - while
                                                           21879  89%
                    - save-excursion
                                                           21864  89%
                     - python-nav-backward-sexp
                                                          21772  89%
                      - python-nav-forward-sexp
                                                          21759  89%
                       - while
                                                           21732  89%
                        - python-nav--forward-sexp
                                                           21711  89%
                         - if
                                                          21706  89%
                          - let*
                                                           21700  89%
                           - cond
                                                          20732  85%
                            - let*
                                                           20686  84%
                             - cond
                                                          10735  44%
                              - python-info-beginning-of-block-p
                                                            4750  19%
                               - and
                                                            4748  19%
                                - python-info-beginning-of-statement-p
                                                            3683  15%
                                 - =
                                                            3676  15%
                                  - save-excursion
                                                            3671  15%
                                   - python-nav-beginning-of-statement
                                                            3667  15%
                                    - let*
                                                            3631  14%
                                     - cond
                                                           2691  11%
                                      - save-excursion
                                                            2679  11%
                                       - python-info-line-ends-backslash-p
                                                            2673  10%
                                        - save-excursion
                                                            2665  10%
                                         - while
                                                            2661  10%
                                          - and
                                                           2658  10%
                                           - nth
                                                            2640  10%
                                            - or
                                                            2638  10%
                                             - syntax-ppss
                                                            2607  10%
                                                #<compiled 0x163a7bd>
                                                              2   0%
                                             goto-char
                                                              15   0%
                                             not
                                                               1   0%
                                         - if
                                                              3   0%
                                            equal
                                                              2   0%
                                     - syntax-ppss
                                                             916   3%
                                        #<compiled 0x15ecea1>
                                                              2   0%
                                     - or
                                                             10   0%
                                      - let
                                                              4   0%
                                         and
                                                               1   0%
                                        nth
                                                              1   0%
                                      back-to-indentation
                                                             21   0%
                                - python-info-statement-starts-block-p
                                                            1061   4%
                                 - save-excursion
                                                           1057   4%
                                  - python-nav-beginning-of-statement
                                                           1045   4%
                                   - let*
                                                           1006   4%
                                    - syntax-ppss
                                                            898   3%
                                       #<compiled 0x57b3bd>
                                                              1   0%
                                    - cond
                                                              77   0%
                                     - save-excursion
                                                             74   0%
                                      - python-info-line-ends-backslash-p
                                                             61   0%
                                       - save-excursion
                                                             54   0%
                                        - while
                                                             47   0%
                                         - and
                                                              44   0%
                                          - nth
                                                             21   0%
                                             or
                                                             16   0%
                                            goto-char
                                                             16   0%
                                        - if
                                                               5   0%
                                           equal
                                                               3   0%
                                    - or
                                                              10   0%
                                       let
                                                               2   0%
                                       nth
                                                               1   0%
                                     back-to-indentation
                                                              26   0%
                              - python-info-end-of-block-p
                                                            4015  16%
                               - and
                                                            4012  16%
                                - python-info-end-of-statement-p
                                                            4009  16%
                                 - =
                                                            4006  16%
                                  - save-excursion
                                                            3996  16%
                                   - python-nav-end-of-statement
                                                            3988  16%
                                    - let
                                                           3977  16%
                                     - while
                                                            3975  16%
                                      - and
                                                           3971  16%
                                       - cond
                                                           3945  16%
                                        - setq
                                                            2982  12%
                                         -
python-info-line-ends-backslash-p
                1994   8%
                                          - save-excursion
                                                            1990   8%
                                           - while
                                                            1979   8%
                                            - and
                                                           1977   8%
                                             - nth
                                                            1954   8%
                                              - or
                                                            1949   8%
                                               - syntax-ppss
                                                            1931   7%
                                                  #<compiled 0x17508a9>
                                                              1   0%
                                               goto-char
                                                              10   0%
                                               not
                                                               1   0%
                                           - if
                                                              7   0%
                                              equal
                                                              6   0%
                                         - let
                                                             975   4%
                                          - or
                                                             971   3%
                                           - syntax-ppss
                                                             953   3%
                                              #<compiled 0x163ff59>
                                                              2   0%
                                            and
                                                              1   0%
                                        - nth
                                                            958   3%
                                         - or
                                                            955   3%
                                            syntax-ppss
                                                            934   3%
                                       - or
                                                             19   0%
                                          goto-char
                                                             14   0%
                                         not
                                                               1   0%
                              - python-info-beginning-of-statement-p
                                                            1963   8%
                               - =
                                                            1960   8%
                                - save-excursion
                                                            1954   8%
                                 - python-nav-beginning-of-statement
                                                            1949   8%
                                  - let*
                                                            1910   7%
                                     syntax-ppss
                                                             945   3%
                                   - cond
                                                            931   3%
                                    - save-excursion
                                                             922   3%
                                     - python-info-line-ends-backslash-p
                                                             914   3%
                                      - save-excursion
                                                             909   3%
                                       - while
                                                             906   3%
                                        - and
                                                            905   3%
                                         - nth
                                                             884   3%
                                          - or
                                                             881   3%
                                           - syntax-ppss
                                                             864   3%
                                              #<compiled 0x1687431>
                                                              2   0%
                                           goto-char
                                                              13   0%
                                         if
                                                              1   0%
                                   - or
                                                             16   0%
                                    - let
                                                              5   0%
                                       and
                                                               1   0%
                                      nth
                                                              2   0%
                                    back-to-indentation
                                                             30   0%
                             - save-excursion
                                                           7969  32%
                              - cond
                                                            7763  31%
                               - python-info-beginning-of-block-p
                                                           3887  15%
                                - and
                                                           3887  15%
                                 - python-info-statement-starts-block-p
                                                           2870  11%
                                  - save-excursion
                                                            2864  11%
                                   - python-nav-beginning-of-statement
                                                            2847  11%
                                    - let*
                                                            2799  11%
                                     - cond
                                                           1911   7%
                                      - save-excursion
                                                            1904   7%
                                       - python-info-line-ends-backslash-p
                                                            1896   7%
                                        - save-excursion
                                                            1889   7%
                                         - while
                                                            1878   7%
                                          - and
                                                           1876   7%
                                           - nth
                                                            1851   7%
                                            - or
                                                            1846   7%
                                             - syntax-ppss
                                                            1826   7%
                                                #<compiled 0x16c50a9>
                                                              1   0%
                                             goto-char
                                                              21   0%
                                             not
                                                               2   0%
                                         - if
                                                              8   0%
                                            equal
                                                              4   0%
                                       syntax-ppss
                                                             864   3%
                                     - or
                                                              5   0%
                                        let
                                                              4   0%
                                      back-to-indentation
                                                             31   0%
                                 - python-info-beginning-of-statement-p
                                                           1012   4%
                                  - =
                                                           1011   4%
                                   - save-excursion
                                                           1008   4%
                                    - python-nav-beginning-of-statement
                                                           1001   4%
                                     - let*
                                                            950   3%
                                      - syntax-ppss
                                                            873   3%
                                         #<compiled 0x1771691>
                                                               1   0%
                                      - cond
                                                              43   0%
                                       - save-excursion
                                                             36   0%
                                        - python-info-line-ends-backslash-p
                                                             31   0%
                                         - save-excursion
                                                             25   0%
                                          - while
                                                             17   0%
                                           - and
                                                              14   0%
                                              goto-char
                                                              8   0%
                                              not
                                                              1   0%
                                          - if
                                                               3   0%
                                             equal
                                                               2   0%
                                      - or
                                                              11   0%
                                       - let
                                                               4   0%
                                          and
                                                              1   0%
                                         nth
                                                               1   0%
                                       back-to-indentation
                                                              38   0%
                               - python-info-beginning-of-statement-p
                                                           1959   8%
                                - =
                                                           1959   8%
                                 - save-excursion
                                                           1954   8%
                                  - python-nav-beginning-of-statement
                                                           1948   8%
                                   - let*
                                                           1912   7%
                                    - cond
                                                            1014   4%
                                     - save-excursion
                                                           1009   4%
                                      - python-info-line-ends-backslash-p
                                                            999   4%
                                       - save-excursion
                                                            990   4%
                                        - while
                                                            978   4%
                                         - and
                                                             976   4%
                                          - nth
                                                            957   3%
                                           - or
                                                            955   3%
                                              syntax-ppss
                                                            937   3%
                                            goto-char
                                                             11   0%
                                            not
                                                              3   0%
                                        - if
                                                               7   0%
                                           equal
                                                               5   0%
                                    - syntax-ppss
                                                            867   3%
                                       #<compiled 0x16c5751>
                                                               1   0%
                                    - or
                                                               9   0%
                                     - let
                                                               3   0%
                                        and
                                                              1   0%
                                     back-to-indentation
                                                              26   0%
                               - python-info-end-of-block-p
                                                           1905   7%
                                - and
                                                           1904   7%
                                 - python-info-end-of-statement-p
                                                           1901   7%
                                  - =
                                                           1900   7%
                                   - save-excursion
                                                           1891   7%
                                    - python-nav-end-of-statement
                                                           1887   7%
                                     - let
                                                            1881   7%
                                      - while
                                                           1879   7%
                                       - and
                                                            1879   7%
                                        - cond
                                                            1844   7%
                                         - setq
                                                            968   3%
                                          - let
                                                            946   3%
                                           - or
                                                            944   3%
                                              syntax-ppss
                                                            923   3%
                                             and
                                                               1   0%
                                          -
python-info-line-ends-backslash-p
                 14   0%
                                           - save-excursion
                                                             11   0%
                                              while
                                                              5   0%
                                         - nth
                                                             870   3%
                                          - or
                                                             869   3%
                                           - syntax-ppss
                                                             857   3%
                                              #<compiled 0x16bc029>
                                                              1   0%
                                        - or
                                                              26   0%
                                           goto-char
                                                              23   0%
                                          not
                                                              1   0%
                              - if
                                                             194   0%
                               - python-nav--lisp-forward-sexp
                                                             189   0%
                                - let
                                                            171   0%
                                   forward-sexp
                                                            150   0%
                                 - if
                                                              7   0%
                                    or
                                                               3   0%
                             - if
                                                           1969   8%
                              - cond
                                                            1965   8%
                               - python-nav-beginning-of-statement
                                                            1878   7%
                                - let*
                                                            1842   7%
                                 - cond
                                                            947   3%
                                  - save-excursion
                                                             942   3%
                                   - python-info-line-ends-backslash-p
                                                             934   3%
                                    - save-excursion
                                                             930   3%
                                     - while
                                                             925   3%
                                      - and
                                                            925   3%
                                       - nth
                                                             910   3%
                                        - or
                                                             907   3%
                                         - syntax-ppss
                                                             889   3%
                                            #<compiled 0x156fe99>
                                                              1   0%
                                         goto-char
                                                               9   0%
                                         not
                                                               1   0%
                                       if
                                                              1   0%
                                 - syntax-ppss
                                                             870   3%
                                    #<compiled 0x163e3e9>
                                                              1   0%
                                 - or
                                                             12   0%
                                  - let
                                                              4   0%
                                     and
                                                               1   0%
                                    nth
                                                              3   0%
                                  back-to-indentation
                                                             26   0%
                               - and
                                                              66   0%
                                - python-info-current-line-empty-p
                                                              54   0%
                                 - save-excursion
                                                             49   0%
                                  - string-equal
                                                               3   0%
                                     match-string-no-properties
                                                              1   0%
                                 eq
                                                              5   0%
                            - and
                                                             33   0%
                             - or
                                                             32   0%
                              - if
                                                              30   0%
                               - eq
                                                             26   0%
                                - syntax-class
                                                              16   0%
                                 - syntax-after
                                                              7   0%
                                    1-
                                                               2   0%
                                  car
                                                              4   0%
                              memq
                                                               2   0%
                           - python-syntax-context-type
                                                            953   3%
                            - let
                                                            944   3%
                             - or
                                                            931   3%
                              - syntax-ppss
                                                            909   3%
                                 #<compiled 0x172d4c5>
                                                               2   0%
                               cond
                                                              5   0%
                           - if
                                                              8   0%
                              and
                                                              1   0%
                           setq
                                                              1   0%
                          setq
                                                               2   0%
                       - or
                                                             20   0%
                        - setq
                                                              20   0%
                         - memq
                                                             11   0%
                            list
                                                               4   0%
                        or
                                                               2   0%
                     - and
                                                              81   0%
                        looking-at-p
                                                              39   0%
                        =
                                                             23   0%
                      - prog1
                                                              6   0%
                         not
                                                               4   0%
                      setq
                                                               1   0%
                 - not
                                                              76   0%
                  - python-info-assignment-statement-p
                                                              75   0%
                   - save-excursion
                                                             75   0%
                    - let
                                                             74   0%
                     - if
                                                             64   0%
                      - python-nav-beginning-of-statement
                                                             64   0%
                       - let*
                                                             61   0%
                        - cond
                                                              34   0%
                         - save-excursion
                                                             34   0%
                          - python-info-line-ends-backslash-p
                                                             34   0%
                           - save-excursion
                                                             34   0%
                            - while
                                                             34   0%
                             - and
                                                              34   0%
                              - nth
                                                             34   0%
                               - or
                                                             34   0%
                                  syntax-ppss
                                                             33   0%
                          syntax-ppss
                                                             25   0%
                         back-to-indentation
                                                               2   0%
                     - while
                                                               9   0%
                        and
                                                              9   0%
              - python-nav-beginning-of-statement
                                                             78   0%
               - let*
                                                             77   0%
                  syntax-ppss
                                                             38   0%
                - cond
                                                              37   0%
                 - save-excursion
                                                             37   0%
                  - python-info-line-ends-backslash-p
                                                             37   0%
                   - save-excursion
                                                             36   0%
                    - while
                                                             36   0%
                     - and
                                                              36   0%
                      - nth
                                                             36   0%
                       - or
                                                             36   0%
                          syntax-ppss
                                                             36   0%
                - or
                                                               1   0%
                   let
                                                               1   0%
         - syntax-propertize
                                                              85   0%
          - #<lambda 0x317b158c9689>
                                                              84   0%
           - while
                                                              84   0%
            - cond
                                                              81   0%
             - python-syntax-stringify
                                                              81   0%
              - let*
                                                              79   0%
               - prog2
                                                              76   0%
                  syntax-ppss
                                                             76   0%
               - and
                                                               1   0%
                - python-syntax-count-quotes
                                                               1   0%
                 - let
                                                               1   0%
                  - while
                                                              1   0%
                     and
                                                               1   0%
                 cond
                                                              1   0%
              and
                                                              3   0%
           syntax-ppss
                                                               7   0%
         - replace-regexp-in-string
                                                              1   0%
            #<compiled 0x25de21>
                                                               1   0%
        - font-lock-fontify-keywords-region
                                                             32   0%
         - #<lambda 0x317b2112709>
                                                               9   0%
          - let
                                                              9   0%
           - while
                                                               9   0%
            - and
                                                              9   0%
               setq
                                                              9   0%
         - #<lambda 0x317b2112709>
                                                               4   0%
          - let
                                                              4   0%
           - while
                                                               4   0%
            - and
                                                              4   0%
               setq
                                                              4   0%
 + #<compiled 0x486c29>
                                                              6   0%
 + eval
                                                              5   0%
 + tool-bar-make-keymap
                                                              2   0%
   kill-this-buffer-enabled-p
                                                              1   0%