emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master 3e4d4f472d: Rework `abbreviate-file-name' in Tramp


From: Michael Albinus
Subject: Re: master 3e4d4f472d: Rework `abbreviate-file-name' in Tramp
Date: Tue, 08 Mar 2022 10:16:05 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Jim Porter <jporterbugs@gmail.com> writes:

Hi Jim,

> I don't know how much this matters in practice, but one benefit of the
> old code is that it cached the *abbreviated* home directory (though I
> gave it a poor name; "home-directory" didn't indicate that it's
> abbreviated). This can significantly improve performance when there
> are many entries in `directory-abbrev-alist', since then Tramp doesn't
> have to abbreviate the home-dir on each call. That's similar to how
> `abbreviate-file-name' works on local files, which also caches the
> abbreviated home dir.

I don't know how relevant it is in practice, but if you believe it is
relevant I don't object to apply such a patch. The reason for my rework
was to fold out handling of home directory from the different
expand-file-name implementations, it didn't work in different backends
(tramp-gvfs.el, tramp-sudoedit.el), or it wasn't implemented at all
(tramp-smb.el). So I've introduced the new internal magic file name
operation tramp-get-home-directory, which has different implementations
in different backends.

> See the attached benchmark/results. I also attached a sketch of a
> patch for a way to avoid that performance cost. I'm not sure it's
> actually a good way to do things (or even if it's correct in all
> cases), but hopefully it serves as a demonstration. It would probably
> be better to cache it somewhere that doesn't persist across sessions
> though[1]; it could get out of sync with `directory-abbrev-alist' and
> cause problems (this was a problem with the old code too).

Tramp is prepared :-) See the comment at the beginning of
tramp-cache.el: if you use the connection process as cache key, it isn't
saved persistently. You need to do something like

--8<---------------cut here---------------start------------->8---
(with-tramp-connection-property (tramp-connection-process vec) 
"abbr-home-directory"
--8<---------------cut here---------------end--------------->8---

> - Jim

Best regards, Michael.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]