[PATCH] (a bit hacky) hgweb very slow when there are many branches

Simon MacMullen simon at rabbitmq.com
Mon Nov 21 12:11:52 CST 2011


We just upgraded our Mercurial servers from 1.0.x to 1.6.x (Debian lenny 
to squeeze) and found that hgweb had become incredibly slow.

(I know, those are old versions but I checked: the problem still exists 
in 2.0.)

We use a configuration like:

   [web]
   style = gitweb
   allow_archive = bz2 gz zip
   baseurl = ...
   maxchanges = 200

After a bit of poking around I determined that the problem was the code 
to produce the coloured branch indicators. This looks up all branches 
for all changesets, for each changeset in the displayed list. So it's 
probably O(changesets_in_list * branches_in_repo) or even 
O(changesets_in_list * changesets_in_repo) - I'm not sure what 
repo.branchtags() does. Anyway it's slow.

The attached patch makes things much faster, at the cost of showing the 
wrong coloured branch indicator for changesets at the "tip" of part of a 
discontiguous branch. I know it's hacky, but it made hgweb usable for us 
again. Maybe it can form the basis of something useful.

If you want an example of a repo with enough branches to feel slow in 
hgweb, clone:

http://hg.rabbitmq.com/rabbitmq-server/

Cheers, Simon

-- 
Simon MacMullen
RabbitMQ, VMware
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hgweb-fast-with-lots-of-branches.diff
Type: text/x-patch
Size: 1200 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20111121/a7f8f037/attachment.bin>


More information about the Mercurial-devel mailing list