git-svn: reload RA every log-window-size
commitdfa72fdb96befbd790f623bb2909a347176753c2
authorEric Wong <normalperson@yhbt.net>
Fri, 24 Oct 2014 22:53:52 +0000 (24 22:53 +0000)
committerEric Wong <normalperson@yhbt.net>
Fri, 24 Oct 2014 22:56:06 +0000 (24 22:56 +0000)
tree38ece2a37a3d7b8c1813bda7a13f680564023f5b
parentf947ae4b655b5354ca2a7c2456e04d6567921160
git-svn: reload RA every log-window-size

Despite attempting to use local memory pools everywhere we can,
(including our call to SVN::Ra::do_update and all subsequent reporter
calls), there does not appear to be a way to force the Git::SVN::Fetcher
callbacks to use a pool other than the per-SVN::Ra pool.
Git::SVN::Fetcher ends up using the main RA pool which grows
monotonically in size for the lifetime of the RA object.

Thus the only way to free that memory appears to be to destroy and
recreate the RA connection for at every --log-window-size interval.

This reduces memory usage over the course of fetching 10K revisions
using a test repository created with the script at the end of this
commit message.

As reported by time(1) on my x86-64 system:

before: 54024k
 after: 28680k

Unfortunately, there remains some yet-to-be-tracked-down slow memory
growth which would be evident as the `nr' parameter increases in
the repository generation script:
-----------------------------8<------------------------------
set -e
tmp=$(mktemp -d svntestrepo-XXXXXXXX)
svnadmin create "$tmp"
repo=file://"$(cd $tmp && pwd)"
svn co "$repo" "$tmp/wd"
cd "$tmp/wd"
if ! test -f a
then
> a
svn add a
svn commit -m 'A'
fi

nr=10000
while test $nr -gt 0
do
echo $nr > a
svn commit -q -m A
nr=$((nr - 1))
done
echo "repository created in $repo"
-----------------------------8<------------------------------

Signed-off-by: Eric Wong <normalperson@yhbt.net>
perl/Git/SVN/Ra.pm