Thursday, February 10, 2011

Clone timings

Chris Atlee was wondering how clone times differ between git and mercurial so I ran a quick test on a fast linux machine.

$ time git clone git://
real 1m33.478s

$ time git clone mozilla-central moz2
real 0m2.559s

$ time hg clone
real 3m22.510s

$ time hg clone mozilla-central moz2
real 0m20.660s


Anonymous said...

Now do the same on Linux/Mac/Windows. :)

Zack Weinberg said...

Don't suppose we could get "strace -c" reports for, at least, both of the local disk cases? /me suspects a big chunk of this is down to hg's one-store-file-per-checked-out-file arrangement vs git's packs.

Jeff Muizelaar said...


Yeah, that sounds correct. shows 2 link calls in the git case and 71435 in the hg case.

Anonymous said...

I'm jealous of your 3 minute hg clone times, here in NZ it's more like 30 minutes!

Neil Rashbrook said...

If git just links two files, then when you commit a local change isn't that going to require a rewrite of the whole file?

Did you use hg clone -U ? It's unclear whether your timings included updating the working directory. On my usual PC you're looking at the best part of an hour, even for a clone -U :-( It took about 5½ minutes on a powerful Windows PC that I borrowed for testing purposes.

Jeff Muizelaar said...


The hg clone time included updating the working directory.

Git works using raw files in addition to "pack" files. When you commit, new files are created with just that commit in them. These are occasionally garbage collected into pack files. This keeps commits very fast because no files need to be rewritten and at the same time allows very compact storage of history. e.g. git's 207M vs hg's 645M