[PATCH 2 of 2 v4] revset: use localrepo persistent branch name caching

Mads Kiilerich mads at kiilerich.com
Thu Oct 16 09:45:30 CDT 2014


On 10/16/2014 09:49 AM, Pierre-Yves David wrote:
> On 10/15/2014 06:48 PM, Mads Kiilerich wrote:
>> # HG changeset patch
>> # User Mads Kiilerich <madski at unity3d.com>
>> # Date 1413424007 -7200
>> #      Thu Oct 16 03:46:47 2014 +0200
>> # Node ID b0e40604be81ff0716e1254f7ce7884599457f71
>> # Parent  d87009e720063a8d6d80afdbe6bb9323e2849030
>> revset: use localrepo persistent branch name caching
>>
>> Branch name filtering in revsets was expensive. For every rev it 
>> created a
>> changectx and called .branch(). (Using changelog.branchinfo() would 
>> make it a
>> bit faster.)
>>
>> Instead, use the new localrepo caching branch lookup method.
>
> Could you get ctx.branch() to use this cache too ? Would that benefit 
> anything?

I doubt there will be much to win if we already have a ctx.

The cache will also grow with the repo and is not free to load. We do 
not want to load it just to make a single branch name lookup. But it 
will probably always be worth it for revsets.

> The branchmap code could use it too. and would prewarm it for you.

Sure. It would also require storing the closed flag in the cache, in a 
way that doesn't cause regressions for regular branch name lookups.

That is something that can come later.

>
>>
>> On the small hg repo:
>>    hg log --time -r 'branch(stable) & branch(default)'
>> Before:
>>    time: real 1.910 secs (user 1.890+0.000 sys 0.020+0.000)
>> After:
>>    time: real 1.240 secs (user 1.230+0.000 sys 0.010+0.000)
>>    time: real 0.120 secs (user 0.110+0.000 sys 0.000+0.000)
>>
>> On mozilla-central with 210557:a280a03c9f3c :
>>    hg --time log -r 'branch(mobile)' -T.
>> Before:
>>    time: real 10.450 secs (user 10.390+0.000 sys 0.060+0.000)
>> After:
>>    time: real 7.640 secs (user 7.480+0.000 sys 0.140+0.000)
>>    time: real 0.520 secs (user 0.490+0.000 sys 0.030+0.000)
>>
>> First run is 35%/27% faster (primarily because the new code path uses
>> changelog.branchinfo instead changectx.branch and we avoid messing with
>> localrepo). Following runs will use the cache and are 16x/20x faster.
>
> If you are benchmarking revset please use the perf extension to get 
> your numbers.

The perf extension is fine for fine tuning. The perf extension will be 
tricked by the different computations done when populating and using the 
cache. It will not give any relevant, reliable and comparable values.

/Mads


More information about the Mercurial-devel mailing list