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

login
register
mail settings
Submitter Gregory Szorc
Date July 14, 2015, 8:51 p.m.
Message ID <a5aef0c6311664026c7f.1436907073@gps-mbp.local>
Download mbox | patch
Permalink /patch/9986/
State Changes Requested
Headers show

Comments

Gregory Szorc - July 14, 2015, 8:51 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@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.

Patch

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