Getting the Best Performance Out of MQ

MQ is very efficient at handling a large number of patches. I ran some performance experiments in mid-2006 for a talk that I gave at the 2006 EuroPython conference (on modern hardware, you should expect better performance than you’ll see below). I used as my data set the Linux 2.6.17-mm1 patch series, which consists of 1,738 patches. I applied these on top of a Linux kernel repository containing all 27,472 revisions between Linux 2.6.12-rc2 and Linux 2.6.17.

On my old, slow laptop, I was able to hg qpush hg -a all 1,738 patches in 3.5 minutes, and hg qpop hg -a them all in 30 seconds. (On a newer laptop, the time to push all patches dropped to two minutes.) I could qrefresh one of the biggest patches (which made 22,779 lines of changes to 287 files) in 6.6 seconds.

Clearly, MQ is well suited to working in large trees, but there are a few tricks you can use to get the best performance out of it.

First of all, try to batch operations together. Every time you run qpush or qpop, these commands scan the working directory once to make sure you haven’t made some changes and then forgotten to run qrefresh. On a small tree, the time that this scan takes is unnoticeable. However, on a medium-sized tree (containing tens of thousands of files), it can take a second or more.

The qpush and qpop commands allow you to push and pop multiple patches at a time. You can identify the destination patch that you want to end up at. When you qpush with a destination ...

Get Mercurial: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.