Trasteando con Debian y Net::SSH::Perl se observa que el rendimiento a la hora de conectarse a las máquina en bajísimo, muy muy lento.
Vamos a buscar la solución…
Primero analizamos el script de Perl con una librería de Profiler, en este caso, usamos esta que está en pruebas DProfLB
ejecutamos:
[shell]perl -d:DProfLB test_ssh.pl
# dprofpp
Total Elapsed Time = 31.78279 Seconds
User+System Time = 30.61279 Seconds
Exclusive Times
%Time ExclSec CumulS #Calls sec/call Csec/c Name
62.8 19.25 19.317 3779 0.0051 0.0051 Math::BigInt::Calc::_div_use_div
35.2 10.79 10.861 3721 0.0029 0.0029 Math::BigInt::Calc::_mul_use_div
0.43 0.133 0.133 10678 0.0000 0.0000 Math::BigInt::Calc::__strip_zeros
0.19 0.058 19.366 3688 0.0000 0.0053 Math::BigInt::Calc::_mod
0.13 0.040 0.040 7973 0.0000 0.0000 Math::Pari::DESTROY
0.11 0.033 0.078 10 0.0033 0.0078 Net::SSH::Perl::Util::SSH2MP::mp2bin
0.10 0.030 0.030 7 0.0043 0.0042 Exporter::export
0.08 0.026 0.040 89 0.0003 0.0004 :(eval
0.07 0.020 0.047 1 0.0198 0.0471 :/usr/share/perl5/Crypt/DH.pm:6
0.07 0.020 0.083 11 0.0018 0.0075 :/usr/local/share/perl/5.8.8/Net/SSH/Perl/SSH2.pm:6
0.06 0.019 0.016 70 0.0003 0.0002 Net::SSH::Perl::Buffer::new
0.06 0.018 0.021 5 0.0036 0.0043 Math::BigInt::Calc::_as_bin
0.05 0.016 0.016 1395 0.0000 0.0000 Math::Pari::_gmul
0.05 0.016 0.016 1399 0.0000 0.0000 Math::Pari::_gadd
0.05 0.014 0.048 15 0.0009 0.0032 Net::SSH::Perl::Util::SSH2MP::bin2mp
[/shell]Aquí tenemos el cuello de botella:
[shell] 62.8 19.25 19.317 3779 0.0051 0.0051 Math::BigInt::Calc::_div_use_div
35.2 10.79 10.861 3721 0.0029 0.0029 Math::BigInt::Calc::_mul_use_div
[/shell]Vamos a ver qué paquete tenemos de matematicas
[shell] # dpkg -l | grep math | awk ‘ {print $2} ‘
libmath-gmp-perl
[/shell]y ahora a ver que librerías salen en el repositorio
[shell] # apt-cache search math bigint perl
libmath-bigint-gmp-perl – GMP library for Math::BigInt routines
libmath-gmp-perl – high speed arbitrary size integer math for perl
perl-modules – Core Perl modules
[/shell]Este suena bien libmath-bigint-gmp-perl – GMP library for Math::BigInt routines
lo instalamos :
[shell] apt-get install libmath-bigint-gmp-perl [/shell]y ahora lo probamos
[shell] # dprofpp
Total Elapsed Time = 1.406720 Seconds
User+System Time = 0.336720 Seconds
Exclusive Times
%Time ExclSec CumulS #Calls sec/call Csec/c Name
11.8 0.040 0.040 7978 0.0000 0.0000 Math::Pari::DESTROY
8.91 0.030 0.038 1 0.0298 0.0376 :/usr/share/perl5/Crypt/DH.pm:6
8.61 0.029 0.038 75 0.0004 0.0005 Net::SSH::Perl::Util::import
5.64 0.019 0.019 82 0.0002 0.0002 Exporter::import
5.35 0.018 0.061 80 0.0002 0.0008 :(eval
5.05 0.017 0.017 1282 0.0000 0.0000 Math::Pari::_gdiv
4.75 0.016 0.016 1397 0.0000 0.0000 Math::Pari::_gmul
3.86 0.013 0.058 10 0.0013 0.0058 Net::SSH::Perl::Util::SSH2MP::mp2bin
2.97 0.010 0.010 1 0.0100 0.0100 :/usr/share/perl/5.8/File/Spec/Unix.pm:3
2.97 0.010 0.010 1 0.0100 0.0100 :/usr/local/share/perl/5.8.8/Net/SSH/Perl/Packet.pm:20
2.97 0.010 0.010 1 0.0100 0.0100 :/usr/local/share/perl/5.8.8/Net/SSH/Perl/Packet.pm:5
2.97 0.010 0.010 2 0.0050 0.0050 Crypt::Blowfish::new
2.97 0.010 0.010 1 0.0100 0.0099 :/usr/share/perl5/Digest/HMAC_MD5.pm:6
2.97 0.010 0.010 4 0.0025 0.0025 Math::BigInt::GMP::_modpow
2.97 0.010 0.010 1 0.0099 0.0098 :/usr/local/share/perl/5.8.8/Net/SSH/Perl/ChannelMgr.pm:6
[/shell]Ahora se ha dado la vuelta a la tortilla 😀 y tenemos unos tiempos aceptables
Deja una respuesta