Page MenuHomePhabricator

perftweaks: skip loading branches namespace if unnecessary
ClosedPublic

Authored by quark on Nov 21 2017, 12:34 AM.

Details

Summary

Loading the branches namespace is expensive since it calls headrevs()
which scans the entire changelog. Therefore add an option to skip the
namespace if we're not resolving default. This should be an no-op if named
branches are not used.

This removes the following cost resolving remote/master in smartlog:

60    \ _masterrev                           smartlog.py:426
61     | revsingle (2 times)                 scmutil.py:426
61     | revrange (2 times)                  scmutil.py:469
79     | anyrevs (3 times)                   localrepo.py:812
74     | matchany (3 times)                  revset.py:2163
71     | parse (6 times)                     revsetlang.py:535
71     | _parsewith (10 times)               revsetlang.py:462
71     | parse (46 times)                    parser.py:78
70     | _advance (48 times)                 parser.py:33
71     | tokenize (281 times)                revsetlang.py:66
70     | <genexpr> (6 times)                 revsetlang.py:97
70     | __contains__ (3 times)              localrepo.py:761
72     | __getitem__ (39 times)              localrepo.py:748
73     | __init__ (161 times)                context.py:447
70     | singlenode (3 times)                namespaces.py:97
58     | <lambda> (3 times)                  namespaces.py:55
58     | branchtip (3 times)                 localrepo.py:965
58     | branchmap (3 times)                 localrepo.py:953
58     | _branchmapupdatecache (3 times)     perftweaks.py:105
57     | _branchmapupdate                    perftweaks.py:85
38     | headrevs                            changelog.py:336

Note: we cannot just reorder the namespaces since the revset string
smartlog(...) as a whole will be tested against each namespace.

Test Plan

Added a test. Based on the test plan of D1501. Enable this feature and make
sure there are no new test failures.

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 21 2017, 12:34 AM
Herald added a reviewer: Restricted Project. · View Herald TranscriptNov 21 2017, 12:34 AM
quark updated this revision to Diff 3707.Nov 21 2017, 1:27 AM
durham requested changes to this revision.Nov 21 2017, 10:27 AM
durham added a subscriber: durham.
durham added inline comments.
hgext3rd/perftweaks.py
75

How are tags affected by the code below?

81

Is this only true if we're in a repo that doesn't have branches? Some of our older ones do have branches though.

This revision now requires changes to proceed.Nov 21 2017, 10:27 AM
quark added inline comments.Nov 21 2017, 2:27 PM
hgext3rd/perftweaks.py
75

Sorry. Outdated comments. tags seems fast because we made them empty. So it got removed from the excluded list.

81

Good catch. I thought the old code here will only expose default branch. Will add a check about tweakdefaults.allowbranch

quark updated this revision to Diff 3759.Nov 21 2017, 10:15 PM
quark edited the test plan for this revision. (Show Details)Nov 23 2017, 5:33 PM
durham accepted this revision.Nov 27 2017, 9:39 PM
This revision is now accepted and ready to land.Nov 27 2017, 9:39 PM
quark edited the summary of this revision. (Show Details)Nov 29 2017, 8:40 PM
quark edited the test plan for this revision. (Show Details)
quark retitled this revision from perftweaks: skip branches namespace if not resolving 'default' to perftweaks: skip loading branches namespace if necessary.
quark retitled this revision from perftweaks: skip loading branches namespace if necessary to perftweaks: skip loading branches namespace if unnecessary.
quark updated this revision to Diff 3988.
This revision was automatically updated to reflect the committed changes.