dirstate: use parsers.make_file_foldmap when available
authorSiddharth Agarwal <sid0@fb.com>
Wed, 01 Apr 2015 00:44:33 -0700
changeset 24610 4a4018831d2e
parent 24609 670aaee7931c
child 24611 82fddb3d6bc0
dirstate: use parsers.make_file_foldmap when available This is a significant performance win on large repositories. perffilefoldmap: On Linux/gcc, on a test repo with over 500,000 files: before: wall 0.605021 comb 0.600000 user 0.560000 sys 0.040000 (best of 17) after: wall 0.280530 comb 0.280000 user 0.250000 sys 0.030000 (best of 35) On Mac OS X/clang, on a real-world repo with over 200,000 files: before: wall 0.281103 comb 0.280000 user 0.260000 sys 0.020000 (best of 34) after: wall 0.133622 comb 0.140000 user 0.120000 sys 0.020000 (best of 65) This visibly impacts status times on case-insensitive file systems. On the Mac OS X repo, status goes from 3.64 seconds to 3.50. With the third-party hgwatchman extension [1], 'hg status' on the same repo goes from 0.80 seconds to 0.65. [1] https://bitbucket.org/facebook/hgwatchman
mercurial/dirstate.py
--- a/mercurial/dirstate.py	Tue Mar 31 23:32:27 2015 -0700
+++ b/mercurial/dirstate.py	Wed Apr 01 00:44:33 2015 -0700
@@ -88,6 +88,14 @@
 
     @propertycache
     def _filefoldmap(self):
+        try:
+            makefilefoldmap = parsers.make_file_foldmap
+        except AttributeError:
+            pass
+        else:
+            return makefilefoldmap(self._map, util.normcasespec,
+                                   util.normcasefallback)
+
         f = {}
         normcase = util.normcase
         for name, s in self._map.iteritems():