[PATCH] 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@...>, Kevin Ballard <kevin@...>, Junio C Hamano <gitster@...>
Date: Saturday, January 19, 2008 - 6:36 pm

Let "git svn" run "git gc --auto" every 100 imported commits, to
reduce the number of loose objects.

To handle the common use case of frequent imports, where each
invocation typically fetches less than 100 commits, randomly set the
counter to something in the range 1-100 on initialization. It's almost
as good as saving the counter, and much less of a hassle.

Oh, and 100 is just my best guess at a reasonable number. It could
conceivably need tweaking.

Signed-off-by: Karl Hasselström <kha@treskal.com>

---

On 2008-01-19 13:35:57 +0100, Karl Hasselström wrote:


OK, it didn't feel good saying that. So here's my attempt at being a
model citizen. (It's not hard with a change this small ...)

I'm not quite sure how this should interact with the --repack flag.
Right now they just coexist, except for never running right after one
another, but conceivably we should do something cleverer. Eric?

 git-svn.perl |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)


diff --git a/git-svn.perl b/git-svn.perl
index 9f2b587..89e1d61 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1247,7 +1247,7 @@ use File::Path qw/mkpath/;
 use File::Copy qw/copy/;
 use IPC::Open3;
 
-my $_repack_nr;
+my ($_repack_nr, $_gc_nr, $_gc_period);
 # properties that we do not log:
 my %SKIP_PROP;
 BEGIN {
@@ -1413,6 +1413,8 @@ sub init_vars {
 		$_repack_nr = $_repack;
 		$_repack_flags ||= '-d';
 	}
+	$_gc_period = 100;
+	$_gc_nr = int(rand($_gc_period)) + 1;
 }
 
 sub verify_remotes_sanity {
@@ -2157,6 +2159,9 @@ sub do_git_commit {
 		print "Running git repack $_repack_flags ...\n";
 		command_noisy('repack', split(/\s+/, $_repack_flags));
 		print "Done repacking\n";
+	} elsif (--$_gc_nr == 0) {
+		$_gc_nr = $_gc_period;
+		command_noisy('gc', '--auto');
 	}
 	return $commit;
 }

-
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)
[PATCH] Let "git svn" run "git gc --auto" occasionally, Karl , (Sat Jan 19, 6:36 pm)
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)