Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I optimize a Mercurial clone?

My Mercurial clone has become incredibly slow, presumably due to on-disk fragmentation. Is there a way to optimize it?

The obvious way it to make a new clone, then copy my MQ, saved bundles, hgrc, etc, to the new clone and delete the old one. But it seems like someone might have run into this problem before and made an extension to do it?

like image 980
Paul Biggar Avatar asked Jul 07 '11 20:07

Paul Biggar


2 Answers

If the manifest gets particularly large then it can result in slow performance. Mercurial has an alternative repository format - generaldelta - that can often result in much smaller manifests.

You can check the size of your manifest using:

ls -lh .hg/store/*manifest*

To get maximum value from generaldelta:

  1. Install Mercurial 2.7.2 or later (2.7.2 includes a fix to a bug in generaldelta that could result in larger manifest sizes - but there's a good chance you won't hit the bug with an earlier version).

  2. Execute hg --config format.generaldelta=1 clone --pull orig orig.gd.

This may give some improvement in the manifest size, but not the full benefit.

  1. Execute hg --config format.generaldelta=1 clone --pull orig.gd orig.gd.gd.

The clone of the clone may give a much greater improvement in the manifest size. This is because when pulling from a generaldelta repo things will be reordered to optimise the manifest size.

As an example of the potential benefits of generaldelta, I recently converted a repo that was ~55000 SVN commits (pulled using hgsubversion) plus ~1000 Mercurial commits/merges/grafts, etc. The manifest in the original repo was ~1.4GB. The manifest in the first clone was ~600MB. The manifest in the clone of the clone was ~30MB.

There isn't a lot of information about generaldelta online - there's still work to be done before it can become the default format, but it works well for many projects. The first few Google search results have some information from when it was first introduced, and there was some recent discussion on the mercurial-dev mailing list.

like image 51
Tim Delaney Avatar answered Sep 22 '22 06:09

Tim Delaney


I deleted the repo and recloned, and that improved performance.

like image 33
Paul Biggar Avatar answered Sep 25 '22 06:09

Paul Biggar