Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67027 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93432 invoked from network); 10 Apr 2013 13:18:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Apr 2013 13:18:38 -0000 Authentication-Results: pb1.pair.com header.from=zeev@zend.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=zeev@zend.com; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain zend.com does not designate 209.85.215.42 as permitted sender) X-PHP-List-Original-Sender: zeev@zend.com X-Host-Fingerprint: 209.85.215.42 mail-la0-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:50322] helo=mail-la0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8C/F0-21449-DA665615 for ; Wed, 10 Apr 2013 09:18:38 -0400 Received: by mail-la0-f42.google.com with SMTP id fn20so134415lab.15 for ; Wed, 10 Apr 2013 06:18:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:references:in-reply-to:mime-version:x-mailer :thread-index:date:message-id:subject:to:cc:content-type :x-gm-message-state; bh=1ewYqXQlpPTU4ZgO4n4Tkzl4v2O+P8kpuCyopNIAojk=; b=I0O26rJSPY3t/zN8eAMncpmCcxA8t4CkDRTU5fuYQUvDMQLArL4niN8MT4zLKOYrEc CAxCQDaBwcS6DOLlvI73Cb6Irf7XapkKpjylEZWAFWXTJnI9EGpBSCeDvzlRrwC7GSM0 19es4q5tehk+8Eo0xGRLxyEvH+T3gxz6rEOxBQ7HZ/XEDcEHo6/+T1q80a6S3CFdLpaW Vr7rmhj9nzBEjRNsr8AxI2/9uP118hUQt/V4lNhjzk5k2eacnNtQ3hiUqWcMsAP2ikMv NdsSnia0SuEu3ujpTmDY3+c4FJh8EmZcgrWK0zNoZRYm1i1v0KDaOuxhVL0BQJtWQ2uG Y7WQ== X-Received: by 10.112.5.6 with SMTP id o6mr1195021lbo.57.1365599914241; Wed, 10 Apr 2013 06:18:34 -0700 (PDT) References: In-Reply-To: MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQFVPpSNbOGMJmTVWXvN9y+HxauxBwDgUUw9mbpZ/8A= Date: Wed, 10 Apr 2013 16:18:33 +0300 Message-ID: <346136c9a028d303d8345ffd4c3c8237@mail.gmail.com> To: Arvids Godjuks , Dmitry Stogov Cc: PHP Internals Content-Type: text/plain; charset=UTF-8 X-Gm-Message-State: ALoCoQlrGCESW19xTOfJEt4gnaTVM5orgDMyMKkrU9pAe1b3iDHpga1vbjVuhGOavoNkOoyL0kSFjgyw5OI6i/eU6HTwIscETn/YxuUhBd18MRkVduVJxcQw5Q3rB+8bTdYqApv0ucbQ Subject: RE: [PHP-DEV] OPcache optimizer improvement in PHP-5.5? From: zeev@zend.com (Zeev Suraski) > -----Original Message----- > From: Arvids Godjuks [mailto:arvids.godjuks@gmail.com] > Sent: Wednesday, April 10, 2013 4:08 PM > To: PHP Internals > Subject: Re: [PHP-DEV] OPcache optimizer improvement in PHP-5.5? > > 2013/4/10 Dmitry Stogov > > > Hi, > > > > Recently, I've found that OPcache optimizer misses a lot of abilities, > > because it handles only one op_array at once. So it definitely can't > > perform any inter-function optimizations (e.g. inlining). > > > > Actually, it was not very difficult to switch to "script at once" > > approach. > > The attached patch demonstrates it and adds per script constants > > substitution explained in the following script > > > > > define("FOO", 1); > > function foo() { > > echo FOO . "\n"; // optimizer will replace it with: echo "1\n"; } > > ?> > > > > Of course, I ran the PHP test suite and it passed all the same tests. > > Personally, I think it's safe to include this patch into 5.5 and make > > a green light to some other advanced optimizations in 5.5. (e.g. > > conversion INIT_FCALL_BY_NAME into DO_FCALL). > > > > Any thoughts? > > > > Thanks. Dmitry. > > > > -- > > PHP Internals - PHP Runtime Development Mailing List To unsubscribe, > > visit: http://www.php.net/unsub.php > > > > > Hi! > > Many obvious optimizations are not used due to the fact, that script > translation > into opcode state has to be fast. The nature of PHP dictated that and this > was re- > iterated countless times on this mailing list by the core developers. > > To do advanced stuff, you have to create some sort of pre-compile or > storing > that compiled code reliably on disk so that if memory cache is dropped or > restart > is done, there is no significant preformance hit while all the code > compiles into > optimized opcode again. > > I would also imagine that good part of the optimizations would require > multiple > files to be processed and optimized, but due to dynamic nature of the PHP > opcode compilation is done on per-file basis, so do the optimizations. > > It's very commendable that you want to push optimizations and stuff, but > there > are some fundamental stuff that needs to be cared of to do some really > good > stuff. I think it very much depends on the nature of the optimizations. For the vast majority of optimizations we can apply to PHP's execution architecture, I actually don't think that we need to go back to the fundamentals and consider things like storing pre-compiled scripts on disk. The compiler, even with optimization passes still takes split seconds to execute, which means a 'cold boot' (e.g. when doing a restart) won't be a noticeably painful process. As long as you end up reusing the results of that process a lot more frequently than you have to recreate them - you're fine. Note that our experience was that reading binary serialized data from disk isn't significantly faster than invoking the compiler in the first place - you still have to read the data from disk, you still have to analyze it and backpatch addresses, etc.; I know that some people here are revisiting that assertion - which is absolutely fine - but the assumption that saving precompiled files on disk eliminates compilation overhead is wrong. If anything it gives a marginal benefit... From my POV I think we're fine with any optimization that does not break the single-file barrier (in other words, no cross-file optimizations). The one Dmitry suggested falls in that category, so I think it's fine, and it's mostly a question of whether we want it in 5.5 or only in 5.6. Zeev