Mercurial > hg-stable
changeset 14056:bcfe78c3d15c
branchcache: improve speed relative to the amount of heads
Updating the branch cache is quadratic to the amount of heads in the
repository. One consequence of this was that cloning a pathological
repository with 10,000 heads (and nothing else) took hours of CPU
time.
This patch makes one of the inner loop much faster, by removing a
changectx instantiation, and removes another entirely in cases where
there are no candidate branch heads which descend from other branch
heads.
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Sat, 30 Apr 2011 12:56:28 +0200 |
parents | 421d56a055fd |
children | c0e29e10b9ef |
files | mercurial/localrepo.py |
diffstat | 1 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/localrepo.py Sat Apr 30 12:55:07 2011 +0200 +++ b/mercurial/localrepo.py Sat Apr 30 12:56:28 2011 +0200 @@ -509,15 +509,17 @@ bheads.extend(newnodes) if len(bheads) <= 1: continue + bheads = sorted(bheads, key=lambda x: self[x].rev()) # starting from tip means fewer passes over reachable while newnodes: latest = newnodes.pop() if latest not in bheads: continue - minbhrev = self[min([self[bh].rev() for bh in bheads])].node() + minbhrev = self[bheads[0]].node() reachable = self.changelog.reachable(latest, minbhrev) reachable.remove(latest) - bheads = [b for b in bheads if b not in reachable] + if reachable: + bheads = [b for b in bheads if b not in reachable] partial[branch] = bheads def lookup(self, key):