Subject: Re: bug#61942: 28.2; uninterruptible hang in vc-diff buffer

From: Dmitry Gutov <[email-masked]>
Date: Mon, 17 Jun 2024 04:15:00 +0300

Hi!

Late reply here.

On 03/03/2023 20:13, Tom Tromey wrote:
> From*vc-outgoing*, I used '=' to see a diff.
> 
> The diff in question is pretty large.
> 
> Emacs showed this in the echo area:
> 
> Finding changes in ....
> 
> This was not interruptible -- I tried C-g, C-], and 'kill -USR1'
> 
> I don't know exactly what this is doing, but whatever it is should be
> interruptible.

I've been doing some performance debugging for vc-diff, and the same 
thing has happened once when c-ts-mode was associated with *.c files.

That time I also turned off the cache for diff's revision syntax 
highlighting and repeated a 'vc-diff' for one revision several times.

Profiling this scenario gets me to

         7940  85%             - diff--get-revision-properties
         7940  85%              - let*
         5637  61%               - if
         5637  61%                - condition-case
         5637  61%                 - vc-find-revision-no-save
         5622  60%                  - decode-coding-inserted-region
            3   0%                   - set-auto-coding
            3   0%                    - find-auto-coding
            3   0%                     + set-auto-mode-1
           12   0%                  + set-auto-mode
            3   0%                  + vc-call-backend

and if we're talking about tree-sitter based modes, it might be due to 
memory usage (or not).

Anyway, if you're seeing this regularly

   (setq diff-font-lock-syntax 'hunk-only)

should help as a workaround.