Let "git svn" run "git gc --auto" occasionally
Let "git svn" run "git gc --auto" every 1000 imported commits to reduce the number of loose objects. To handle the common use case of frequent imports, where each invocation typically fetches much less than 1000 commits, also run gc unconditionally at the end of the import. "1000" is the same number that was used by default when we called git-repack. It isn't necessarily still the best choice. Signed-off-by: Karl Hasselström <kha@treskal.com> Acked-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Karl Hasselström committed
Feb 3, 2008 at 17:56 UTC
94bc914c5e1e46160f79e743ec369e483bf9f5cd
1 file changed
+12
git-svn.perl
+12
@@ -1247,6 +1247,8 @@ use File::Path qw/mkpath/;
1247
use File::Copy qw/copy/;
1248
use IPC::Open3;
1249
1250
+my ($_gc_nr, $_gc_period);
1251
+
1252
# properties that we do not log:
1253
my %SKIP_PROP;
1254
BEGIN {
@@ -1407,6 +1409,7 @@ sub read_all_remotes {
1409
}
1410
1411
sub init_vars {
1412
+ $_gc_nr = $_gc_period = 1000;
1413
if (defined $_repack || defined $_repack_flags) {
1414
warn "Repack options are obsolete; they have no effect.\n";
1415
}
@@ -2095,6 +2098,10 @@ sub restore_commit_header_env {
2098
}
2099
}
2100
2101
+sub gc {
2102
+ command_noisy('gc', '--auto');
2103
+};
2104
+
2105
sub do_git_commit {
2106
my ($self, $log_entry) = @_;
2107
my $lr = $self->last_rev;
@@ -2148,6 +2155,10 @@ sub do_git_commit {
2155
0, $self->svm_uuid);
2156
}
2157
print " = $commit ($self->{ref_id})\n";
2158
+ if (--$_gc_nr == 0) {
2159
+ $_gc_nr = $_gc_period;
2160
+ gc();
2161
+ }
2162
return $commit;
2163
}
2164
@@ -3975,6 +3986,7 @@ sub gs_fetch_loop_common {
3986
$max += $inc;
3987
$max = $head if ($max > $head);
3988
}
3989
+ Git::SVN::gc();
3990
}
3991
3992
sub match_globs {