Subject: Re: 31.0.50; Severe performance issue with Tramp and project-mode-line-format

From: Michael Albinus <[email-masked]>
Date: Wed, 09 Oct 2024 15:12:00 +0200

Ergus <[email-masked]> writes:

> Hi Dmitry and Michael:

Hi Ergus,

> I enabled the project-mode-line recently and now when I try to open a
> remote file emacs seems frozen forever (minutes in a not so bad
> connection).
>
> I made a profile and it looks like there is some bad interaction between
> project-mode-line and tramp names
>
> The profile report:
>
> 15458  75% - redisplay_internal (C function)
> 15442  75%  - eval
> 15442  75%   - project-mode-line-format
> 15442  75%    - project-current
> 15442  75%     - project--find-in-directory
> 15442  75%      - run-hook-with-args-until-success
> 15442  75%       - project-try-vc
> 15442  75%        - project--value-in-dir
> 15442  75%         - hack-dir-local-variables
> 15442  75%          - #<byte-code-function 8FF>
> 15442  75%           - hack-dir-local--get-variables
> 15442  75%            - dir-locals-find-file
> 14648  71%             - locate-dominating-file
> 14644  71%              - abbreviate-file-name
> 14644  71%               - tramp-file-name-handler
> 14637  71%                - apply
> 14637  71%                 - tramp-sh-file-name-handler
> 14611  71%                  - tramp-handle-insert-file-contents
> 14611  71%                   - file-local-copy
> 14611  71%                    - tramp-file-name-handler
> 14611  71%                     - apply
> 14611  71%                      - tramp-sh-file-name-handler
> 14611  71%                       - tramp-sh-handle-file-local-copy
> 14611  71%                        - tramp-barf-unless-okay
> 14611  71%                         - tramp-send-command-and-check
> 14611  71%                          - tramp-send-command
> 14611  71%                           - tramp-wait-for-output
> 14611  71%                            - tramp-wait-for-regexp
> 14611  71%                             - sit-for
> 14611  71%                              - redisplay_internal (C function)
> 14574  71%                               - eval
> 14574  71%                                - project-mode-line-format

This is unfortune. sit-for should not trigger a redisplay. Does the
appended patch in tramp.el helps?

Best regards, Michael.

> At the moment I disabled the project-mode-line. However There may be
> a better solutions for this issue.
>
> Best,
> Ergus

Best regards, Michael.

diff --git a/lisp/tramp.el b/lisp/tramp.el
index 4ce44119..181bba01 100644
--- a/lisp/tramp.el
+++ b/lisp/tramp.el
@@ -6049,7 +6049,7 @@ nil."
     (with-tramp-timeout (timeout)
       (while (not found)
 	;; This is needed to yield the CPU, otherwise we'll see 100% CPU load.
-	(sit-for 0)
+	(sit-for 0 'nodisp)
 	(tramp-accept-process-output proc)
 	(unless (process-live-p proc)
 	  (tramp-error-with-buffer