[PATCH 6 of 6 V7] dirstate: call the C implementation of nonnonormalentries when available

Laurent Charignon lcharignon at fb.com
Wed Dec 23 15:20:21 CST 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1450905363 28800
#      Wed Dec 23 13:16:03 2015 -0800
# Node ID f6769ae3b7cb32f18041c808117a80c6c1890323
# Parent  755fe13eac4245420e8e8065864abcbd9a3fdaa9
dirstate: call the C implementation of nonnonormalentries when available

Before this patch, we were using python code for computing the nonnormal
dirstate entries. This patch makes us use the C implementation of the function
when it is available.

Using the nonnormal set in hgwatchman improves hg status performance. Below
are the numbers for mozilla-central.

with the changes:
$ hg perfstatus
    ! wall 0.010632 comb 0.000000 user 0.000000 sys 0.000000 (best of 246)

without the changes:
$ hg perfstatus
    ! wall 0.036442 comb 0.030000 user 0.030000 sys 0.000000 (best of 100)

On mozilla-central the improvement to hg status is ~20% (0.25s to 0.2s),
on our big repos at Facebook, the win is ~40% (1.2s to 0.72s).

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -38,8 +38,11 @@ def _getfsnow(vfs):
 
 def nonnomalentries(dmap):
     '''Compute the nonnormal dirstate entries from the dmap'''
-    return set(fname for fname, e in dmap.iteritems()
-           if e[0] != 'n' or e[3] == -1)
+    try:
+        return parsers.nonnormalentries(dmap)
+    except AttributeError:
+        return set(fname for fname, e in dmap.iteritems()
+                   if e[0] != 'n' or e[3] == -1)
 
 def _trypending(root, vfs, filename):
     '''Open  file to be read according to HG_PENDING environment variable


More information about the Mercurial-devel mailing list