[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Patch: use GNU readlink --canonicalize for file-truename when availa
From: |
Michael Albinus |
Subject: |
Re: Patch: use GNU readlink --canonicalize for file-truename when available |
Date: |
Thu, 06 Aug 2009 16:42:51 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
Julian Scheid <address@hidden> writes:
> tramp-handle-file-truename's current logic will lead to a series of
> "test -e" and "stat" calls on the remote host, one each for every
> component of the path (in the simple case of a path that does not use
> any symlinks, probably more for heavily symlinked paths.)
>
> This can pose a significant overhead on slow connections especially
> for deeply nested files.
>
> The attached patch will try to use GNU readlink's --canonicalize
> feature to do the same in a single remote call instead, regardless of
> the file's nesting level. See readlink(1).
>
> GNU readlink is not available on all platforms. For instance, Mac OS
> X's readlink is not GNU and does not provide the --canonicalize flag.
> However, on remote hosts where it is available, such as Linux hosts,
> this should speed things up considerably. On other hosts this will
> fall back to the current logic.
>
> Caveats:
>
> This might need better error handling for the case where readlink fails.
>
> It should also be verified that this has indeed the same semantics as
> file-truename. Since neither file-truename's nor GNU readlink's
> behaviour is documented precisely this is unfortunately not easy to
> do. Superficially they both appear to do the same thing, though.
AFAICS, they are equivalent. Unless proven otherwise, I'll assume it
from now :-)
> Newer versions of GNU readlink appear to offer --canonicalize-existing
> and --canonicalize-missing flags. My test system does not have these.
> It is not entirely clear to me whether these might be preferable when
> available. See http://linux.die.net/man/1/readlink
--canonicalize-existing might be even closer to the existing
file-truename logic. But I believe, --canonicalize is a good aproximation.
> Note that for hosts that don't have GNU readlink things might be
> optimized further by doing canonicalization in a single remote call
> using a remote script such as
> http://codesnippets.joyent.com/posts/show/2049 , or maybe something
This could be on the list of possible optimizations ... OTOH, it might
raise legal issues, because the code is not copylefted.
> like "python -c "import os; print(os.path.realpath('%s'))" where a
> Python interpreter is available (Macs usually have a working one.)
Hmm. We have already dependencies on Perl. Another one from Python - I
fear, that initial checks for existence of several programs on the
remote host will grow and grow.
Thanks for the patch, I have committed it to Tramp's CVS. (Please
provide also a ChangeLog entry next time)
Best regards, Michael.
- Patch: use GNU readlink --canonicalize for file-truename when available, Julian Scheid, 2009/08/05
- Re: Patch: use GNU readlink --canonicalize for file-truename when available,
Michael Albinus <=
- Re: Patch: use GNU readlink --canonicalize for file-truename when available, yary, 2009/08/06
- Message not available
- Message not available
- Re: Patch: use GNU readlink --canonicalize for file-truename when available, Michael Albinus, 2009/08/14
- Re: Patch: use GNU readlink --canonicalize for file-truename when available, Julian Scheid, 2009/08/14
- Re: Patch: use GNU readlink --canonicalize for file-truename when available, Julian Scheid, 2009/08/14
- Re: Patch: use GNU readlink --canonicalize for file-truename when available, Michael Albinus, 2009/08/14