A couple of notes. You make it sound like this happens on all includes. It is only include_once/require_once that have this problem. Regular include/require do not.
This has been addressed in APC by overriding the opcode and providing our own opcode handler for this case. See http://svn.php.net/viewvc/pecl/apc/trunk/apc_zend.c?view=markup&pathrev=289331 line 86. Having said that, it would be preferable, of course, if we didn't need to swap out that code in APC but I am not sure your solution for solving this only for absolute path includes is the right way to go here. -Rasmus Basant Kukreja wrote: > Hi, > When php script includes a script, php engine compiles the included file. > When opcode caching extensions e.g apc are used, re-compilation is avoided by > apc. But there is a performance problem here. Since php code uses > zend_stream_open to open the included file, open/close system call is still > there. When used with APC, open/close doesn't do any good for file-system > based > files. It only provides the realpath of the opened file. In php 5.3, > zend_resolve_path already provides the realpath of the file being opened so we > can avoid an open/close calls for file to be included if file is an absolute > path. > > Current php 5.3 implementation for include_once/require_once (pseudo code) > > a) call zend_resolve_path. It will provide the realpath. Symlinks are taken > care of by zend_resolve_path. > b) Check if file is already included. If yes, do nothing else go to step (c) > c) Call zend_stream_open and get the included_file realpath. > d) Invoke zend_compile_file and do the rest. > > Now zend_stream_open invokes the open/close calls to the including files which > is redundant when caches are used. > > Here is the suggested performance fix : > a) Same as previous > b) Same as previous > c) If resolved_path is an absolute path then do step c.1 else do c.2 > c.1) Prepare a file_handle and directly invoke zend_compile_file > c.2 Call zend_stream_open and get the included_file realpath. > b) Same as previous > > --------------------------------------------------- > > Few notes : > * Performance improvements using this patch = ~1.5% in an e-commerce workload. > * Testing : I ran the php 5.3 test suite and didn't find any regression. > * If files which are included are not absolute paths then they will follow > the same zend_stream_path route. > * Tested with symlinks and found the behaviour is expected (no change). > > I have attached the patch for review comments. > > Regards, > Basant. > > Note: I previously did this work for php 5.2 but bug remains still open. 5.3 > implementation is relatively straight forward. Here is the reference to 5.2 > bug > : http://bugs.php.net/bug.php?id=47660&thanks=2 > > > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php