Subject: Re: bug#72977: 28.2; DOS in Shell-script mode

From: Eli Zaretskii <[email-masked]>
Date: Mon, 02 Sep 2024 20:30:16 +0300

> From: Chris Moore <[email-masked]>
> Date: Mon, 2 Sep 2024 12:35:18 -0300
> 
> I've been seeing Emacs hang up repeatedly for no apparent reason recently while editing shell scripts. I spent
> the time to isolate the issue. It turns out that I can reproduce the issue by opening a new shell script file and
> typing the word "in" 20 or 30 times on a single line:
> 
> $ emacs -Q
> C-x C-f /tmp/x.sh
> echo in in in in in in in in in in in in in in in in in in in in in in in in in in in in in in
> 
> After about 20 'in's, things slow down noticeably, and I can't get to 30 without it hanging.

The profile is below.  Maybe Stefan (CC'ed) has some comments or
suggestions.

       36361  58% - timer-event-handler
       36361  58%  - apply
       36361  58%   - show-paren-function
       36361  58%    - #<advice 1DA>
       36361  58%     - apply
       36361  58%      - smie--matching-block-data
       36359  58%       - smie--opener/closer-at-point
       36068  57%        - sh-smie-sh-forward-token
       23841  38%         - sh-smie--sh-keyword-p
       23841  38%          - sh-smie--sh-keyword-in/do-p
       23841  38%           - sh-smie-sh-backward-token
       23837  38%            - sh-smie--sh-keyword-p
       23837  38%             - sh-smie--sh-keyword-in/do-p
       23837  38%              - sh-smie-sh-backward-token
       23805  38%               - sh-smie--sh-keyword-p
       23801  38%                - sh-smie--sh-keyword-in/do-p
       23793  38%                 - sh-smie-sh-backward-token
       23685  38%                  - sh-smie--sh-keyword-p
       23681  38%                   - sh-smie--sh-keyword-in/do-p
       23665  37%                    - sh-smie-sh-backward-token
       23425  37%                     - sh-smie--sh-keyword-p
       23409  37%                      - sh-smie--sh-keyword-in/do-p
       23349  37%                       - sh-smie-sh-backward-token
       13623  21%                          looking-back
        6152   9%                          sh-smie--default-backward-token
        3368   5%                        - sh-smie--sh-keyword-p
        1655   2%                           sh-smie--sh-keyword-in/do-p
          28   0%                         assoc
         136   0%                       looking-back
          44   0%                       sh-smie--default-backward-token
           8   0%                      assoc
          64   0%                    looking-back
          20   0%                    sh-smie--default-backward-token
           4   0%                   assoc
          16   0%                 sh-smie--default-backward-token
           8   0%                 looking-back
           4   0%              sh-smie--default-backward-token
       12227  19%         - sh-smie--newline-semi-p
       12227  19%          - sh-smie-sh-backward-token
       12227  19%           - sh-smie--sh-keyword-p
       12227  19%            - sh-smie--sh-keyword-in/do-p
       12227  19%             - sh-smie-sh-backward-token
       12227  19%              - sh-smie--sh-keyword-p
       12227  19%               - sh-smie--sh-keyword-in/do-p
       12227  19%                - sh-smie-sh-backward-token
       12223  19%                 - sh-smie--sh-keyword-p
       12223  19%                  - sh-smie--sh-keyword-in/do-p
       12223  19%                   - sh-smie-sh-backward-token
       12203  19%                    - sh-smie--sh-keyword-p
       12203  19%                     - sh-smie--sh-keyword-in/do-p
       12199  19%                      - sh-smie-sh-backward-token
       12143  19%                       - sh-smie--sh-keyword-p
       12143  19%                        - sh-smie--sh-keyword-in/do-p
       10012  16%                           sh-smie-sh-backward-token
        2119   3%                           assoc
          36   0%                         looking-back
 [...]
       25633  41%   Automatic GC