speeding up hg pull?

Cameron Simpson cs at zip.com.au
Mon Aug 27 23:54:24 UTC 2012


On 27Aug2012 15:17, Matt Mackall <mpm at selenic.com> wrote:
| On Mon, 2012-08-27 at 23:49 +1200, Ryan Brown wrote:
| > I was thinking if hg kept the ssh tunnel open till you've finished
| > with it (or a timeout x seconds), rather than close it before I push
| > it out (hg push is also slow)
| 
| Mercurial uses one ssh connection per invocation. Since it's not a
| daemon, it can't hold connections open.

No, but you can keep a master ssh open (outside of mercurial) and use
its control socket. This _greatly_ speeds connection time.

Example:
  invoke the master ssh using
      ControlMaster         yes
      ControlPath           ~/.sshctrl-%r@%h%p

Configure your default ssh connections (so that Mercurial's connections
is this) thus:

  ControlMaster         no
  ControlPath           ~/.sshctrl-%r@%h.%p

The initial connection then takes place to the local ssh control socket
named by ControlPath (almost instant, no network latency) and the
authentication step is also skipped (trusted connection tunneled over
the existing ssh connection), also saving much latency.

Aside from the setup, the only real downside is that if you tunnel
multiple actions through this in parallel your sharing a single network
TCP connection; if the net is congested you get a smaller share (overall
throughput for significant data) than using multiple TCP connections. In
practice I don't think this has ever caused me trouble.

I keep a few ssh connections around to portforward to remote secure
services, including my home server. This makes short hg operations
(eg fetch/push with small changes) much snappier.

Cheers,
-- 
Cameron Simpson <cs at zip.com.au>

One of the advantages of being disorderly is that one is constantly making
exciting discoveries.   - A. A. Milne



More information about the Mercurial mailing list