Skip to content

Commit dfa72fd

Browse files
author
Eric Wong
committed
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 <[email protected]>
1 parent f947ae4 commit dfa72fd

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

perl/Git/SVN/Ra.pm

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,19 @@ sub longest_common_path {
376376
sub gs_fetch_loop_common {
377377
my ($self, $base, $head, $gsv, $globs) = @_;
378378
return if ($base > $head);
379+
my $gpool = SVN::Pool->new_default;
380+
my $ra_url = $self->url;
381+
my $reload_ra = sub {
382+
$_[0] = undef;
383+
$self = undef;
384+
$RA = undef;
385+
$gpool->clear;
386+
$self = Git::SVN::Ra->new($ra_url);
387+
$ra_invalid = undef;
388+
};
379389
my $inc = $_log_window_size;
380390
my ($min, $max) = ($base, $head < $base + $inc ? $head : $base + $inc);
381391
my $longest_path = longest_common_path($gsv, $globs);
382-
my $ra_url = $self->url;
383392
my $find_trailing_edge;
384393
while (1) {
385394
my %revs;
@@ -449,13 +458,7 @@ sub gs_fetch_loop_common {
449458
"$g->{t}-maxRev";
450459
Git::SVN::tmp_config($k, $r);
451460
}
452-
if ($ra_invalid) {
453-
$_[0] = undef;
454-
$self = undef;
455-
$RA = undef;
456-
$self = Git::SVN::Ra->new($ra_url);
457-
$ra_invalid = undef;
458-
}
461+
$reload_ra->() if $ra_invalid;
459462
}
460463
# pre-fill the .rev_db since it'll eventually get filled in
461464
# with '0' x40 if something new gets committed
@@ -472,6 +475,8 @@ sub gs_fetch_loop_common {
472475
$min = $max + 1;
473476
$max += $inc;
474477
$max = $head if ($max > $head);
478+
479+
$reload_ra->();
475480
}
476481
Git::SVN::gc();
477482
}

0 commit comments

Comments
 (0)