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

Matt Mackall mpm at selenic.com
Wed Nov 23 15:36:25 CST 2011


On Mon, 2011-11-21 at 18:11 +0000, Simon MacMullen wrote:
> 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/

Please take a look at:

http://mercurial.selenic.com/wiki/ContributingChanges

I suspect you have a problem with your server building its on-disk
branch cache, probably due to permission issues:

http://www.selenic.com/hg/file/cea62936b39a/mercurial/localrepo.py#l543

Fix that, and the existing code should be faster than your hack (after
the cache is built).

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list