patrick_thomson · 2022-10-20 16:32
I use TRAMP to connect to GitHub Codespaces via my [Codespaces](https://github.com/patrickt/codespaces.el) package. However, I noted recently that my TRAMP sessions were suffering tremendous and unignorable lag when navigating within a file. I went through my enabled modes one-by-one and was surprised to learn that `vc-mode` was, in this case, the culprit. Setting `vc-handled-backends` like so:
(setq vc-handled-backends '(Git))
had a profound effect on latency. I'm not sure why this is the case, but its original value holds a bunch of entries for VCSs that died decades ago (CVS, SCCS, RCS…): it's possible that one of my packages was using all of `vc-mode`'s backends.
My TRAMP sessions to Codespaces are now as responsive and fast as if I were to connect to them via VS Code. Hope this helps someone!
glg00 · 2022-10-20 16:52
I personally use:
(defun my-vc-off-if-remote ()
(if (file-remote-p (buffer-file-name))
(setq-local vc-handled-backends nil)))
(add-hook 'find-file-hook 'my-vc-off-if-remote)
I don't use vc-mode, but still need it on my local machine to use project-mode; this disables vc when remote.
Another optimization I recently started using:
(setq remote-file-name-inhibit-locks t)
this inhibits .#<...> lock files. ymmv if you use different emacs processes to edit the same file, which I never do.
patrick_thomson · 2022-10-20 16:57
I didn't know about `remote-file-name-inhibit-locks`. Thanks for the pointer.
HM0880 · 2022-10-20 17:40
Wow, thanks for this! It's now part of my `init.el`.
redguardtoo · 2022-10-21 00:15
Aslo see https://www.reddit.com/r/emacs/comments/4c0mi3/the_biggest_performance_improvement_to_emacs_ive/
polaris64 · 2022-10-21 08:52
What perfect timing! I ran into this issue using TRAMP with a slow FTP server only yesterday and I had "Look into a solution" on my to-do list. Now marked as DONE :)