[PATCH 03 of 10] wireproto: don't audit local paths during stream_out

Bryan O'Sullivan bos at serpentine.com
Thu Sep 13 14:01:16 CDT 2012


# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1347562629 25200
# Node ID f85d5c5b428594aeccc4ce0a81786f53eea9039c
# Parent  d89e56d72ecf0ef69b1650aac774667297969622
wireproto: don't audit local paths during stream_out

Auditing at this stage is both pointless (they're already trusted by
the local repo) and expensive. Skipping the audits improves stream_out
performance by about 15%.

diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -545,12 +545,21 @@
         repo.ui.debug('%d files, %d bytes to transfer\n' %
                       (len(entries), total_bytes))
         yield '%d %d\n' % (len(entries), total_bytes)
-        for name, size in entries:
-            repo.ui.debug('sending %s (%d bytes)\n' % (name, size))
-            # partially encode name over the wire for backwards compat
-            yield '%s\0%d\n' % (store.encodedir(name), size)
-            for chunk in util.filechunkiter(repo.sopener(name), limit=size):
-                yield chunk
+
+        sopener = repo.sopener
+
+        try:
+            oldaudit = sopener.mustaudit
+            sopener.mustaudit = False
+
+            for name, size in entries:
+                repo.ui.debug('sending %s (%d bytes)\n' % (name, size))
+                # partially encode name over the wire for backwards compat
+                yield '%s\0%d\n' % (store.encodedir(name), size)
+                for chunk in util.filechunkiter(sopener(name), limit=size):
+                    yield chunk
+        finally:
+            sopener.mustaudit = oldaudit
 
     return streamres(streamer(repo, entries, total_bytes))
 


More information about the Mercurial-devel mailing list