Load Times

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
protokol
Forum Contributor
Posts: 353
Joined: Fri Jun 21, 2002 7:00 pm
Location: Cleveland, OH
Contact:

Load Times

Post by protokol »

I have been working on a large-scale corporate intranet product using 100% pure PHP5 OOP. So far it has been the most pleasant coding experience I have had in a while. Everything that PHP5 provides makes my code more elegant and my life much easier.

So far, the speeds that I have seen from the program have been quite good. However, one of the things that I'm surprised to have found is that it takes longer for the script to parse the include files than it does to actually instantiate and use the objects defined in those files!

I don't recall in PHP4 whether I actually experienced this. I know that there are products which exist to do caching, such as Zend Accelerator, ionCube PHP Accelerator, APC, AfterBurner, etc. which help eliminate the need for script compilation upon each request. Unfortunately, I don't believe that these accelerators work with PHP5.

So I am wondering if there are any other tools I can use or tips I can try in order to help speed up the parsing time for my code. I know that a lot of times this just depends on CPU speed and memory, so please don't tell me to buy more memory or get a faster CPU :-) The program is running on a dual 3GHz CPU w/ 1GB ram.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

reduce the number of includes, repeats of includes, and depth of the includes..
User avatar
protokol
Forum Contributor
Posts: 353
Joined: Fri Jun 21, 2002 7:00 pm
Location: Cleveland, OH
Contact:

Post by protokol »

I am using require_once(). Each include file (which is 1 class per include file) require_once()'s whatever other files it needs in order to operate.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

how many includes are we talking here?
User avatar
protokol
Forum Contributor
Posts: 353
Joined: Fri Jun 21, 2002 7:00 pm
Location: Cleveland, OH
Contact:

Post by protokol »

In total I have 18 classes and interfaces being included. At any given time, I'd say that 10-12 classes are used. So 10-12 includes minimum.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

that shouldn't really be enough to wear the load time down a lot.. esp on a dual 3Ghz
User avatar
protokol
Forum Contributor
Posts: 353
Joined: Fri Jun 21, 2002 7:00 pm
Location: Cleveland, OH
Contact:

Post by protokol »

That's why I was so surprised to see that it was taking longer to parse the files than to actually instantiate the objects and perform operations on them. Maybe something else is going on here.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I can understand the loading and parsing taking longer.. that's a lot of complex stuff that has to be done to verify no parse errors and syntax before it can continue on.. but what kinda time are we talking here, 100ms of processing time? unless you have 100,000 pages being processed at the same time, that shouldn't be a large issue.. and if you have 100,000 pages being processed, you probably have other problems than inclusion times to worry about..

HD seek times may be more to worry about for this than the parsing time as that's probably where a bunch of the slow down is happening.. using a multi-disk RAID 5 or better setup can and will greatly improve response time.. Making sure those drives are nearly always spun up helps too.. high-end SCSI drives are better at RAID than IDE set ups.. uh... processor cache levels and cache misses become very important when getting into serious performance gains... I don't think php uses SSE/SSE2/SSE3 and the others... I haven't seen any of that code inside their stuff anyways..
User avatar
protokol
Forum Contributor
Posts: 353
Joined: Fri Jun 21, 2002 7:00 pm
Location: Cleveland, OH
Contact:

Post by protokol »

I'm not even going to let it bug me. The script runs pretty damn fast, so I've got no problem with the parsing taking a bit longer. Hopefully we will see some accelerators for PHP5 in the near future
Post Reply