问题
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?
回答1:
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:
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).
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.
- 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.
回答2:
I deleted the repo and recloned, and that improved performance.
回答3:
Turn off real-time anti-virus monitoring of the folder the repo is cloned to and defrag. There's not much else you can do.
来源:https://stackoverflow.com/questions/6616951/can-i-optimize-a-mercurial-clone