git svn: delay importing SVN::Base until it is needed

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>
Acked-by: Eric Wong <normalperson@yhbt.net>
This commit is contained in:
josh robb 2010-02-24 16:13:50 +13:00 коммит произвёл Eric Wong
Родитель 6a2009e7f3
Коммит d32fad2b89
1 изменённых файлов: 11 добавлений и 5 удалений

Просмотреть файл

@ -36,12 +36,14 @@ $ENV{TZ} = 'UTC';
$| = 1; # unbuffer STDOUT $| = 1; # unbuffer STDOUT
sub fatal (@) { print STDERR "@_\n"; exit 1 } sub fatal (@) { print STDERR "@_\n"; exit 1 }
sub _req_svn {
require SVN::Core; # use()-ing this causes segfaults for me... *shrug* require SVN::Core; # use()-ing this causes segfaults for me... *shrug*
require SVN::Ra; require SVN::Ra;
require SVN::Delta; require SVN::Delta;
if ($SVN::Core::VERSION lt '1.1.0') { if ($SVN::Core::VERSION lt '1.1.0') {
fatal "Need SVN::Core 1.1.0 or better (got $SVN::Core::VERSION)"; fatal "Need SVN::Core 1.1.0 or better (got $SVN::Core::VERSION)";
} }
}
my $can_compress = eval { require Compress::Zlib; 1}; my $can_compress = eval { require Compress::Zlib; 1};
push @Git::SVN::Ra::ISA, 'SVN::Ra'; push @Git::SVN::Ra::ISA, 'SVN::Ra';
push @SVN::Git::Editor::ISA, 'SVN::Delta::Editor'; push @SVN::Git::Editor::ISA, 'SVN::Delta::Editor';
@ -730,6 +732,8 @@ sub cmd_branch {
$src=~s/^http:/https:/; $src=~s/^http:/https:/;
} }
::_req_svn();
my $ctx = SVN::Client->new( my $ctx = SVN::Client->new(
auth => Git::SVN::Ra::_auth_providers(), auth => Git::SVN::Ra::_auth_providers(),
log_msg => sub { log_msg => sub {
@ -4859,6 +4863,8 @@ sub new {
$url =~ s!/+$!!; $url =~ s!/+$!!;
return $RA if ($RA && $RA->{url} eq $url); return $RA if ($RA && $RA->{url} eq $url);
::_req_svn();
SVN::_Core::svn_config_ensure($config_dir, undef); SVN::_Core::svn_config_ensure($config_dir, undef);
my ($baton, $callbacks) = SVN::Core::auth_open_helper(_auth_providers); my ($baton, $callbacks) = SVN::Core::auth_open_helper(_auth_providers);
my $config = SVN::Core::config_get_config($config_dir); my $config = SVN::Core::config_get_config($config_dir);