CVS version is slower than 0.2.0

Get help with using the PHP Secure Communications Library.

Moderator: Nuxius

Forum rules
The purpose of this forum is to provide support for phpseclib, a pure PHP SSH / SFTP / RSA library.

Posts by new users are held in a moderation queue and are not publicly visible until the post is approved.

CVS version is slower than 0.2.0

Postby TangiX » Tue Mar 30, 2010 1:13 pm

Hi,

After the bug of the interleaved mode, i note that my transfer was very slow.
So i make a simple test :
1. i create random files (with dd unix commanbd and /dev/urandom) of 1MiB, 10MiB and 100MiB
2. i transfer this three files by four different methods on three different connection.

The connections are :
1. xDSL : 1MBPS, ping : ~30ms
2. Fiber : 5MBPS, ping : ~30ms
3. LAN : 100MBPS, ping : 0.3ms

The methods are :
1. unix scp command
2. php with ssh2_sftp
3. php with phpseclib0.2.0
4. php with cvs version of phpseclib (interleaved mode)

I make three array for the result (in seconds) for the 3 files :

1 MIB file
xDSL (1MBPS)
  • unix scp command : < 1
  • php / ssh2_sftp : Not Applicable (MAMP have no support for ssh lib)
  • php / SecLib 0.2.0 : 00:00:20
  • php / SecLib cvs interleaved : 00:00:10
Fiber (5MBPS)
  • unix scp command : < 1
  • php / ssh2_sftp : Not Applicable (MAMP have no support for ssh lib)
  • php / SecLib 0.2.0 : 00:00:02
  • php / SecLib cvs interleaved : 00:00:11
LAN (100MBPS)
  • unix scp command : < 1
  • php / ssh2_sftp : < 1
  • php / SecLib 0.2.0 : 00:00:01
  • php / SecLib cvs interleaved : 00:00:03

10 MIB file
xDSL (1MBPS)
  • unix scp command : 00:01:31
  • php / ssh2_sftp : Not Applicable (MAMP have no support for ssh lib)
  • php / SecLib 0.2.0 : 00:02:04
  • php / SecLib cvs interleaved : 00:01:39
Fiber (5MBPS)
  • unix scp command : 00:00:13
  • php / ssh2_sftp : Not Applicable (MAMP have no support for ssh lib)
  • php / SecLib 0.2.0 : 00:00:19
  • php / SecLib cvs interleaved : 00:01:42
LAN (100MBPS)
  • unix scp command : 00:00:01
  • php / ssh2_sftp : 00:00:01
  • php / SecLib 0.2.0 : 00:00:01
  • php / SecLib cvs interleaved : 00:00:24

100 MIB file
xDSL (1MBPS)
  • unix scp command : 00:17:45
  • php / ssh2_sftp : Not Applicable (MAMP have no support for ssh lib)
  • php / SecLib 0.2.0 : 00:19:33
  • php / SecLib cvs interleaved : 00:16:54
Fiber (5MBPS)
  • unix scp command : 00:02:57
  • php / ssh2_sftp : Not Applicable (MAMP have no support for ssh lib)
  • php / SecLib 0.2.0 : 00:03:12
  • php / SecLib cvs interleaved : 00:16:33
LAN (100MBPS)
  • unix scp command : 00:00:08
  • php / ssh2_sftp : 00:00:09
  • php / SecLib 0.2.0 : 00:00:09
  • php / SecLib cvs interleaved : 00:04:02

Sorry for the poor formatting but it seems that table tag is not active in this forum.

This result shows that phpseclib works correctly but not the cvs version
I try to deactivate the interleaved mode without any changes on times, so this is not the problem.
Have you any idea on this problem ?

(note that cvs version is better than others on big files with low connection !!)
Thanks
Christophe
TangiX
Traveler
 
Posts: 34
Joined: Tue Feb 09, 2010 2:07 pm

Re: CVS version is slower than 0.2.0

Postby TerraFrost » Sun Apr 04, 2010 12:24 am

The problem has to do with my reordering of preferred encryption algorithms. Here's a breakdown of the speeds (without mcrypt, which php5-cli doesn't have by default in Ubuntu, in VirtualBox):

arcfour256: 1.18s
arcfour: 1.19s
arcfour128: 1.21s
aes128-cbc: 5.67s
aes128-ctr: 5.87s
aes192-cbc: 6.34s
aes192-ctr: 6.59s
aes256-cbc: 7.42s
aes256-ctr: 7.48s
3des-cbc: 20.75s

Even overlooking the fact that the above speeds haven't been averaged out, it's pretty clear that arcfour is the fastest. Here's the version I changed it in:

http://phpseclib.cvs.sourceforge.net/vi ... 34&r2=1.35

That said, when I made the change, I wasn't testing over a LAN - I was testing over a connection more comparable to an xDSL connection. ie. there, the bottleneck wasn't the encryption algorithm being used, but rather, the connection.

Anyway, I've reverted the change and am now, once again, using arcfour as my main preferred algorithm. Since openssh-server, in Ubuntu, supports arcfour128 and arcfour256, I've also officially, now, added support for them, as well :)

Check out the latest CVS to get the latest changes.
TerraFrost
Legendary Guard
 
Posts: 12218
Joined: Wed Dec 04, 2002 6:37 am

Re: CVS version is slower than 0.2.0

Postby TangiX » Tue Apr 06, 2010 11:18 am

Hi,

This correction reduce the transfer time, but it seems there's another problem :

scp : 00:00:08
ssh2_sftp : 00:00:09
phpseclib 0.2.0 : 00:00:09
phpseclib cvs : 00:04:02
phpseclib new cvs : 00:02:39

Thanks
Christophe
TangiX
Traveler
 
Posts: 34
Joined: Tue Feb 09, 2010 2:07 pm

Re: CVS version is slower than 0.2.0

Postby TerraFrost » Wed Apr 07, 2010 3:57 am

Try the latest CVS again. As noted in the commit message, I was processing /dev/urandom inappropriately. The following demonstrates:

Code: Select all
$start = microtime(true);
$fp = fopen('/dev/urandom', 'rb');
for ($i = 0; $i < 10000; $i++) {
    extract(unpack('Nrandom', fread($fp, 4)));
}
$elapsed = microtime(true) - $start;
echo "took $elapsed seconds\r\n";

$start = microtime(true);
for ($i = 0; $i < 10000; $i++) {
    $fp = fopen('/dev/urandom', 'rb');
    extract(unpack('Nrandom', fread($fp, 4)));
    fclose($fp);
}
$elapsed = microtime(true) - $start;
echo "took $elapsed seconds\r\n";

The first one takes, for me, 0.37 seconds. The second one, for me, takes 19.98 seconds. So that's probably (hopefully!) where the slow down's occurring for you as well.
TerraFrost
Legendary Guard
 
Posts: 12218
Joined: Wed Dec 04, 2002 6:37 am

Re: CVS version is slower than 0.2.0

Postby TangiX » Wed Apr 07, 2010 7:10 am

TerraFrost wrote:So that's probably (hopefully!) where the slow down's occurring for you as well.


You've right ! :)

So, the new CVS version took 9 seconds to tranfer a 100MiB files over LAN (as phpseclib0.2.0 do)

Thanks again for the fix

Christophe
TangiX
Traveler
 
Posts: 34
Joined: Tue Feb 09, 2010 2:07 pm


Return to phpseclib support

Who is online

Users browsing this forum: No registered users and 2 guests

cron