[PATCH 3 of 3] dirstate: inline more properties and methods in status

Siddharth Agarwal sid0 at fb.com
Mon Dec 3 16:23:55 CST 2012


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1354573305 28800
# Node ID a17491c6a1cf2ec1bb129e2b4341581d31eeac22
# Parent  98f5d2b441abc677c2b2fbaa3900de2afc193247
dirstate: inline more properties and methods in status

hg perfstatus -u on a working directory with 170,000 files, without this
change:
! wall 1.839561 comb 1.830000 user 1.120000 sys 0.710000 (best of 6)

With this change:
! wall 1.804222 comb 1.790000 user 1.140000 sys 0.650000 (best of 6)

hg perfstatus on the same directory, without this change:
! wall 1.016609 comb 1.020000 user 0.670000 sys 0.350000 (best of 10)

With this change:
! wall 0.985573 comb 0.980000 user 0.650000 sys 0.330000 (best of 10)

diff -r 98f5d2b441ab -r a17491c6a1cf mercurial/dirstate.py
--- a/mercurial/dirstate.py	Mon Dec 03 13:42:42 2012 -0800
+++ b/mercurial/dirstate.py	Mon Dec 03 14:21:45 2012 -0800
@@ -750,13 +750,19 @@
         radd = removed.append
         dadd = deleted.append
         cadd = clean.append
+        mexact = match.exact
+        dirignore = self._dirignore
+        checkexec = self._checkexec
+        checklink = self._checklink
+        copymap = self._copymap
+        lastnormaltime = self._lastnormaltime
 
         lnkkind = stat.S_IFLNK
 
         for fn, st in self.walk(match, subrepos, listunknown,
                                 listignored).iteritems():
             if fn not in dmap:
-                if (listignored or match.exact(fn)) and self._dirignore(fn):
+                if (listignored or mexact(fn)) and dirignore(fn):
                     if listignored:
                         iadd(fn)
                 elif listunknown:
@@ -775,15 +781,15 @@
                 mtime = int(st.st_mtime)
                 if (size >= 0 and
                     ((size != st.st_size and size != st.st_size & _rangemask)
-                     or ((mode ^ st.st_mode) & 0100 and self._checkexec))
-                    and (mode & lnkkind != lnkkind or self._checklink)
+                     or ((mode ^ st.st_mode) & 0100 and checkexec))
+                    and (mode & lnkkind != lnkkind or checklink)
                     or size == -2 # other parent
-                    or fn in self._copymap):
+                    or fn in copymap):
                     madd(fn)
                 elif ((time != mtime and time != mtime & _rangemask)
-                      and (mode & lnkkind != lnkkind or self._checklink)):
+                      and (mode & lnkkind != lnkkind or checklink)):
                     ladd(fn)
-                elif mtime == self._lastnormaltime:
+                elif mtime == lastnormaltime:
                     # fn may have been changed in the same timeslot without
                     # changing its size. This can happen if we quickly do
                     # multiple commits in a single transaction.


More information about the Mercurial-devel mailing list