-
-
Notifications
You must be signed in to change notification settings - Fork 878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[V3] SSH login slower in V3 with key whereas it takes less than 1s in V2 #1919
Comments
Does terrafrost@41cb11e help? |
That said, I would expect v3 to be a little slower because, for example, |
Thanks, Yes this helped a lot and the performance is now significantly faster 👌🥳
|
One thing that's interesting is how BCMath is faster for you then PHP64. phpseclib uses the PHP64 engine preferentially over the BCMath engine. In light of your analysis I updated https://github.com/phpseclib/benchmarks/blob/master/test.php to work with phpseclib 3.0 and ran benchmarks on PHP 8.1 vs 8.2. So with PHP 8.1 x64 with BCMath that benchmark script takes between 0.46s and 0.49s. With PHP64 on PHP 8.1 x64 it takes 0.38 and 0.40s. So, clearly, PHP64 is faster. With PHP 8.2 x64, in contrast, both PHP64 and BCMath take between 0.06s and 0.09s. For fun I tried it on PHP 7.0 x64, as well. On that one PHP64 takes between 0.56s - 0.58s whereas BCMath takes between 0.89s and 0.91s. TLDR it might be worthwhile to default to BCMath on PHP 8.2 whilst still defaulting to PHP64 on PHP 8.1 and earlier.. |
I don't know what could be causing this. And this is my private key used during tests:
Since we can't control servers of users, once this fix is released, I am thinking about either providing a explicit option to users within our plugin to whether prefer BCMath over PHP64 or prefer PHP64 over BCMath while always prefering GMP over others. Or maybe automate this selection during connection test. Thank you for your quick response and fix. |
So I wanted to do some more testing before possibly making BCMath prioritized over PHP64 and... altho I said in an earlier post that BCMath was faster than PHP64 on PHP 8.2 I was not able to duplicate that when trying to do so just now. I created a heatmap showing the fastest and slowest speeds at http://phpseclib.com/docs/speed . Per that PHP64 is consistently faster than BCMath BUT, when OpenSSL is being used, the difference is pretty negligible. Consequently, I thought I'd just go ahead and make it use BCMath over PHP64 / PHP32 when OpenSSL is available but then Github Actions kept on timing out on the unit tests. I'd still like to be able to better understand why, on your system, BCMath is outperforming PHP64, but none-the-less, I've released a new version of 3.0 that includes this fix. Thanks! |
We have been using V2 of your library in our WordPress plugin but we recently received multiple reports of error by some Hosting Providers when user try to update PHP to version 8
V2 does work well for us till PHP 8.2 but these reports can be related to security issues and we couldn't risk, so we decided to use V3 of phpseclib. On upgradation, we found out that V3 is performing slow as compared to V2. During our inspection for sftp login, we found issue with BigInteger::powMod (or BigInteger::modPow) which is taking all the time during signing method. We already tried forcing BCMath (default in V2), but it is still slower.
Here are some benchmarks
PHP: 8.0.10
OpenSSL: 1.1.1f 31 Mar 2020
BCMath: enabled
Let me know if you require more information. Thanks
The text was updated successfully, but these errors were encountered: