speeding up hg pull?

114 views
Skip to first unread message

Ryan Brown

unread,
Aug 25, 2012, 6:13:36 AM8/25/12
to merc...@selenic.com
We were wondering why the hg server was taking the a long time to just
pull changes, so attached a timer on the script ..(The server isn't
overloaded btw)

@echo off
echo %time%
hg pull -u
echo %time%

22:05:00.23
pulling from ssh://h...@200.000.000.000/dir/
searching for changes
no changes found
22:05:15.80

15 seconds seems a bit high, is there any serverside tweaks to improve
it or speed up a pull?
_______________________________________________
Mercurial mailing list
Merc...@selenic.com
http://selenic.com/mailman/listinfo/mercurial

Matt Mackall

unread,
Aug 26, 2012, 2:08:05 PM8/26/12
to Ryan Brown, merc...@selenic.com
On Sat, 2012-08-25 at 22:13 +1200, Ryan Brown wrote:
> We were wondering why the hg server was taking the a long time to just
> pull changes, so attached a timer on the script ..(The server isn't
> overloaded btw)
>
> @echo off
> echo %time%
> hg pull -u
> echo %time%
>
> 22:05:00.23
> pulling from ssh://h...@200.000.000.000/dir/
> searching for changes
> no changes found
> 22:05:15.80
>
> 15 seconds seems a bit high, is there any serverside tweaks to improve
> it or speed up a pull?

How long does it take to start an ssh shell connection without
Mercurial?

--
Mathematics is the supreme nostalgia of our time.

Ryan Brown

unread,
Aug 27, 2012, 7:49:22 AM8/27/12
to Matt Mackall, merc...@selenic.com
> How long does it take to start an ssh shell connection without
> Mercurial?

about 1-2 secs (around 140-150ms)

How would you speed up ssh auth's via hg? When I use putty its pretty
quick to initiate a login.

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)

Ryan Brown

unread,
Aug 27, 2012, 7:52:22 AM8/27/12
to Matt Mackall, merc...@selenic.com
We're using mercurial-server for ssh specifically, performance wise is
that okay or is there better?

Mihamina Rakotomandimby

unread,
Aug 27, 2012, 7:55:22 AM8/27/12
to merc...@selenic.com
On 08/27/2012 02:52 PM, Ryan Brown wrote:
> We're using mercurial-server for ssh specifically, performance wise is
> that okay or is there better?

You're looking for a way to have a shorter response time than 140-150ms?
How frequent do you push or pull per developper?

--
RMA.

Ryan Brown

unread,
Aug 27, 2012, 8:24:16 AM8/27/12
to Mihamina Rakotomandimby, merc...@selenic.com
Anytime we commit something, it'll hg pull/hg push we could be waiting
around 35-40seconds.. Which slows things down.

We're not trying "shortening the response time", .. 140-150ms is fine,
hg via ssh is horribly slow, compared to using Putty.

Pull and Pushing isn't dependent on load (most of the time, 2 people
using it at a specific time), but even when you're the only one on the
server, its still slow.

Mihamina Rakotomandimby

unread,
Aug 27, 2012, 8:39:15 AM8/27/12
to mercurial
On 08/27/2012 03:24 PM, Ryan Brown wrote:
> Anytime we commit something, it'll hg pull/hg push we could be waiting
> around 35-40seconds.. Which slows things down.

My first idea is then about reverse DNS.
Setup the SSH on the server (/etc/ssh/sshd_config):
UseDNS no

Then give a try.

Rian Hunter

unread,
Aug 27, 2012, 2:11:23 PM8/27/12
to Ryan Brown, merc...@selenic.com
Ssh is usually slow because of dns lookups. One way to speed that up is disabling "UseDNS" on the server-side. There are other tweaks that can help as well.

It doesn't seem that ssh is the culprit here though since raw ssh is 1-2 seconds compared to total hg pull time.

Have you run an activity monitor or strace on both client and server to see what resources are being used / blocked on the most during the pull? I have a feeling you might be blocked on disk IO on your server.

Rian Hunter

unread,
Aug 27, 2012, 2:05:14 PM8/27/12
to Ryan Brown, merc...@selenic.com


On Aug 27, 2012, at 5:24 AM, Ryan Brown <mp3...@gmail.com> wrote:

Matt Mackall

unread,
Aug 27, 2012, 4:17:22 PM8/27/12
to Ryan Brown, merc...@selenic.com
On Mon, 2012-08-27 at 23:49 +1200, Ryan Brown wrote:
> > How long does it take to start an ssh shell connection without
> > Mercurial?
>
> about 1-2 secs (around 140-150ms)

I'm going to assume the apparently completely contradictory second set
of numbers is ping time.

Also, it was unhelpful to delete the original context, as I've now
forgotten it and needed to consult my archives. An empty pull should
generally be about as fast as an ssh connection:


$ time ssh waste.org echo foo
foo

real 0m0.325s
user 0m0.003s
sys 0m0.020s

$ time hg in default-push --debug | cat
running ssh server.org 'hg -R repo/hg serve --stdio'
sending hello command
sending between command
remote: 145
remote: capabilities: lookup changegroupsubset branchmap pushkey known
getbundle unbundlehash batch stream unbundle=HG10GZ,HG10BZ,HG10UN
httpheader=1024
remote: 1
comparing with ssh://server.org/repo/hg
query 1; heads
sending batch command
searching for changes
all remote heads known locally
no changes found

real 0m0.589s
user 0m0.053s
sys 0m0.043s


> How would you speed up ssh auth's via hg? When I use putty its pretty
> quick to initiate a login.

Mercurial auth over ssh should be exactly as fast as plain ssh auth
(provided you're using an agent for both). Try to get verbose output
from putty together with debug output from hg. Something like this
should work:

hg outgoing -e "plink -v" --debug

Send that along with annotation of where it's pausing. You might try
comparing the above with a normal putty connection.

> 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.

--
Mathematics is the supreme nostalgia of our time.


Cameron Simpson

unread,
Aug 27, 2012, 7:54:24 PM8/27/12
to Matt Mackall, merc...@selenic.com
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 <c...@zip.com.au>

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

Ryan Brown

unread,
Aug 28, 2012, 8:53:31 AM8/28/12
to Mihamina Rakotomandimby, mercurial
Thanks! That improved it a lot.. did a bit more googling after that..

disabled X11Forwarding, UsePAM, GSSAPIAuthentication and apparently
setting "AddressFamily inet" also helps

Mihamina Rakotomandimby

unread,
Aug 28, 2012, 9:14:42 AM8/28/12
to mercurial
On 08/28/2012 03:53 PM, Ryan Brown wrote:
> Thanks! That improved it a lot..

Always happy I could help :-)
Reply all
Reply to author
Forward
0 new messages