SimpleID: Slow OpenID login

Since some months I had the problem that doing logins on my SimpleID OpenID server were very slow. phorkie's automatic login took 6-8 seconds, which blocked the browser in that time.

After upgrading all PEAR packages yesterday, OpenID login with phorkie stopped working: The OpenID association request timed out after 3 seconds. Time to investigate the issue.

I was able to create a curl POST request that took 3.6 seconds on my SimpleID instance. With that I was able to track down the functions that were slow with var_dump(); exit(); statements in the code.

I followed the trail from openid_dh_server_assoc() to openid_dh_generate_key_pair() to bignum_powmod() which did some heavy math in vanilla PHP - when PHP's GMP extension is not installed.

Installing Debian's php5-gmp package made it all fast; the login request takes 0.8s now.


To be fair: SimpleID's system requirements document tells us about that issue:

You can also have the following extension enabled for better performance:

gmp

Written by Christian Weiske.

Comments? Please send an e-mail.