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

From: Eli Zaretskii <[email-masked]>
Date: Fri, 14 Feb 2020 15:50:33 +0200

> 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%