U
usenet
Greetings.
I am having terrible problems with very poor performance when using
Net::SFTP. Specifically, it takes about 10 seconds for a machine to
transfer a 1 MB file to itself (localhost), and this is a brand new,
very FAST, lightly loaded server (and I can replicate this problem on
other machines as well). Using ordinary FTP takes 0.4 seconds, and
doing the same thing with commandline sftp completes the task in the
blink of an eye.
I ***DO*** have Math::GMP::BigInt installed (as well as
Math:ari::BigInt), and a diagnostic dump of %INC indicates these are
being called (see below). Enabling SFTP debug mode shows that I am not
experiencing any long pauses (ie, I get a handle in 0.8 seconds, and
transfers occur at a steady - though slow - pace without any pauses).
It is doubtful that I have the option to use Net::SSH2 (because the
servers do not have libssh2 and I probably won't be able to do anything
about that). I really need to figure out why Net::SFTP is behaving so
poorly. I really appreciate any insight anyone can offer.
Here is my test script:
#!/usr/bin/perl
use strict; use warnings;
use Net::SFTP;
#Create with: dd if=/dev/urandom of=/tmp/1mb.junk bs=1024 count=1024
my $testfile = "/tmp/1mb.junk";
my %comm = (
user => 'myuserid',
password => 'mypassword',
ssh_args => [ cipher => 'blowfish-cbc' ],
debug => 0,
);
my $sftp = Net::SFTP->new('localhost', %comm) or die "oops: $@";
$sftp->put ($testfile, "$testfile.test")
or die("ftp put failed ", $sftp->message);
END{
print map{"$_\n"} sort keys %INC; #check for GMP/Pari
}
__END__
The blowfish cipher is indeed the "fastest" (as the docs indicate). I
tried the other available ciphers with inferior results:
arcfour 14 seconds
3des-cbc 22 seconds
The "interesting" parts of the %INC dump (in the END block of the test
script) look like this (and validate that GMP/Pari are being called):
Convert/ASN1 MIME/Base64
Convert/ASN1/IO Math/BigInt
Convert/ASN1/_decode Math/BigInt/GMP
Convert/ASN1/_encode Math/GMP
Convert/ASN1/parser Math/Pari
Convert/PEM Net/SFTP
Convert/PEM/CBC Net/SFTP/Attributes
Convert/PEM/ErrorHandler Net/SFTP/Buffer
Crypt/Blowfish Net/SFTP/Constants
Crypt/DH Net/SFTP/Util
Crypt/DSA Net/SSH/Perl
Crypt/DSA/Key Net/SSH/Perl/Agent
Crypt/DSA/Key/PEM Net/SSH/Perl/Auth
Crypt/DSA/KeyChain Net/SSH/Perl/Auth/Password
Crypt/DSA/Signature Net/SSH/Perl/Auth/PublicKey
Crypt/DSA/Util Net/SSH/Perl/AuthMgr
Crypt/Random Net/SSH/Perl/Buffer
Crypt/Random/Generator Net/SSH/Perl/Channel
Crypt/Random/Provider/File Net/SSH/Perl/ChannelMgr
Crypt/Random/Provider/devurandom Net/SSH/Perl/Cipher
Digest/HMAC Net/SSH/Perl/Cipher/Blowfish
Digest/HMAC_MD5 Net/SSH/Perl/Cipher/CBC
Digest/HMAC_SHA1 Net/SSH/Perl/Comp
Digest/MD5 Net/SSH/Perl/Config
Digest/SHA1 Net/SSH/Perl/Constants
Digest/base Net/SSH/Perl/Kex
Encode Net/SSH/Perl/Kex/DH1
Encode/Alias Net/SSH/Perl/Key
Encode/Config Net/SSH/Perl/Key/DSA
Encode/Encoding Net/SSH/Perl/Mac
Fcntl Net/SSH/Perl/Packet
IO Net/SSH/Perl/SSH2
IO/Handle Net/SSH/Perl/Util
IO/Select Net/SSH/Perl/Util/Hosts
IO/Socket Net/SSH/Perl/Util/SSH2MP
IO/Socket/INET Net/SSH/Perl/Util/Term
IO/Socket/UNIX
I ran the script thorough Devel:rofile (perl -drofile test.pl); the
top results (> 1.0%) are:
time elapsed (wall): 12.8377
time running program: 9.6744 (75.36%)
time profiling (est.): 3.1633 (24.64%)
number of calls: 361634
number of exceptions: 11
%Time Sec. #calls sec/call name
28.05 2.714 131970 0.000021 Crypt::Blowfish::encrypt
23.32 2.256 139 0.016228 Net::SSH:erl::Cipher::CBC::encrypt
10.08 0.975 282 0.003458 IO::Select::select
5.53 0.535 32 0.016733 IO::Select::can_read
4.51 0.437 132840 0.000003 Crypt::Blowfish::crypt
2.78 0.269 59 0.004553 Net::SSH:erl::Util::SSH2MP::bin2mp
2.52 0.244 144 0.001693 Net::SSH:erl::Util::SSH2MP::mp2bin
1.47 0.142 1035 0.000137 Net::SSH:erl::Buffer::new
1.25 0.121 449 0.000269 Net::SSH:erl:acket::read_poll_ssh2
1.12 0.109 1041 0.000104 Net::SSH:erl::Util::import
So the machine is definitely spending most of its time with the crypto
stuff (not I/O stuff), which is to be expected, but it is taking a LONG
time to do the crypto stuff.
I know that Math::BigInt::GMP (or Pari) is very important for SFTP
performance. But I have both libraries and their BigInt modules
installed. Is there ANOTHER math module that I need???
I'm happy to entertain any "try this and see what happens" ideas.
Thanks!
I am having terrible problems with very poor performance when using
Net::SFTP. Specifically, it takes about 10 seconds for a machine to
transfer a 1 MB file to itself (localhost), and this is a brand new,
very FAST, lightly loaded server (and I can replicate this problem on
other machines as well). Using ordinary FTP takes 0.4 seconds, and
doing the same thing with commandline sftp completes the task in the
blink of an eye.
I ***DO*** have Math::GMP::BigInt installed (as well as
Math:ari::BigInt), and a diagnostic dump of %INC indicates these are
being called (see below). Enabling SFTP debug mode shows that I am not
experiencing any long pauses (ie, I get a handle in 0.8 seconds, and
transfers occur at a steady - though slow - pace without any pauses).
It is doubtful that I have the option to use Net::SSH2 (because the
servers do not have libssh2 and I probably won't be able to do anything
about that). I really need to figure out why Net::SFTP is behaving so
poorly. I really appreciate any insight anyone can offer.
Here is my test script:
#!/usr/bin/perl
use strict; use warnings;
use Net::SFTP;
#Create with: dd if=/dev/urandom of=/tmp/1mb.junk bs=1024 count=1024
my $testfile = "/tmp/1mb.junk";
my %comm = (
user => 'myuserid',
password => 'mypassword',
ssh_args => [ cipher => 'blowfish-cbc' ],
debug => 0,
);
my $sftp = Net::SFTP->new('localhost', %comm) or die "oops: $@";
$sftp->put ($testfile, "$testfile.test")
or die("ftp put failed ", $sftp->message);
END{
print map{"$_\n"} sort keys %INC; #check for GMP/Pari
}
__END__
The blowfish cipher is indeed the "fastest" (as the docs indicate). I
tried the other available ciphers with inferior results:
arcfour 14 seconds
3des-cbc 22 seconds
The "interesting" parts of the %INC dump (in the END block of the test
script) look like this (and validate that GMP/Pari are being called):
Convert/ASN1 MIME/Base64
Convert/ASN1/IO Math/BigInt
Convert/ASN1/_decode Math/BigInt/GMP
Convert/ASN1/_encode Math/GMP
Convert/ASN1/parser Math/Pari
Convert/PEM Net/SFTP
Convert/PEM/CBC Net/SFTP/Attributes
Convert/PEM/ErrorHandler Net/SFTP/Buffer
Crypt/Blowfish Net/SFTP/Constants
Crypt/DH Net/SFTP/Util
Crypt/DSA Net/SSH/Perl
Crypt/DSA/Key Net/SSH/Perl/Agent
Crypt/DSA/Key/PEM Net/SSH/Perl/Auth
Crypt/DSA/KeyChain Net/SSH/Perl/Auth/Password
Crypt/DSA/Signature Net/SSH/Perl/Auth/PublicKey
Crypt/DSA/Util Net/SSH/Perl/AuthMgr
Crypt/Random Net/SSH/Perl/Buffer
Crypt/Random/Generator Net/SSH/Perl/Channel
Crypt/Random/Provider/File Net/SSH/Perl/ChannelMgr
Crypt/Random/Provider/devurandom Net/SSH/Perl/Cipher
Digest/HMAC Net/SSH/Perl/Cipher/Blowfish
Digest/HMAC_MD5 Net/SSH/Perl/Cipher/CBC
Digest/HMAC_SHA1 Net/SSH/Perl/Comp
Digest/MD5 Net/SSH/Perl/Config
Digest/SHA1 Net/SSH/Perl/Constants
Digest/base Net/SSH/Perl/Kex
Encode Net/SSH/Perl/Kex/DH1
Encode/Alias Net/SSH/Perl/Key
Encode/Config Net/SSH/Perl/Key/DSA
Encode/Encoding Net/SSH/Perl/Mac
Fcntl Net/SSH/Perl/Packet
IO Net/SSH/Perl/SSH2
IO/Handle Net/SSH/Perl/Util
IO/Select Net/SSH/Perl/Util/Hosts
IO/Socket Net/SSH/Perl/Util/SSH2MP
IO/Socket/INET Net/SSH/Perl/Util/Term
IO/Socket/UNIX
I ran the script thorough Devel:rofile (perl -drofile test.pl); the
top results (> 1.0%) are:
time elapsed (wall): 12.8377
time running program: 9.6744 (75.36%)
time profiling (est.): 3.1633 (24.64%)
number of calls: 361634
number of exceptions: 11
%Time Sec. #calls sec/call name
28.05 2.714 131970 0.000021 Crypt::Blowfish::encrypt
23.32 2.256 139 0.016228 Net::SSH:erl::Cipher::CBC::encrypt
10.08 0.975 282 0.003458 IO::Select::select
5.53 0.535 32 0.016733 IO::Select::can_read
4.51 0.437 132840 0.000003 Crypt::Blowfish::crypt
2.78 0.269 59 0.004553 Net::SSH:erl::Util::SSH2MP::bin2mp
2.52 0.244 144 0.001693 Net::SSH:erl::Util::SSH2MP::mp2bin
1.47 0.142 1035 0.000137 Net::SSH:erl::Buffer::new
1.25 0.121 449 0.000269 Net::SSH:erl:acket::read_poll_ssh2
1.12 0.109 1041 0.000104 Net::SSH:erl::Util::import
So the machine is definitely spending most of its time with the crypto
stuff (not I/O stuff), which is to be expected, but it is taking a LONG
time to do the crypto stuff.
I know that Math::BigInt::GMP (or Pari) is very important for SFTP
performance. But I have both libraries and their BigInt modules
installed. Is there ANOTHER math module that I need???
I'm happy to entertain any "try this and see what happens" ideas.
Thanks!