Hello!
While searching for a ldap performance bottleneck in the cuurent eGroupWare
1.4 code at a customers system, I stumbled about some very worse situation.
With every page request to the home application, 6 ldap connections got
initiated. Depending on the connection to your ldap server, this can sum up
a little bit. In this case to one second.
While trying to hunt down the problem for that many ldap connections. I
stumbled about following piece of code.
$this->accounts =& CreateObject(‘phpgwapi.accounts’);
and then somewhere else multiple times
$GLOBALS[‘egw’]->accounts->accounts($this->account_id);
Fist we try to create the global accounts object and then we try to set the
id of the current account.
Unfortunately the function account() is also the contructor of the accounts
class(of course! this is PHP4 :-)). And the accounts class extends the
accounts_ldap class. The constructor of the accounts class is executing the
constructor of the accounts_ldap class, which initiates every time a new
ldap connection even if you only want to update the internal accountId.
I changed two things. I added a singleton pattern to the accounts class and
added a function to set the accountId without calling the constructor of
this class. This solved most of the problems.
But there was still one ldap connection to much. It was the same problem,
just a different solutions. The class.uiaccountsel.inc.php was extending the
accounts object which was extending the accounts_ldap class. Puh! What the
hell was this? A GUI class should never extend a backend class!! Never
ever!! It may use a instance of a backend class but it should never extend a
backend class. The uiaccountsel class was using variables of the
accounts_ldap class directly.
I rewrote this class to use also the singleton pattern to use the global
instance of the accounts class.
And now we are using only 1 ldap connections instead of 6.
I commited the changes to the stable version (branches/1.4) and trunk.
After my changes the time to render the home application dropped from 2
seconds to 1 second. 50% speed improvment just by using modern coding style.
Not that bad at all.
If someone finds a problem with my changes, please drop me a note.
BTW: Working with PHP4 was the maximum punishment, after working with PHP 5
for Tine 2.0 only!
Lars Kneschke
CTO OfficeSpot.Net
Metaways Infosystems GmbH
Pickhuben 2-4, D-20457 Hamburg
eGroupWare Support: http://www.egroupware-support.net
OfficeSpot.Net Collaboration Server: http://cs.officespot.net
our proposal for the next major eGroupWare release: http://www.tine20.org
E-Mail: mailto:l.kneschke@metaways.de
Web: http://www.metaways.de
Tel: +49 (0)40 317031-21
Fax: +49 (0)40 317031-921
Mobile: +49 (0)175 9304324
Metaways Infosystems GmbH - Sitz: D-22967 Tremsbüttel
Handelsregister: Amtsgericht Ahrensburg HRB 4508
Geschäftsführung: Hermann Thaele, Lüder-H.Thaele