Subject: bug#26525: `sit-for' in Flyspell slows typing down, hogs 90% of CPU

From: Nick H <[email-masked]>
Date: Thu, 03 Sep 2020 11:15:50 +1200

> I'm marking this bug as unreproducible for now.  Please report back
> if you see this again or can provide any more information.

I just bumped into this bug on 27.1 with the same symptoms - typing lag
after activating flyspell-mode. 

I took a couple of profiles - the first when lag was apparent and
another after clearing the lag by toggling flyspell-mode.

Both profiles show a similar result, so the "high cpu" in sit-for might
be a red-herring.

Profile 1 - with lag
  - flyspell-post-command-hook                     1146  92%
   - flyspell-check-word-p                         1120  90%
    - sit-for                                      1117  90%
     - redisplay                                    551  44%
      + redisplay_internal (C function)               1   0%
       read-event                                   390  31%
    - flyspell-get-not-casechars                      1   0%
       ispell-get-decoded-string                      1   0%
   + flyspell-word                                    8   0%
   + flyspell-check-pre-word-p                        3   0%
  + command-execute                                  65   5%
  + ...                                              22   1%
  + undo-auto--add-boundary                           1   0%

Profile 2 - without lag
  - flyspell-post-command-hook                     3507  94%
   - flyspell-check-word-p                         3432  92%
    - sit-for                                      3414  92%
     - redisplay                                   1660  44%
      + redisplay_internal (C function)               3   0%
     + read-event                                  1317  35%
    + ispell-get-otherchars                           6   0%
    + flyspell-get-not-casechars                      5   0%
   + flyspell-word                                   17   0%
   + flyspell-check-pre-word-p                       13   0%
  + command-execute                                  93   2%
  + ...                                              87   2%
  + timer-event-handler                               3   0%
    undo-auto--add-boundary                           2   0%
    tooltip-hide                                      1   0%

Nick