Subject: bug#25682: 25.1; font-lock: fontifying too slow in some modes on very long lines

From: Eli Zaretskii <[email-masked]>
Date: Thu, 31 Oct 2019 19:26:23 +0200

> From: Lars Ingebrigtsen <[email-masked]>
> Date: Thu, 31 Oct 2019 18:07:53 +0100
> Cc: [email-masked]
> 
> > 1. put the single long line under the === below (18572 chars long) into a file
> > 2. run emacs -Q
> > 3. type C-x C-f <filename> RET to open the file
> > 4. type M-x compilation-mode RET
> >
> > this consistently hangs emacs for 9-10s for me on modern hardware, a 2014
> > retina macbook pro.
> 
> The example was corrupted in transit (line-folded), so I've included a
> fixed-up version as an attachment here.

The profile is below.

> Running M-x compilation-mode takes about five seconds for me, but this
> laptop is pretty fast.

Yours is an optimized build, right?

- ...                                                            3375  98%
 - compilation--ensure-parse                                     3362  98%
  - save-excursion                                               3362  98%
   - if                                                          3362  98%
    - progn                                                      3362  98%
     - let                                                       3362  98%
      - let*                                                     3362  98%
       - unwind-protect                                          3362  98%
        - progn                                                  3362  98%
         - compilation--parse-region                             3362  98%
          - if                                                   3362  98%
           - compilation-parse-errors                            3362  98%
            - let                                                3362  98%
             - while                                             3362  98%
              - let                                              3362  98%
               - let                                             3362  98%
                  while                                          3362  98%
   Automatic GC                                                    13   0%
- command-execute                                                  50   1%
 - call-interactively                                              50   1%
  - funcall-interactively                                          48   1%
   - execute-extended-command                                      48   1%
    - execute-extended-command--shorter                            45   1%
     - completion-try-completion                                   45   1%
      - completion--nth-completion                                 45   1%
       - completion--some                                          45   1%
        - #<compiled -0x1ffffffff85d3920>                          45   1%
         - completion-pcm-try-completion                           28   0%
          - completion-pcm--find-all-completions                   26   0%
             completion-pcm--all-completions                       26   0%
          - completion-pcm--merge-try                               2   0%
             completion-pcm--merge-completions                      1   0%
           completion-basic-try-completion                         17   0%
    - command-execute                                               1   0%
     - call-interactively                                           1   0%
      - funcall-interactively                                       1   0%
       - compilation-mode                                           1   0%
        - run-mode-hooks                                            1   0%
         - hack-local-variables                                     1   0%
          - hack-dir-local-variables                                1   0%
           - dir-locals-find-file                                   1   0%
            - locate-dominating-file                                1   0%
               dir-locals--all-files                                1   0%
    - sit-for                                                       1   0%
       redisplay                                                    1   0%
  - byte-code                                                       2   0%
   - read-extended-command                                          2   0%
    - completing-read                                               2   0%
     - completing-read-default                                      2   0%
        read-from-minibuffer                                        2   0%