git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git svn: delay importing SVN::Base until it is needed

From
JRjosh robb <josh_robb@fastmail.fm>
Date
Feb 24, 2010, 03:13 UTC
Message-ID
<13237f021002231913m77d9bc0aqd045546da3cf5a95@mail.gmail.com>

Importing functions from a .dll into Git for Windows' perl is pretty slow, so let's avoid importing if it is not necessary.

This seems particularly slow in virtualized enviroments. Before this change (on my machine):

$ time perl /libexec/git-core/git-svn rebase Current branch master is up to date.

real 2m56.750s user 0m3.129s sys 2m39.232s

Afterwards:

$ time perl /libexec/git-core/git-svn rebase Current branch master is up to date.

real 0m33.407s user 0m1.409s sys 0m23.054s

git svn rebase -n goes from 3m7.046s to 0m10.312s.
Signed-off-by: Josh Robb <josh_robb@fastmail.fm>
---
 git-svn.perl |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index 265852f..0e4572f 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -36,11 +36,13 @@ $ENV{TZ} = 'UTC';
 $| = 1; # unbuffer STDOUT

 sub fatal (@) { print STDERR "@_\n"; exit 1 }
-require SVN::Core; # use()-ing this causes segfaults for me... *shrug*
-require SVN::Ra;
-require SVN::Delta;
-if ($SVN::Core::VERSION lt '1.1.0') {
-	fatal "Need SVN::Core 1.1.0 or better (got $SVN::Core::VERSION)";
+sub _req_svn {
+	require SVN::Core; # use()-ing this causes segfaults for me... *shrug*
+	require SVN::Ra;
+	require SVN::Delta;
+	if ($SVN::Core::VERSION lt '1.1.0') {
+		fatal "Need SVN::Core 1.1.0 or better (got $SVN::Core::VERSION)";
+	}
 }
 my $can_compress = eval { require Compress::Zlib; 1};
 push @Git::SVN::Ra::ISA, 'SVN::Ra';
@@ -730,6 +732,8 @@ sub cmd_branch {
 		$src=~s/^http:/https:/;
 	}

+	::_req_svn();
+
 	my $ctx = SVN::Client->new(
 		auth    => Git::SVN::Ra::_auth_providers(),
 		log_msg => sub {
@@ -4859,6 +4863,8 @@ sub new {
 	$url =~ s!/+$!!;
 	return $RA if ($RA && $RA->{url} eq $url);

+	::_req_svn();
+
 	SVN::_Core::svn_config_ensure($config_dir, undef);
 	my ($baton, $callbacks) = SVN::Core::auth_open_helper(_auth_providers);
 	my $config = SVN::Core::config_get_config($config_dir);
-- 
1.7.0
Message 1 of 1 in “git svn: delay importing SVN::Base until it is needed”
  1. git svn: delay importing SVN::Base until it is neededjosh robb, Feb 24, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.