Subject: Re: bug#22090: Isearch is sluggish and eventually refuses further service with "[Too many words]".

From: Eli Zaretskii <[email-masked]>
Date: Fri, 04 Dec 2015 11:23:43 +0200

> Date: Fri, 4 Dec 2015 04:20:52 +0000
> From: Alan Mackenzie <[email-masked]>
> 
> With a recent emacs-25 (last update
> eaa1fd6dbff8346eb38485de5ebf0fbfacf374d9 from Thursday 2015-12-03):
> 
> emacs -Q
> C-c C-f src/xdisp.c
> Move point to L30 (paragraph beginning "Updating the display is triggered
>   by the Lisp interpreter ...")
> 
> C-s
> C-w repeatedly, to yank words onto the search string.
> 
> After ~29 words have been yanked, the response becomes sluggish, pausing
> for between 0.5s and 1s before highlighting the "for" at the end of L31.
> 
> Carrying on with C-w, some words are taking 2 or 3 seconds to be
> registered by Isearch.  This is Bad.

Here's a profile for this part:

 - command-execute                                                1762  99%
  - call-interactively                                            1762  99%
   - funcall-interactively                                        1762  99%
    - isearch-yank-word-or-char                                   1760  99%
     - isearch-yank-internal                                      1760  99%
      - isearch-yank-string                                       1760  99%
       - isearch-process-search-string                            1760  99%
	- isearch-search-and-update                               1760  99%
	 - isearch-update                                         1760  99%
	  - if                                                    1760  99%
	   - progn                                                1760  99%
	    - while                                               1757  99%
	     - let                                                1757  99%
	      - isearch-lazy-highlight-search                     1757  99%
	       - condition-case                                   1757  99%
		- let                                             1757  99%
		 - while                                          1757  99%
		  - setq                                          1757  99%
		   - isearch-search-string                        1757  99%
		    - let*                                        1757  99%
		     - save-excursion                             1757  99%
		      - funcall                                   1757  99%
		       - #<lambda 0x2f020ea27a40>                 1757  99%
			- let                                     1757  99%
			 - condition-case                         1757  99%
			  - funcall                               1757  99%
			   - cond                                    7   0%
			    - let                                    7   0%
			     - if                                    7   0%
			      - funcall                              7   0%
				 character-fold-to-regexp                  7   0%
	    - isearch-lazy-highlight-new-loop                        2   0%
	     - if                                                    2   0%
	      - and                                                  2   0%
	       - sit-for                                             2   0%
		  redisplay                                          2   0%
	    - if                                                     1   0%
	     - if                                                    1   0%
	      - isearch-message                                      1   0%
	       - let                                                 1   0%
		- if                                                 1   0%
		   let                                               1   0%
    - isearch-forward                                                1   0%
     - isearch-mode                                                  1   0%
      - isearch-update                                               1   0%
       - if                                                          1   0%
	- progn                                                      1   0%
	 - isearch-lazy-highlight-new-loop                           1   0%
	  - if                                                       1   0%
	   - and                                                     1   0%
	    - sit-for                                                1   0%
	     - redisplay                                             1   0%
	      - redisplay_internal (C function)                      1   0%
	       - find-image                                          1   0%
		  image-search-load-path                             1   0%
    - execute-extended-command                                       1   0%
     - command-execute                                               1   0%
      - call-interactively                                           1   0%
       - funcall-interactively                                       1   0%
	- profiler-report                                            1   0%
	 - profiler-report-cpu                                       1   0%
	    profiler-cpu-profile                                     1   0%
 - ...                                                               5   0%
    Automatic GC                                                     5   0%