Subject: Re: bug#73046: 29.4; Emacs 100% CPU usage for several seconds when opening dired buffer over TRAMP

From: Michael Albinus <[email-masked]>
Date: Wed, 11 Sep 2024 16:06:46 +0200

Michael Albinus <[email-masked]> writes:

Hi Eli,

> I made a test. In a remote directory I have created a cyclic symlink
> "zzz", in order to see what Tramp does when running dired on the
> directory. The additional actions are

[...]

> 15 times the "test -h" command - I guess, Tramp shall do cyclic link
> detection better.

I've analyzed the case in detail. Tracing file-truename and
tramp-sh-handle-file-truename.

--8<---------------cut here---------------start------------->8---
======================================================================
1 -> (file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 -> (tramp-sh-handle-file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 <- tramp-sh-handle-file-truename: !non-local\ exit!
1 <- file-truename: !non-local\ exit!
======================================================================
1 -> (file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 -> (tramp-sh-handle-file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 <- tramp-sh-handle-file-truename: !non-local\ exit!
1 <- file-truename: !non-local\ exit!
======================================================================
1 -> (file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 -> (tramp-sh-handle-file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 <- tramp-sh-handle-file-truename: !non-local\ exit!
1 <- file-truename: !non-local\ exit!
======================================================================
1 -> (file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 -> (tramp-sh-handle-file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 <- tramp-sh-handle-file-truename: !non-local\ exit!
1 <- file-truename: !non-local\ exit!
======================================================================
1 -> (file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 -> (tramp-sh-handle-file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 <- tramp-sh-handle-file-truename: !non-local\ exit!
1 <- file-truename: !non-local\ exit!
======================================================================
1 -> (file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 -> (tramp-sh-handle-file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 <- tramp-sh-handle-file-truename: !non-local\ exit!
1 <- file-truename: !non-local\ exit!
======================================================================
1 -> (file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 -> (tramp-sh-handle-file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 <- tramp-sh-handle-file-truename: !non-local\ exit!
1 <- file-truename: !non-local\ exit!
======================================================================
1 -> (file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 -> (tramp-sh-handle-file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 <- tramp-sh-handle-file-truename: !non-local\ exit!
1 <- file-truename: !non-local\ exit!
======================================================================
1 -> (file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 -> (tramp-sh-handle-file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 <- tramp-sh-handle-file-truename: !non-local\ exit!
1 <- file-truename: !non-local\ exit!
======================================================================
1 -> (file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 -> (tramp-sh-handle-file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 <- tramp-sh-handle-file-truename: !non-local\ exit!
1 <- file-truename: !non-local\ exit!
======================================================================
1 -> (file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 -> (tramp-sh-handle-file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 <- tramp-sh-handle-file-truename: !non-local\ exit!
1 <- file-truename: !non-local\ exit!
======================================================================
1 -> (file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 -> (tramp-sh-handle-file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 <- tramp-sh-handle-file-truename: !non-local\ exit!
1 <- file-truename: !non-local\ exit!
======================================================================
1 -> (file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 -> (tramp-sh-handle-file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 <- tramp-sh-handle-file-truename: !non-local\ exit!
1 <- file-truename: !non-local\ exit!
======================================================================
1 -> (file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 -> (tramp-sh-handle-file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 <- tramp-sh-handle-file-truename: !non-local\ exit!
1 <- file-truename: !non-local\ exit!
======================================================================
1 -> (file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 -> (tramp-sh-handle-file-truename "/ssh:gandalf:~/tmp/zzz")
| 2 <- tramp-sh-handle-file-truename: !non-local\ exit!
1 <- file-truename: !non-local\ exit!
--8<---------------cut here---------------end--------------->8---

15 calls of file-truename (dired fontification), with 1 call of
tramp-sh-handle-file-truename each time. That sounds proper.

Tramp doesn't cache erroneous results, so it doesn't remember the
truename of "/ssh:gandalf:~/tmp/zzz". That's it, we can live with it I
guess.

Best regards, Michael.