[PATCH] largefiles: optimize performance when updating (issue3440)

Na'Tosha Bard natosha at unity3d.com
Sat May 12 08:45:29 CDT 2012


# HG changeset patch
# User Na'Tosha Bard <natosha at unity3d.com>
# Date 1336830087 -7200
# Node ID 418599662b77bae8d92e38c98f627d1af8e1f638
# Parent  b496a35f805990dfc5502cdae52b52096a56df7c
largefiles: optimize performance when updating (issue3440)

Previously, when updating, cachelfiles was called blindly on all largefiles
in the repository at the revision being updated to, despite the fact that
a list of which largefiles needs to be updated has already been collected.  This
optimization constrains the cachelfiles call to only the largefiles that need
to be updated.

On a repository with about 80 largefiles, updating between two revisions that
only change one largefile goes from approximately 6.7 seconds to 3.3 seconds.

diff -r b496a35f8059 -r 418599662b77 hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py	Sat May 12 11:45:22 2012 +0200
+++ b/hgext/largefiles/lfcommands.py	Sat May 12 15:41:27 2012 +0200
@@ -365,7 +365,7 @@
     store = basestore._openstore(repo)
     return store.verify(revs, contents=contents)
 
-def cachelfiles(ui, repo, node):
+def cachelfiles(ui, repo, node, filelist=None):
     '''cachelfiles ensures that all largefiles needed by the specified revision
     are present in the repository's largefile cache.
 
@@ -373,6 +373,8 @@
     by this operation; missing is the list of files that were needed but could
     not be found.'''
     lfiles = lfutil.listlfiles(repo, node)
+    if filelist:
+        lfiles = set(lfiles) & set(filelist)
     toget = []
 
     for lfile in lfiles:
@@ -431,7 +433,7 @@
         if printmessage and lfiles:
             ui.status(_('getting changed largefiles\n'))
             printed = True
-            cachelfiles(ui, repo, '.')
+            cachelfiles(ui, repo, '.', lfiles)
 
         updated, removed = 0, 0
         for i in map(lambda f: _updatelfile(repo, lfdirstate, f), lfiles):


More information about the Mercurial-devel mailing list