changegroup: don't store unused value on fnodes (issue4443) stable
authorGregory Szorc <gregory.szorc@gmail.com>
Thu, 06 Nov 2014 22:33:48 -0800
branchstable
changeset 23225 bdf7b1ea1dae
parent 23224 f4ab47ccefde
child 23226 5dcaed20b27c
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.
mercurial/changegroup.py
--- a/mercurial/changegroup.py	Thu Nov 06 20:57:12 2014 -0800
+++ b/mercurial/changegroup.py	Thu Nov 06 22:33:48 2014 -0800
@@ -369,7 +369,7 @@
                         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,