tramp-devel
[Top][All Lists]
Advanced

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

vc-registered optimization


From: Julian Scheid
Subject: vc-registered optimization
Date: Sun, 2 Aug 2009 19:02:58 +1200

Hi there,

I've upgraded to Emacs 23.1 yesterday and found that tramp - which I
use for the majority of my editing - had become comically slow. A
find-file that previously took somewhere around 4 seconds suddenly
took 16.

At first I thought I ran into the same problem as David Abrahams - the
process timeout issue - but reducing the timeouts didn't help.

So I started investigating and it appears that Emacs 23.1 ships with
support for a number of version control backends that will lead to a
large number of file-exists-p and some file-readable-p operations.
Notably, git, mercurial, bazaar, monotone and arch backends will all
look for their respective sub-directories (.git, .hg, .bzr, _MTN and
{arch}) in the directory containing the opened file and, if not found,
iteratively in all parent directories. So when opening a file that's
not under version control in nesting level 10, these backends alone
will cause 10 times 5 = 50 file-exists-p's. Then add some for CVS,
RCS, svn and SCCS.

With each file-readable-p taking around 200ms in my setup, this adds
up to the significant slowdown I experienced.

It's worth nothing that since tramp-handle-vc-registered (correctly)
disables the cache, this doesn't get a lot faster on subsequent
find-file operations either.

Disabling VC backends that I rarely use would be one option but
instead I implemented the attached patch. It changes
tramp-handle-vc-registered to first run a bash script remotely that
checks presence of the files used by the various VC backends in one go
and outputs an S-Expression that can subsequently serve as a cache.
Then tramp-file-name-handler is overridden temporarily by a wrapper
that intercepts file-exists-p, file-readable-p, file-directory-p and
file-executable-p and tries to satisfy these from the cache.

This patch probably shouldn't be applied as-is since it lacks polish:
- Hasn't been checked yet to work with whitespace in filenames
- Hasn't been checked yet to work with symlinks etc., i.e. (neq
(file-truename file) file)
- Uses hardwired files to check for instead of looking at vc-handled-backends
- Bash script can probably be optimized, e.g. by using stat(1) instead
of test(1)

All that said, I am using it right now and it improves performance
significantly in my situation. I hope others might find it useful as
well.

If you are interested in incorporating this patch into tramp-mode let
me know and I'm happy to help clean it up.

Cheers,

Julian

Attachment: tramp-vc-optimization.patch
Description: Binary data


reply via email to

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