Subject: Re: bug#33887: 26.1; Emacs hangs for several seconds when going to the end of an XML file in nXML mode

From: Eli Zaretskii <[email-masked]>
Date: Thu, 27 Dec 2018 18:02:07 +0200

> From: Vincent Lefevre <[email-masked]>
> Date: Thu, 27 Dec 2018 11:13:06 +0100
> 
> When I open a large XML file and immediately go to the end of the
> file with '<ESC> >', Emacs hangs for several seconds. For instance,
> on /usr/share/xml/iso-codes/iso_639-3.xml from iso-codes in Debian
> (a 1-MB file), it takes 5 seconds. On a 4-MB personal XML file, it
> takes 15 seconds.
> 
> This is a regression: Emacs 25 did not hang at all.

Confirmed, thanks.

The profile (see below) blames syntax-ppss called by
sgml-syntax-propertize, so I suspect commit 0055190, which added
sgml-syntax-propertize-inside to sgml-syntax-propertize.

CC'ing Stefan who made those changes.

Here's the profile:

  - command-execute                                                 532  77%
   - call-interactively                                             532  77%
    - funcall-interactively                                         522  75%
     - end-of-buffer                                                500  72%
      - recenter                                                    496  71%
       - jit-lock-function                                          496  71%
	- jit-lock-fontify-now                                      496  71%
	 - jit-lock--run-functions                                  496  71%
	  - run-hook-wrapped                                        496  71%
	   - #<compiled 0x200000000b3a7fd0>                         496  71%
	    - font-lock-fontify-region                              496  71%
	     - font-lock-default-fontify-region                     496  71%
	      - nxml-extend-region                                  496  71%
	       - skip-syntax-forward                                496  71%
		- internal--syntax-propertize                       496  71%
		 - syntax-propertize                                496  71%
		  - sgml-syntax-propertize                          490  71%
		     syntax-ppss                                    445  64%
	push-mark                                                     1   0%
     - find-file                                                     20   2%
      - find-file-noselect                                           20   2%
       - find-file-noselect-1                                        19   2%
	- after-find-file                                            17   2%
	 - normal-mode                                               17   2%
	  - set-auto-mode                                            17   2%
	   - set-auto-mode-0                                         17   2%
	    - xml-mode                                               17   2%
	     - byte-code                                             14   2%
	      - require                                              12   1%
	       - byte-code                                           11   1%
		- require                                            10   1%
		 - byte-code                                          9   1%
		  - require                                           6   0%
		   - byte-code                                        6   0%
		    - cl-generic-define-method                        4   0%
		     - cl--generic-make-function                      4   0%
		      - cl--generic-make-next-function                  4   0%
		       - cl--generic-get-dispatcher                   4   0%
			- byte-compile                                3   0%
			   byte-code                                  1   0%
			 - #<compiled 0x200000000b325048>                  1   0%
			    byte-compile-top-level                    1   0%
		  - custom-declare-variable                           1   0%
		   - custom-initialize-reset                          1   0%
		    - eval                                            1   0%
		     - funcall                                        1   0%
		      - #<compiled 0x200000000b3c88b8>                  1   0%
		       - executable-find                              1   0%
			  locate-file                                 1   0%
		 file-truename                                        1   0%
	     - rng-nxml-mode-init                                     2   0%
	      - rng-validate-mode                                     2   0%
	       - rng-auto-set-schema                                  2   0%
		- rng-locate-schema-file                              2   0%
		 - rng-locate-schema-file-using                       2   0%
		  - rng-get-parsed-schema-locating-file                  2   0%
		   - rng-parse-schema-locating-file                   1   0%
		    - rng-parse-validate-file                         1   0%
		     - nxml-parse-instance                            1   0%
			nxml-parse-instance-1                         1   0%
	     - file-truename                                          1   0%
	      - file-truename                                         1   0%
	       - file-truename                                        1   0%
		  file-truename                                       1   0%
	- insert-file-contents                                        1   0%
	   xml-find-file-coding-system                                1   0%
     - execute-extended-command                                       1   0%
      - sit-for                                                       1   0%
	 redisplay                                                    1   0%
     - minibuffer-complete                                            1   0%
      - completion-in-region                                          1   0%
       - completion--in-region                                        1   0%
	- #<compiled 0x2000000001b04c20>                              1   0%
	 - apply                                                      1   0%
	  - #<compiled 0x20000000013baac8>                            1   0%
	   - completion--in-region-1                                  1   0%
	    - completion--do-completion                               1   0%
	     - completion-try-completion                              1   0%
	      - completion--nth-completion                            1   0%
	       - completion--some                                     1   0%
		- #<compiled 0x2000000001b0bd20>                      1   0%
		 - completion-basic-try-completion                    1   0%
		  - try-completion                                    1   0%
		     completion-file-name-table                       1   0%
    - byte-code                                                      10   1%
     - read-extended-command                                          9   1%
      - completing-read                                               9   1%
       - completing-read-default                                      9   1%
	  read-from-minibuffer                                        9   1%
     - find-file-read-args                                            1   0%
      - read-file-name                                                1   0%
       - read-file-name-default                                       1   0%
	- completing-read                                             1   0%
	 - completing-read-default                                    1   0%
	  - read-from-minibuffer                                      1   0%
	   - redisplay_internal (C function)                          1   0%
	      find-image                                              1   0%
  - ...                                                             158  22%
     Automatic GC                                                   156  22%
   - macroexp--all-forms                                              1   0%
    - macroexp--expand-all                                            1   0%
     - #<compiled 0x2000000001375130>                                 1   0%
      - macroexp--all-forms                                           1   0%
       - macroexp--expand-all                                         1   0%
	- macroexp--all-forms                                         1   0%
	 - macroexp--expand-all                                       1   0%
	  - #<compiled 0x2000000001375130>                            1   0%
	   - macroexp--all-forms                                      1   0%
	    - macroexp--expand-all                                    1   0%
	     - #<compiled 0x2000000001375068>                         1   0%
	      - macroexp--all-forms                                   1   0%
	       - macroexp--expand-all                                 1   0%
		- macroexp-macroexpand                                1   0%
		 - macroexpand                                        1   0%
		    #<compiled 0x20000000013f0600>                    1   0%
   - rng-compute-start-tag-open-deriv                                 1   0%
    - rng-element-get-child                                           1   0%
     - rng-compile                                                    1   0%
      - apply                                                         1   0%
       - rng-compile-group                                            1   0%
	- mapcar                                                      1   0%
	 - rng-compile                                                1   0%
	  - apply                                                     1   0%
	   - rng-compile-attribute                                    1   0%
	    - rng-compile                                             1   0%
	     - apply                                                  1   0%
	      - rng-compile-ref                                       1   0%
	       - rng-compile                                          1   0%
		- apply                                               1   0%
		 - rng-compile-data                                   1   0%
		    rng-compile-dt                                    1   0%