Page MenuHomePhabricator

perftweaks: micro optimization about branchcache.update
ClosedPublic

Authored by quark on Nov 18 2017, 12:56 AM.

Details

Summary

This patch did two optimizations:

  • Avoid sorting headrevs since it's already sorted.
  • Inline cl.node so there is no node hash table lookups inside the loop.

After this patch, branchcache.update's bottleneck is at the native code
path (headrevs and node):

63            \ <lambda> (4 times)           namespaces.py:55
63             | branchtip (4 times)         localrepo.py:965
63             | branchmap (4 times)         localrepo.py:953
63             | _branchmapupdatecache (6 times) perftweaks.py:105
62             | _branchmapupdate            perftweaks.py:85
  • 46 \ headrevs changelog.py:336 14 \ node (4087 times) changelog.py:361

We can choose speeding up headrevs, or make it somehow lazy so not all
heads need to be loaded.

Diff Detail

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

Event Timeline

quark created this revision.Nov 18 2017, 12:56 AM
Herald added a reviewer: Restricted Project. · View Herald TranscriptNov 18 2017, 12:56 AM
stash accepted this revision.Nov 21 2017, 4:32 AM
stash added a subscriber: stash.

I maybe missing something, but from your summary it's unclear how much time were saved with these optimizations. Can you include it?

This revision is now accepted and ready to land.Nov 21 2017, 4:32 AM
durham accepted this revision.Nov 21 2017, 10:19 AM
This revision was automatically updated to reflect the committed changes.