使用emacs tramp vs.rsync进行远程开发

时间:2020-03-06 14:52:23  来源:igfitidea点击:

我一直在使用emacs tramp进行一些远程开发,发现它非常慢。每次保存文件时,大约需要10秒钟才能完成保存。因此,现在我正在使用rsync远程传输文件,并且运行速度更快,大约需要一秒钟,而且emacs的本地保存是即时的。流浪汉中是否有任何配置选项可以使其在命令行上像rsync一样快地运行?即使我看到如此糟糕的性能,使用tramp代替rsync有什么优势吗?

解决方案

如果我们将流失用于ssh / scp功能,则会发现打开持久的SSH连接将使流失操作快得多:它们将重用现有的连接,而不是每次都创建一个新的连接,从而减少了很多工作加密开销而又不影响安全性。请参阅SSH ControlMaster功能的本文。

我们是否知道gnu.org上的tramp文档中提到使用rsync的部分?它部分说:

5.3 External transfer methods
  
  The external transfer methods operate through multiple channels, using the
  remote shell connection for many actions while delegating file
  transfers to an external transfer utility.
  
  This saves the overhead of encoding and decoding that multiplexing the
  transfer through the one connection has with the inline methods.
  
  ...
  
  rsync — ssh and rsync
      Using the ssh command to connect securely to the remote machine and the
      rsync command to transfer files is almost identical to the scp method.

While rsync performs much better than scp when transferring files that 
exist on both hosts, this advantage is lost if the file exists only on one side 
of the connection.

The rsync based method may be considerably faster than the rcp based
methods when writing to the remote system. Reading files to the local
machine is no faster than with a direct copy.

This method supports the ‘-p’ hack.

尽管流浪汉可以配置为使用多种传输方法,但我想我们正在使用ssh连接到远程服务器。

我相信完成操作所需的大部分时间都来自建立连接和进行身份验证。如果我们使用的是足够新的OpenSSH版本,则可以通过使用连接共享功能来获得帮助,请参阅ssh_config(5)中的ControlMaster。

我建议你试试

ControlMaster自动

看看这是否可以改善情况。

由于我们之前说过特定服务器上有问题,请检查问题计算机上的sshd配置文件。它可能类似于/ etc / ssh / sshd_config。

查找名为" UseDNS"的配置选项。将其设置为"否"。

看看那是否不能帮我们加快步伐。如果是这样,那么ssh可能正在等待我们可能不关心的反向dns查找超时。

最近,我开始使用sshfs,以便可以在本地编辑远程文件。适用于Linux,Mac和Unix系统,并将ssh部分放在一个命令中,而不是每次访问。并且完全存在于用户空间中。

对我而言,速度意义重大!现在使用流浪汉真的很令人愉快。我也更喜欢它而不是sshfs,因为我也可以从emacs内进行编译,而流浪汉为我做远程编译并为我解释编译器的错误消息:)