Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:21753 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89453 invoked by uid 1010); 1 Feb 2006 19:39:20 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 89438 invoked from network); 1 Feb 2006 19:39:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Feb 2006 19:39:20 -0000 X-Host-Fingerprint: 207.155.248.157 alexander.concentric.com Solaris 8 (1) Received: from ([207.155.248.157:49174] helo=alexander.concentric.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 22/DA-23224-66E01E34 for ; Wed, 01 Feb 2006 14:39:19 -0500 Received: (www@localhost) by alexander.concentric.com id OAA10156; Wed, 1 Feb 2006 14:39:14 -0500 (EST) [ConcentricHost SMTP Relay 1.17] Message-ID: <200602011939.OAA10156@alexander.concentric.com> Errors-To: To: Reply-To: jluedke@concentric.com Date: Wed, 01 Feb 2006 14:39:14 -0500 (EST) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Subject: reducing open calls in php From: jluedke@concentric.com (James M Luedke) Hello: We have a very high-volume site that runs across a cluster of several machines which needs to have access to our back end storage platform, which needless to say is very busy. I have been given the task of reducing load t= o the filer. Due to the fact that our application is rather large and include= s lots of files which reside on our filer, php would be a good place to cut d= own load. 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 calls 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 requested file and all included files are opened, which results in several open calls= to our filer. As I mentioned, we are running APC which seems to be doing a nice job of op-code caching. It would be ideal if somehow I could modify ph= p 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. 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 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; 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. Any input would be greatly appreciated. -James ** ( mod_php and the likes are not an option for us as we have our own custom web server which we cannot do without :) ) *** 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.