[PATCH 4 of 4] changegroup: use persistent read handle on changelog

Gregory Szorc gregory.szorc at gmail.com
Tue Jul 14 15:51:13 CDT 2015


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1436906869 25200
#      Tue Jul 14 13:47:49 2015 -0700
# Node ID a5aef0c6311664026c7fef25c08aca857a3a35c3
# Parent  3c74157a105dc99514775809a99d7ba0f950c614
changegroup: use persistent read handle on changelog

Previously, the scan of the changelog would open and close and changelog
index several times. Using the persistent read handle context manager
reduces the open/close count to 1.

While this drastically reduces the number of system calls, no
statistically significant performance change was measured on my MBP.
But, syscall reduction is syscall reduction. And, having a persistent
file handle opens the door to future improvements, such as using an
automatically caching file handle type.

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -758,10 +758,11 @@ def addchangegroup(repo, source, srctype
         if not (srccontent or emptyok):
             raise util.Abort(_("received changelog group is empty"))
         clend = len(cl)
         changesets = clend - clstart
-        for c in xrange(clstart, clend):
-            efiles.update(repo[c].files())
+        with cl.persistentreadhandle():
+            for c in xrange(clstart, clend):
+                efiles.update(repo[c].files())
         efiles = len(efiles)
         repo.ui.progress(_('changesets'), None)
 
         # pull off the manifest group


More information about the Mercurial-devel mailing list