Full steam ahead. Go to Warp 9.

I have been spending some time doing speed-optimization of Pundit and the code I have made for UniteIT so far. My tool: Zend Studio and its “Profile URL” function. (find it under Tools -> Profile URL. You need the Zend Studio Server extention loaded on you apache process)

I still have some way to go if I have to break the magic 200ms per request, but I’ve gotten it down to 3-400ms from.. well, more than what would be considered “safe”. The RSS-page was a whopping 1200ms - 1.2 seconds - but I got it down to 600ms by simply doing some more work with manual coding instead of relaying 100% on the framework and changing to persistant connections. I then did some framework changes and got it down to 400ms.

My biggest finding was that the PDO constructor took as much as 300ms to run. Comon. 300ms to establish connection to the database??? Now the biggest steal that doesnt come from my framework is Smarty which now takes as much as 120ms for a normal page-view (which is only two (2!) Smarty::fetch() calls). It might get lowered when I turn off auto-compiling of templates.. But still.. 60ms to fetch and display a template.

Second from that I found that I do a lot of PunditModel::_find_var() calls - and they dont really take long to run, but run it 2000 times per request and you have wasted 20ms simply trying to find the var of your object. And since each of these runs loops through the vars I end up with tons of PunditVariable::getName() calls. I have to find a way to get rid of some of thise calls as there might be up to 40ms wasted here.

The next thing I will concentrate on will be PunditModelHandler::getObjects as 6 calls to this resulted in a 100ms own-time. I wonder what causes this.. Hmm, might need some step-by-step running though the code to figure out if there is some weird loop that takes forever.

Of course all these execution-times are with no caching at all. The execution times lower drasticly when you add some caching to it… ;)

-fangel

October 8th, 2006 | PHP, Pundit

No comments

Post comment