dirstate: add some traces on listdir calls
authorAugie Fackler <augie@google.com>
Tue, 15 Oct 2019 11:05:32 -0400
changeset 43239 6fcdcea2b03a
parent 43238 101ae8bbfa02
child 43240 4353942be294
dirstate: add some traces on listdir calls I'm starting to spend some time trying to make `hg status` do less work, and knowing what's happening in here and what's expensive is an important start. Differential Revision: https://phab.mercurial-scm.org/D7109
mercurial/dirstate.py
--- a/mercurial/dirstate.py	Tue Oct 15 11:06:04 2019 -0400
+++ b/mercurial/dirstate.py	Tue Oct 15 11:05:32 2019 -0400
@@ -16,6 +16,9 @@
 from .i18n import _
 from .node import nullid
 from .pycompat import delattr
+
+from hgdemandimport import tracing
+
 from . import (
     encoding,
     error,
@@ -951,6 +954,7 @@
         def traverse(work, alreadynormed):
             wadd = work.append
             while work:
+                tracing.counter('dirstate.walk work', len(work))
                 nd = work.pop()
                 visitentries = match.visitchildrenset(nd)
                 if not visitentries:
@@ -961,7 +965,8 @@
                 if nd != b'':
                     skip = b'.hg'
                 try:
-                    entries = listdir(join(nd), stat=True, skip=skip)
+                    with tracing.log('dirstate.walk.traverse listdir %s', nd):
+                        entries = listdir(join(nd), stat=True, skip=skip)
                 except OSError as inst:
                     if inst.errno in (errno.EACCES, errno.ENOENT):
                         match.bad(