[PATCH 1 of 8 STABLE RFC] largefiles: performance improvement for bypass route choice

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Fri Feb 17 16:07:27 UTC 2012


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1329494572 -32400
# Branch stable
# Node ID be820a2353e7b3e9af8a59b050cd7bf8b1e38490
# Parent  0e0060bf2f440d5cc33e5f36d99868a5380debd4
largefiles: performance improvement for bypass route choice

in current implementation, "performance boost" route is chosen if:

    there are any entries which which specified pattern matches in
    lfdirstate

but this requires full scan of lfdirstate entries in the worst case.

with this patch, "performance boost" route is chosen if:

    - 2nd context is "working directory" (because lfdirstate may not
      have valid entries for target context, in other cases), and

    - there is no file or directory corresponded to specified patterns
      under STANDIN directory

this reduces main cost factor of examination from O(N of lfdirstate)
to O(N of match.files): it is assumed that "N of lfdirstate" is bigger
enough thatn "N of match.files", because the later is given from command
line.

diff -r 0e0060bf2f44 -r be820a2353e7 hgext/largefiles/reposetup.py
--- a/hgext/largefiles/reposetup.py	Mon Feb 13 17:22:35 2012 +0100
+++ b/hgext/largefiles/reposetup.py	Sat Feb 18 01:02:52 2012 +0900
@@ -109,6 +109,9 @@
                     except KeyError:
                         return False
 
+                def hasstandin(f):
+                    return os.path.lexists(repo.wjoin(lfutil.standin(f)))
+
                 if match is None:
                     match = match_.always(self.root, self.getcwd())
 
@@ -117,9 +120,9 @@
                 # largefiles, we should just bail here and let super
                 # handle it -- thus gaining a big performance boost.
                 lfdirstate = lfutil.openlfdirstate(ui, self)
-                if match.files() and not match.anypats():
-                    for f in lfdirstate:
-                        if match(f):
+                if working and match.files() and not match.anypats():
+                    for f in match.files():
+                        if (f in lfdirstate) or hasstandin(f):
                             break
                     else:
                         return super(lfiles_repo, self).status(node1, node2,



More information about the Mercurial-devel mailing list