Re: [Coding Standards] Loading all files at once

From: Date: Wed, 11 Jul 2007 06:37:57 +0000
Subject: Re: [Coding Standards] Loading all files at once
References: 1 2 3 4 5  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-47420@lists.php.net to get a copy of this message
On Tue, 10 Jul 2007 09:23:24 -0400, Matthew Weier O'Phinney <mweierophinney@gmail.com> wrote:
On 7/9/07, Joshua Eichorn <josh@bluga.net> wrote:
Travis Swicegood wrote:
Joshua Eichorn wrote:
Obviously we can't meet everyones needs, but we do want a solution that is better then the current one. An allfiles.php approach might not be that, but obviously status quo isn't any better either.
Actually, I think you can meet the needs of everyone. From the benchmark tests I ran, it looks like you can easily have the allfiles for the performance geeks and have all of the currently existing require_once declarations at the top of the file. My tests showed that it was more efficient to do the second request through a require_once than through an if(!class_exists()), so I don't see an issue. Remove the text disallowing all require_once statements, and add code to Pyrus to generate an allfiles.php file. I imagine Greg's going to have it know what type of package it's preparing, so it will be extremely easy for it to create the necessary require_once statements, and for that matter inject the dirname(__FILE__) call into all of the require_onces throughout the code when it creates the unzip and go
installs.
Can you show an example of what the file would look like. If your talking about something like: if (!class_exists('Class_Name')) { require 'filename'; }
Josh, Travis has shown that replacing the above with require_once is *faster*. Why do you keep insisting on this even in the light of concrete benchmarks?
And I have just as concrete benchmarks that should the exact opposite. For all the files used in my benchmark include results from every run: http://www.adamashley.name/stuff/require-benchmark.tar.bz2 The basic idea of my latest set is run AB against a page that includes a set of three objects from three files that make up a mythical package. Include path is set at the beginning of each file. The only difference between each set is how the files are attempted to include. All of my runs have been under APC. There are 4 test cases: current - like a PEAR1 object require_once all over the place. depend on include_path autoload - basic __autoload function. require $class.php; because of the way autoload works if autoload is doing everything dont need to worry about the _once you'll never hit a duplicate. allfiles - the proposed allfiles.php depend on include_path speedfreak - list every file you need and none you dont with full paths. The results:
current    - 1937 req/s
autoload - 2170 req/s allfiles - 2316 req/s speedfreak - 2294 req/s Notice all the proposed ways are faster when using an opcode cache than the current way of doing things. As for speedfreak's poor performance I wouldn't expect a speed up from it until you are including less files than the allfiles methon (ie for a DB container, include DB, DB_Container, and DB_Container_MySQL instead of all the drivers). These test where run on Athlon 64 X2 2800, 1GB RAM, Ubuntu 7.04, Apache 2.2.3, PHP 5.2.4 and APC 3.0.14. Anyone wants to critique my methods everything (code, script to run, and all raw results) is in the earlier mentioned tarball. Adam Ashley

« previous php.pear.dev (#47420) next »