[PATCH 2/2] Let "git svn" run "git gc --auto" occasionally

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Eric Wong <normalperson@...>
Cc: <git@...>, Harvey Harrison <harvey.harrison@...>, Kevin Ballard <kevin@...>, Junio C Hamano <gitster@...>
Date: Sunday, January 20, 2008 - 5:40 pm

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>

---

 git-svn.perl |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)


diff --git a/git-svn.perl b/git-svn.perl
index 988d8f6..be4105c 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1247,6 +1247,8 @@ use File::Path qw/mkpath/;
 use File::Copy qw/copy/;
 use IPC::Open3;
 
+my ($_gc_nr, $_gc_period);
+
 # properties that we do not log:
 my %SKIP_PROP;
 BEGIN {
@@ -1407,6 +1409,7 @@ sub read_all_remotes {
 }
 
 sub init_vars {
+	$_gc_nr = $_gc_period = 1000;
 	if (defined $_repack || defined $_repack_flags) {
                warn "Repack options are obsolete; they have no effect.\n";
 	}
@@ -2095,6 +2098,10 @@ sub restore_commit_header_env {
 	}
 }
 
+sub gc {
+	command_noisy('gc', '--auto');
+};
+
 sub do_git_commit {
 	my ($self, $log_entry) = @_;
 	my $lr = $self->last_rev;
@@ -2148,6 +2155,10 @@ sub do_git_commit {
 		                   0, $self->svm_uuid);
 	}
 	print " = $commit ($self->{ref_id})\n";
+	if (--$_gc_nr == 0) {
+		$_gc_nr = $_gc_period;
+		gc();
+	}
 	return $commit;
 }
 
@@ -3975,6 +3986,7 @@ sub gs_fetch_loop_common {
 		$max += $inc;
 		$max = $head if ($max > $head);
 	}
+	Git::SVN::gc();
 }
 
 sub match_globs {

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
git-svn should default to --repack, Kevin Ballard, (Fri Jan 18, 8:17 am)
Re: git-svn should default to --repack, Karl , (Fri Jan 18, 11:56 am)
Re: git-svn should default to --repack, Junio C Hamano, (Fri Jan 18, 4:44 pm)
Re: git-svn should default to --repack, Karl , (Sat Jan 19, 8:35 am)
Re: git-svn should default to --repack, Kevin Ballard, (Sat Jan 19, 11:05 am)
Re: [PATCH] Let "git svn" run "git gc --auto" occasionally, Harvey Harrison, (Sat Jan 19, 6:50 pm)
Re: [PATCH] Let "git svn" run "git gc --auto" occasionally, Junio C Hamano, (Sun Jan 20, 3:17 pm)
Re: [PATCH] Let "git svn" run "git gc --auto" occasionally, Junio C Hamano, (Mon Jan 21, 8:30 pm)
Re: [PATCH] Let "git svn" run "git gc --auto" occasionally, Junio C Hamano, (Mon Jan 21, 9:52 pm)
git filter-branch should run git gc --auto, Kevin Ballard, (Tue Jan 22, 10:43 pm)
Re: git filter-branch should run git gc --auto, Junio C Hamano, (Tue Jan 22, 10:46 pm)
Re: git filter-branch should run git gc --auto, Junio C Hamano, (Tue Jan 22, 10:52 pm)
Re: git filter-branch should run git gc --auto, Kevin Ballard, (Tue Jan 22, 11:03 pm)
Re: git filter-branch should run git gc --auto, Kevin Ballard, (Tue Jan 22, 10:58 pm)
Re: git filter-branch should run git gc --auto, Sam Vilain, (Wed Jan 23, 1:07 am)
Re: git filter-branch should run git gc --auto, Kevin Ballard, (Wed Jan 23, 4:18 am)
Re: git filter-branch should run git gc --auto, Mike Hommey, (Wed Jan 23, 2:44 am)
Re: git filter-branch should run git gc --auto, Johannes Schindelin, (Wed Jan 23, 9:00 am)
Re: git filter-branch should run git gc --auto, Junio C Hamano, (Wed Jan 23, 3:22 pm)
Re: git filter-branch should run git gc --auto, Harvey Harrison, (Tue Jan 22, 10:54 pm)
[PATCH 0/2] "git svn" and "git gc --auto", Karl , (Sun Feb 3, 12:55 pm)
[PATCH 2/2] Let "git svn" run "git gc --auto" occasionally, Karl , (Sun Jan 20, 5:40 pm)