This is an archive of the discontinued Mercurial Phabricator instance.

perftweaks: micro optimization about branchcache.update

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



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) 
63             | branchtip (4 times)
63             | branchmap (4 times)
63             | _branchmapupdatecache (6 times)
62             | _branchmapupdate  
  • 46 \ headrevs 14 \ node (4087 times)

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

Diff Detail

rFBHGX Facebook Mercurial Extensions
Automatic diff as part of commit; lint not applicable.
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.