#588611 mercurial: Performance hit on demandimport

Package:
mercurial
Source:
mercurial
Description:
easy-to-use, scalable distributed version control system
Submitter:
Isaac Jurado
Date:
2013-10-29 08:21:13 UTC
Severity:
normal
#588611#5
Date:
2010-07-10 08:44:15 UTC
From:
To:
Packaged mercurial performs worse than upstream mercurial (1.6).  After a quick
test (hg --profile branch, on the Mercurial repo itself) were the following,
from upstream:

   CallCount    Recursive    Total(ms)   Inline(ms) module:lineno(function)
           6            3      0.0011      0.0007   <__import__>
          +1            0      0.0004      0.0001   +mercurial.dirstate:8(<module>)
           1            0      0.0004      0.0001   mercurial.dirstate:8(<module>)
         +11            0      0.0002      0.0001   +mercurial.demandimport:81(_demandimport)
          +1            0      0.0001      0.0000   +mercurial.dirstate:37(dirstate)
          +1            0      0.0000      0.0000   +mercurial.demandimport:72(__getattribute__)
          20           17      0.0013      0.0001   mercurial.demandimport:72(__getattribute__)
          +4            1      0.0012      0.0001   +mercurial.demandimport:44(_load)
          +8            0      0.0000      0.0000   +mercurial.demandimport:72(__getattribute__)
          +4            0      0.0000      0.0000   +<getattr>
           4            1      0.0012      0.0001   mercurial.demandimport:44(_load)
          +4            1      0.0011      0.0007   +<__import__>
          +8            0      0.0000      0.0000   +mercurial.demandimport:72(__getattribute__)
          +4            0      0.0000      0.0000   +<method 'get' of 'dict' objects>
          11            0      0.0002      0.0001   mercurial.demandimport:81(_demandimport)
          +9            0      0.0001      0.0001   +mercurial.demandimport:32(__init__)
          +2            0      0.0000      0.0000   +<__import__>
          +2            0      0.0000      0.0000   +<method 'split' of 'str' objects>
          +2            0      0.0000      0.0000   +<hasattr>
           9            0      0.0001      0.0001   mercurial.demandimport:32(__init__)
           1            0      0.0001      0.0001   mercurial.util:504(__call__)
          +1            0      0.0000      0.0000   +mercurial.util:725(splitpath)
          +1            0      0.0000      0.0000   +<method 'update' of 'set' objects>
          +1            0      0.0000      0.0000   +<method 'pop' of 'list' objects>
          +2            0      0.0000      0.0000   +<method 'lower' of 'str' objects>
          +1            0      0.0000      0.0000   +<method 'add' of 'set' objects>
           1            0      0.0001      0.0001   <method 'write' of 'file' objects>
           1            0      0.0001      0.0000   mercurial.dirstate:37(dirstate)
         +11            0      0.0000      0.0000   +mercurial.util:159(__init__)
           1            0      0.0017      0.0000   mercurial.commands:454(branch)
          +1            0      0.0000      0.0000   +mercurial.encoding:31(tolocal)
          +1            0      0.0013      0.0000   +mercurial.util:162(__get__)
          +1            0      0.0001      0.0000   +mercurial.extensions:159(wrap)
          +1            0      0.0002      0.0000   +mercurial.dirstate:202(branch)
          +1            0      0.0000      0.0000   +<method 'get' of 'dict' objects>

And from the Debian packaged version (1.6-2):

   CallCount    Recursive    Total(ms)   Inline(ms) module:lineno(function)
           6            3      0.0182      0.0176   <__import__>
          +1            0      0.0006      0.0002   +mercurial.dirstate:8(<module>)
           1            0      0.0006      0.0002   mercurial.dirstate:8(<module>)
         +11            0      0.0002      0.0001   +mercurial.demandimport:81(_demandimport)
          +1            0      0.0001      0.0001   +mercurial.dirstate:37(dirstate)
          +1            0      0.0001      0.0000   +mercurial.demandimport:72(__getattribute__)
          20           17      0.0183      0.0001   mercurial.demandimport:72(__getattribute__)
          +4            1      0.0182      0.0001   +mercurial.demandimport:44(_load)
          +8            0      0.0000      0.0000   +mercurial.demandimport:72(__getattribute__)
          +4            0      0.0000      0.0000   +<getattr>
          11            0      0.0002      0.0001   mercurial.demandimport:81(_demandimport)
          +9            0      0.0001      0.0001   +mercurial.demandimport:32(__init__)
          +2            0      0.0000      0.0000   +<__import__>
          +2            0      0.0000      0.0000   +<method 'split' of 'str' objects>
          +2            0      0.0000      0.0000   +<hasattr>
           4            1      0.0182      0.0001   mercurial.demandimport:44(_load)
          +4            1      0.0182      0.0176   +<__import__>
          +8            0      0.0000      0.0000   +mercurial.demandimport:72(__getattribute__)
          +4            0      0.0000      0.0000   +<method 'get' of 'dict' objects>
           1            0      0.0001      0.0001   mercurial.dirstate:37(dirstate)
         +11            0      0.0000      0.0000   +mercurial.util:159(__init__)
           1            0      0.0001      0.0001   <method 'write' of 'file' objects>
           9            0      0.0001      0.0001   mercurial.demandimport:32(__init__)
           1            0      0.0001      0.0001   <method 'read' of 'file' objects>
           1            0      0.0001      0.0001   mercurial.util:504(__call__)
          +1            0      0.0000      0.0000   +mercurial.util:725(splitpath)
          +1            0      0.0000      0.0000   +<method 'update' of 'set' objects>
          +2            0      0.0000      0.0000   +<method 'lower' of 'str' objects>
          +1            0      0.0000      0.0000   +<method 'pop' of 'list' objects>
          +1            0      0.0000      0.0000   +<method 'add' of 'set' objects>

Ignoring the fact that the Debian version has fewer lines, it should be noted
the difference between the <__import__> line, (0.0011ms vs 0.0182, in both cases
is the third run, so it's supposed to be cached).

The upstream version was tested compiling with make local using python2.6-dev
from Debian.

#588611#12
Date:
2013-06-14 23:47:45 UTC
From:
To:
"Preferred benchmark is perfstartup from contrib/perf.py"

Source: mpm on #mercurial IRC channel.