This is an archive of the discontinued Mercurial Phabricator instance.

branchmap: pass changelog into branchmap functions
ClosedPublic

Authored by indygreg on Oct 19 2018, 12:56 PM.

Details

Summary

As part of building the branchmap, we loop over revs and call branchmap()
or _branchmap(). Previously, these functions were accessing repo.changelog.
We know from past experience that repo.changelog in loops is bad for
performance.

This commit teaches the branchmap code to pass a changelog instance into
branchmap() and _branchmap() so we don't need to pay this penalty.

On my MBP, this appears to show a speedup on a clone of the
mozilla-unified repo:

$ hg perfbranchmap --clear-revbranch
! base
! wall 21.078160 comb 21.070000 user 20.920000 sys 0.150000 (best of 3)
! wall 20.574682 comb 20.560000 user 20.400000 sys 0.160000 (best of 3)

$ hg perfbranchmap
! base
! wall 4.880413 comb 4.870000 user 4.860000 sys 0.010000 (best of 3)
! wall 4.573968 comb 4.560000 user 4.550000 sys 0.010000 (best of 3)

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

indygreg created this revision.Oct 19 2018, 12:56 PM
pulkit accepted this revision.Oct 19 2018, 1:08 PM
pulkit added inline comments.Oct 19 2018, 1:14 PM
mercurial/branchmap.py
407

There is one more call of this function in revset.py:491 which is also inside a for-loop. Doing this same thing there will speed up the branch() revset. If possible, can you have a look before the freeze?

pulkit added inline comments.Oct 19 2018, 1:15 PM
mercurial/branchmap.py
407

Oh, and one more in bundle2.py:1650 which is also inside a for loop!

Since these two patches are simple but great speedups, I am queueing them and also I will be sending patches to fix this at other places too if nobody beats me to it.

This revision was automatically updated to reflect the committed changes.