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

mail settings
Submitter Gregory Szorc
Date Nov. 7, 2014, 8:12 a.m.
Message ID <87945ee4a50d8e639a73.1415347930@gps-mbp.local>
Download mbox | patch
Permalink /patch/6630/
State Accepted
Headers show


Gregory Szorc - Nov. 7, 2014, 8:12 a.m.
# HG changeset patch
# User Gregory Szorc <>
# 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/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -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,