Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:21757 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 55648 invoked by uid 1010); 1 Feb 2006 22:24:27 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 55631 invoked from network); 1 Feb 2006 22:24:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Feb 2006 22:24:27 -0000 X-Host-Fingerprint: 207.155.248.156 bellerophon.concentric.com Solaris 8 (1) Received: from ([207.155.248.156:38692] helo=bellerophon.concentric.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 5D/73-23224-91531E34 for ; Wed, 01 Feb 2006 17:24:26 -0500 Received: (www@localhost) by bellerophon.concentric.com id RAA21594; Wed, 1 Feb 2006 17:24:21 -0500 (EST) [ConcentricHost SMTP Relay 1.17] Message-ID: <200602012224.RAA21594@bellerophon.concentric.com> Errors-To: To: Rasmus Lerdorf , Reply-To: jluedke@concentric.com Cc: Date: Wed, 01 Feb 2006 17:24:21 -0500 (EST) In-Reply-To: <200602011939.OAA10156@alexander.concentric.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Subject: Re: [PHP-DEV] reducing open calls in php From: jluedke@concentric.com (James M Luedke) References: <200602011939.OAA10156@alexander.concentric.com> I tested this and you are correct. This should make a big difference. I learn something new every day :)=20 Thanks a million. -James ---- Rasmus Lerdorf wrote: > > I think the main hint you need is to never use require_once/include_once= =20 > with an opcode cache. Those are the only ones that will cause an open()= =20 > call. You should only be seeing a single stat() call per file under APC= =20 > (needed to get the inode+device hash key for the shared memory lookup). >=20 > -Rasmus >=20 > James M Luedke wrote: > > Hello: > > We have a very high-volume site that runs across a cluster of sever= al > > machines which needs to have access to our back end storage platform, w= hich > > needless to say is very busy. I have been given the task of reducing lo= ad to > > the filer. Due to the fact that our application is rather large and inc= ludes > > lots of files which reside on our filer, php would be a good place to c= ut down load. > >=20 > > We currently have a rather unique setup. We are running php with > > fast-cgi support via sapi/cgi/cgi_main.c as well as APC for opcode/user > > caching**. This allows us to run php as a daemon which reduces system c= alls > > and retains persistence with APC. Our setup has been working quite well= . > > However, there is one behavior that is less than optimal. > > =20 > > Whenever one of our pages is accessed, it appears*** that the reque= sted > > file and all included files are opened, which results in several open c= alls to our filer. As I mentioned, we are running APC which seems to be doi= ng a > > nice job of op-code caching. It would be ideal if somehow I could modif= y php > > to first check APC cache for the pre-compiled opcode before attempting = to > > open the file. This would be a huge win on our cluster, since each hit > > currently generates 5-10 open calls. > >=20 > > Now please bear with me because I am new to the Zend / main tree of= =20 > > the php source. If my understanding is correct, the basic flow of=20 > > cgi/php goes something like this: =20 > >=20 > > request > > some variable init. > > module_init <-apc overide compile_file w/my_compile_file > > php_fopen_primary_script(&file_handle TSRMLS_CC); > > php_execute_script(&file_handle TSRMLS_CC); > > VCWD_CHDIR_FILE(primary_file->filename); > > # i think included_files gets opened here someplace > > # i do not understand that magic yet. > > zend_execute_scripts() > > zend_compile_file() > > compile_file || my_compile_file() <-- apc > > # it looks like the std compile_file > > # may do some zend_open cmds here via > > # open_file_for_scaning() > > zend_destroy_file_handle() <-- destroy before execute? > > zend_execute() > > php_request_shutdown() > > FCGX_Finish_r; > >=20 > > I have a few questions: > > 1. When exactly do the files get opened/read? And is this a necessary= =20 > > step if you already have the op-code. > > 2. Is it possible to check apc_cache before opening files? If it=20 > > is possible, how/where do you think it could be best implemented?=20 > > Is there some similar interface to the my_compile_file trick used=20 > > to override zend_compile_file by apc? Perhaps something like=20 > > my_open_file, which I could then add support for into the apc module? > > 3. would changing utility_functions->fopen_function; to point to=20 > > my_fopen_function in place of zend_open work. > >=20 > > Any input would be greatly appreciated. > >=20 > > -James > >=20 > > ** ( mod_php and the likes are not an option for us as we have our own > > custom web server which we cannot do without :) ) > >=20 > > *** when i truss one of the php daemon process i can clearly see that > > it opens and reads the requested file. It also opens all the=20 > > included/required files but does not seem read them. > >=20 >=20 > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20 >=20 >=20