Aumentando el rendimiento en Net::SSH::Perl

Tuesday, January 30th, 2007 @ 11:29 am | Notas rápidas

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:

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

Aquí tenemos el cuello de botella:

  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

Vamos a ver qué paquete tenemos de matematicas

 # dpkg -l | grep math | awk ' {print $2}  '
libmath-gmp-perl

y ahora a ver que librerías salen en el repositorio

 # 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

Este suena bien libmath-bigint-gmp-perl – GMP library for Math::BigInt routines

lo instalamos :

 apt-get install  libmath-bigint-gmp-perl 

y ahora lo probamos

 # 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

Ahora se ha dado la vuelta a la tortilla :D y tenemos unos tiempos aceptables

 

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 

Recently

  • wiki.developers.facebook.com hacked
  • gnome terminal : copiar y pegar = truncado
  • He visto cosas que vosotros no creeríais
  • perl forking
  • OpenSolaris colgando de un hilo
  • iframe sospechoso
  • VirtualBox 3.2 ( cuidado que cruje )
  • cambiar password de usuario sistema en modo batch
  • google fue hackeada desde dentro
  • pezones en el pie !!! wtf !!!
  •