Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:9530 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88959 invoked by uid 1010); 24 Apr 2004 07:48:05 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 88879 invoked from network); 24 Apr 2004 07:48:04 -0000 Received: from unknown (HELO alanathome.ossc.com.hk) (202.81.246.113) by pb1.pair.com with SMTP; 24 Apr 2004 07:48:04 -0000 Received: from [192.168.0.40] (helo=akbkhome.com ident=alan) by alanathome.ossc.com.hk with esmtp (Exim 4.24) id 1BHHz3-0001C6-5b; Sat, 24 Apr 2004 15:53:57 +0800 Message-ID: <408A1C50.6050805@akbkhome.com> Date: Sat, 24 Apr 2004 15:50:40 +0800 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6a) Gecko/20031002 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Rasmus Lerdorf , internals@lists.php.net References: <4089E106.4040409@akbkhome.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Performance Consideration of 1 class per file From: alan@akbkhome.com (Alan Knowles) Thanks - I just had a look through zend_comple.c:zend_include_or_eval_handler it appears that zend_stream_open .. and hence fopen is called on every require_once/include_once would it make sense to add something as simple as if (opline->op2.....lval == ZEND_REQUIRE_ONCE) { locations = get_potential_locations(file,PG('include_path')); foreach (locations as location) if (zend_hash_find(&EG(included_files), location)) { // i've already got it ! NEXT_OPCODE(); } } } reduce the stat calls substancially?? - especially where we have cases that alot of the pear classes already have "require_once 'PEAR.php'" .. even though it may have already been loaded by another package... Or did I miss some other optimization that is already there for that..? .. Yeah, I see from APC in CVS, it only wraps the compile_file() call, which has recieves a file pointer, so the stating/realpath damage etc. has already been done) - so unless it does something similar to the above check, and overrides the include handler, it wont help much either, I guess.. Regards Alan Rasmus Lerdorf wrote: > It can be significant. There are a couple of issues: > > 1. The included_files list gets updated each time you include a file. In > order to make sure that the same file included by different paths or > symlinks don't conflict we do a realpath() on the file to be included. > That means stats on every component up to and including the file > itself. I can't speak for all the opcode caches, but at least APC > doesn't do anything to alleviate this. > > 2. APC uses the file's device and inode as the lookup key into shared > memory to find the opcodes for the file, so a stat has to be done on > each and every file that is cached. There is currently no such thing > as a request-spanning stat cache. > > So yes, jumping from 20 to 30 include files could very well bring a rather > significant performance hit. > > Anybody looking for real performance out of PHP pretty much has to address > the first issue. It is easy enough to do, simply get rid of the realpath > lookup in that situation and just live with the fact that if someone > includes the same file via different paths it won't catch it. I can see > that it is convenient to have PHP figure this out for you, but the price > of that convenience is not worth it in my opinion. > > -Rasmus > > On Sat, 24 Apr 2004, Alan Knowles wrote: > > >>PEAR is considering stipulating 1 class per file, for the packages. - >>one of the concerns raised is performance. While this is true for a >>non-cache compiled situation (where performance is less of an issue) - >>would anyone care to comment on the implications when using the Zend >>Optimizer or APC, on how significant the impact of this would be. >> >>- looking at typical application where the number of files included in >>the code with may jump from 20->30 included files.. >> >> From my understanding, if you where looking for performance, you would >>probably have a cache expiry which would mean very few stat (if any) >>calls based on these addition includes.. - hence negating the issue.. >> >>Thanks >>Alan >> >> >> >>-- >>Can you help out? >>Need Consulting Services or Know of a Job? >>http://www.akbkhome.com >> >>-- >>PHP Internals - PHP Runtime Development Mailing List >>To unsubscribe, visit: http://www.php.net/unsub.php >> > > -- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.com