( )⚙ D805 alias: make alias command lazily resolved

This is an archive of the discontinued Mercurial Phabricator instance.

alias: make alias command lazily resolved
ClosedPublic

Authored by quark on Sep 23 2017, 4:57 PM.

Details

Summary

With many aliases, resolving them could have some visible overhead. Below is
part of traceprof [1] output of hg bookmark --hidden:

(time unit: ms)
37  \ addaliases                             dispatch.py:526
37   | __init__ (60 times)                   dispatch.py:402
33   | findcmd (108 times)                   cmdutil.py:721
16   | findpossible (49 times)               cmdutil.py:683

It may get better by optimizing findcmd to do a bisect, but we don't
really need to resolve an alias if it's not used, so let's make those
command entries lazy.

After this patch, addalias takes less than 1ms.

.. perf:: improved performance when many aliases are defined

[1]: https://bitbucket.org/facebook/hg-experimental/src/9aca0dbdbdfc48457e5d2581ca2d6e662fced2e6/hgext3rd/traceprof.pyx

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

quark created this revision.Sep 23 2017, 4:57 PM
quark edited the summary of this revision. (Show Details)Sep 23 2017, 5:00 PM
quark updated this revision to Diff 2050.Sep 23 2017, 5:34 PM
quark updated this revision to Diff 2052.Sep 23 2017, 5:41 PM
yuja accepted this revision.Sep 25 2017, 10:48 AM
yuja added a subscriber: yuja.

Looks okay. Queued, thanks.

mercurial/dispatch.py
539

A slice operation would be unlikely for alias commands, so this
should be fine.

This revision is now accepted and ready to land.Sep 25 2017, 10:48 AM
This revision was automatically updated to reflect the committed changes.