[PATCH 2 of 3 stable] changegroup: don't store unused value on fnodes (issue4443)

Gregory Szorc gregory.szorc at gmail.com
Fri Nov 7 02:12:10 CST 2014


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1415342028 28800
#      Thu Nov 06 22:33:48 2014 -0800
# Node ID 87945ee4a50d8e639a737d72f8e5c1e8a45441da
# Parent  b6b91dd825e07fcfe67403f5716fc23e2e30f8c3
changegroup: don't store unused value on fnodes (issue4443)

The contents of fnodes are only accessed once per key. It is wasteful to
cache the value since nobody will use it.

Before this patch, the caching of unused data in fnodes was effectively
causing a memory leak during the file streaming part of bundle creation.

On mozilla-central (which has ~190,000 entries in fnodes), this patch
has a significant impact on RSS at the end of generate():

before:  516,124 KB
after:   364,356 KB
delta:  -151,768 KB

The origin of this code can be traced back to 627cd7842e5d and has been
with us since the 2.7 release.

diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -377,9 +377,9 @@ class cg1packer(object):
                     for r in filerevlog:
                         linkrev = llr(r)
                         if linkrev in needed:
                             yield filerevlog.node(r), cl.node(linkrev)
-                fnodes[fname] = dict(genfilenodes())
+                return dict(genfilenodes())
             return fnodes.get(fname, {})
 
         for chunk in self.generatefiles(changedfiles, linknodes, commonrevs,
                                         source):


More information about the Mercurial-devel mailing list