Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:36057 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84520 invoked from network); 8 Mar 2008 07:44:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Mar 2008 07:44:43 -0000 Authentication-Results: pb1.pair.com smtp.mail=indeyets@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=indeyets@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 66.249.82.226 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: indeyets@gmail.com X-Host-Fingerprint: 66.249.82.226 wx-out-0506.google.com Received: from [66.249.82.226] ([66.249.82.226:9556] helo=wx-out-0506.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 21/10-18442-8E342D74 for ; Sat, 08 Mar 2008 02:44:42 -0500 Received: by wx-out-0506.google.com with SMTP id s14so1109034wxc.26 for ; Fri, 07 Mar 2008 23:44:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=Qks1sNzrlgyewD0l+wbiZ1XYN984G/X6RGak/j139hw=; b=kgWaGsGawv5kwfuQ3H2gUgbxMN5kb2965WgJgosDbYIKc59u0WGuNC+jqSh0C7tJn1pBOSMaCMxLaQdbMjzYGMJTdkELN2dIEVwrLEOcjfQ8mx0VcU/kIyBOBHApeZ4GmREyJTP3Q5R4942MTHzQSTpoXk7tW2xX9qJbWrzSVjk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=h2os0xVMC5OW9Fd4EcuSMoM30QLV9NLJjWveoDiM/3TUb0TISxDmm3AfFdE9VQKd+MdZxnxr0+b5xzoizEybsjGy4+imXt57yTLKQdO+Irc4XGXuAdEGXGTbf9FPijlF4JolO576tavFKf2dGjaeSZCVbPqx9DiVHjL3SyPbEcQ= Received: by 10.151.84.12 with SMTP id m12mr969750ybl.169.1204962278485; Fri, 07 Mar 2008 23:44:38 -0800 (PST) Received: by 10.150.52.9 with HTTP; Fri, 7 Mar 2008 23:44:38 -0800 (PST) Message-ID: Date: Sat, 8 Mar 2008 10:44:38 +0300 To: "Gregory Beaver" Cc: "internals Mailing List" , "Dmitry Stogov" In-Reply-To: <47D21F95.7090704@chiaraquartet.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <47D21F95.7090704@chiaraquartet.net> Subject: Re: [PHP-DEV] profiling followup on addition of streams to include_path - it's *faster* From: indeyets@gmail.com ("Alexey Zakhlestin") On 3/8/08, Gregory Beaver wrote: > Hi, > > When I posted yesterday's patch to add stream support to include_path > (http://news.php.net/php.internals/36031) I mentioned that I suspected > benchmarking would reveal it to be slow. My primary goal is to provide > no impact on current users who are using a traditional include_path, > with a secondary goal of improving performance of those who use the new > syntax. Today I ran callgrind on the thing, with some surprising results. > > With the patch, include is *faster* for our traditional users than it is > now. > With the patch, include_once with >1000 unique files is about 3% slower > - not the whole execution, just include_once > With the patch, include_once with 1 unique file included 10000 times is > insignificantly slower (about 0.4%) > > For these reasons, I'm really encouraged :). The next step is to > absolutely ensure correctness and then see if the streams part of > include_path can be optimized at all (or if it needs it). > > Details > ====== > > I just ran callgrind on this script: > > set_include_path('.:/usr/local/lib/php:/home/cellog/workspace/php5/ext/phar'); > for ($i = 0; $i < 100000; $i++) { > include 'extra.php'; > } > > The empty file "extra.php" (zero byte) is in > "/home/cellog/workspace/php5/ext/phar/extra.php" ensuring that we > traverse include_path to find it. > > To my great shock, the script runs *faster* with my patch, because it > executes significantly more instruction cycles in > php_stream_open_for_zend_ex without the patch. > > Note that this does not measure the cost of *_once. *_once is a lot > harder to measure, so I created 10,000 files (yikes) via this script: > > for ($i = 1; $i <= 10000; $i++) file_put_contents('test' . $i, ''); > > and then ran this test script: > > set_include_path('.:/usr/local/lib/php:/home/cellog/workspace/php5/poop'); > for ($i = 1; $i <= 10000; $i++) { > include_once 'test' . $i; > } > > callgrind reported that php_resolve_path was about twice as slow as the > other version, resulting in a 3% degradation of include_once performance > over the current version (which is much faster than 5.2.x, incidentally). > > Finally, to test the _once aspect of include_once, I ran this script: > > set_include_path('.:/usr/local/lib/php:/home/cellog/workspace/php5/ext/phar'); > for ($i = 0; $i < 100000; $i++) { > include_once 'extra.php'; > } > > With this script, it really highlights the most common use case of > include/require_once: attempting to include the same file multiple > times. The difference in performance was insignificant, with callgrind > reporting a total execution portion of 75.12% for CVS, and 75.57% with > my patch. > > So, it looks like the biggest performance hit would be for users > including more than 1000 different files, and would result in > approximately 3% slower performance *of include_once*. I'm curious how > many of our readers have a PHP setup that includes close to this many > files, because it seems rather unlikely to me that anyone would include > more than a few hundred in a single process. > > The surprising news is that users who are using "include" would see a > performance improvement from my patch, so I recommend that portion be > committed regardless of other actions. This improvement proabbly > results from removing an include_path search in plain_wrapper. what about including(_once) by absolute path? -- Alexey Zakhlestin http://blog.milkfarmsoft.com/