This is an archive of the discontinued Mercurial Phabricator instance.

branchcache: lazily validate nodes from the branchmap
ClosedPublic

Authored by pulkit on Apr 5 2019, 9:31 AM.

Details

Summary

On my personal hg-repository with 365 entries in .hg/cache/branch2, following
are the numbers for perfbranchmapload.

Before this patch:

! wall 0.000866 comb 0.000000 user 0.000000 sys 0.000000 (best of 2680)
! wall 0.001525 comb 0.000000 user 0.000000 sys 0.000000 (max of 2680)
! wall 0.001107 comb 0.001097 user 0.001086 sys 0.000011 (avg of 2680)
! wall 0.001104 comb 0.000000 user 0.000000 sys 0.000000 (median of 2680)

With this patch:

! wall 0.000530 comb 0.000000 user 0.000000 sys 0.000000 (best of 4240)
! wall 0.001078 comb 0.000000 user 0.000000 sys 0.000000 (max of 4240)
! wall 0.000696 comb 0.000693 user 0.000677 sys 0.000017 (avg of 4240)
! wall 0.000690 comb 0.000000 user 0.000000 sys 0.000000 (median of 4240)

On our internal repository with ~20k entries in branchcache, I see improvement
from 0.125 sec to 0.066 sec which is 47% speed up.

The above are the numbers of perfbranchmapload which shows how much time we
saved by not validating the nodes. But we need to validate some nodes. Following
are timings of some mercurial operations which have speed up because of this
lazy validation of nodes:

No-op hg update on our internal repository (Avg on 4 runs):

Before: 0.540 secs
After: 0.430 secs

Setting a branch name which already exists without --force (Avg of 4 runs):

Before: 0.510 secs
After: 0.250 secs

I ran the ASV performance suite and was unable to see any improvements except
there was improvement of perfdirstatewrite() on netbeans which I think was not
related.

I looked into the commit code, the command which I am trying to speedup, it
looks like it uses revbranchcache to update the branchcache.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

pulkit created this revision.Apr 5 2019, 9:31 AM
yuja added a subscriber: yuja.Apr 12 2019, 9:12 PM

The idea sounds good to me. Is this still an RFC (i.e. draft) patch?

pulkit retitled this revision from [RFC] branchmap: lazily validate nodes from the branchmap to branchcache: lazily validate nodes from the branchmap.Apr 15 2019, 12:14 PM
In D6208#90673, @yuja wrote:

The idea sounds good to me. Is this still an RFC (i.e. draft) patch?

It's good to be reviewed.

yuja added a comment.Apr 15 2019, 7:16 PM
def copy(self):
    """return an deep copy of the branchcache object"""

+ self._verifyall()

return type(self)(
    self._entries, self.tipnode, self.tiprev, self.filteredhash,
    self._closednodes)

Maybe the copy would be marked as not verified?

This revision was automatically updated to reflect the committed changes.