[PATCH 4 of 6] branchmap: use revbranchcache when updating branch map

Pierre-Yves David pierre-yves.david at ens-lyon.org
Sun Dec 14 18:21:17 CST 2014



On 12/14/2014 10:34 AM, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski at unity3d.com>
> # Date 1418581984 -3600
> #      Sun Dec 14 19:33:04 2014 +0100
> # Node ID a84099ef1a332eb93bc9287d74c64af7e510f90e
> # Parent  eeeae034dc7aa8501c3e8f510a0788a77e54bc9f
> branchmap: use revbranchcache when updating branch map
>
> This will speed repeated branchmap calculation up.
>
> perfbranchmap base on mozilla-central, before:
> ! wall 6.995851 comb 6.990000 user 6.970000 sys 0.020000 (best of 3)
> After:
> ! wall 2.599774 comb 2.600000 user 2.600000 sys 0.000000 (best of 4)
>
> On the hg repo, before:
> ! wall 0.718498 comb 0.720000 user 0.720000 sys 0.000000 (best of 14)
> After:
> ! wall 0.284678 comb 0.290000 user 0.290000 sys 0.000000 (best of 32)
>
> The use of revbranchcache for branch map will also make sure the revbranchcache
> "always" is kept up-to-date. If the cache for some reason should be out of
> sync, the wrong information in the cache will be skipped and the branch
> information will be retrieved as normally and the cache entry will be updated.
>
> diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
> --- a/mercurial/branchmap.py
> +++ b/mercurial/branchmap.py
> @@ -234,13 +234,15 @@
>           cl = repo.changelog
>           # collect new branch entries
>           newbranches = {}
> -        getbranchinfoutf8 = cl.branchinfoutf8
> +        cache = revbranchcache(repo)
> +        getbranchinfoutf8 = cache.branchinfoutf8

You should get your revbranchcache on an unfiltered repo version. There 
is no good to expect from recreating it on a repoview and this will to 
extra invalidation for bad reason.

>           for r in revgen:
>               branchutf8, closesbranch = getbranchinfoutf8(r)
>               branch = encoding.tolocal(branchutf8)
>               newbranches.setdefault(branch, []).append(r)
>               if closesbranch:
>                   self._closednodes.add(cl.node(r))
> +        cache.save()

You should probably move the save logic at the same place as the 
branchmap save logic.

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list