Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67063 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16115 invoked from network); 12 Apr 2013 06:43:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Apr 2013 06:43:12 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain zend.com does not designate 209.85.128.182 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.128.182 mail-ve0-f182.google.com Received: from [209.85.128.182] ([209.85.128.182:63238] helo=mail-ve0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 91/91-05511-EFCA7615 for ; Fri, 12 Apr 2013 02:43:11 -0400 Received: by mail-ve0-f182.google.com with SMTP id m1so2155834ves.27 for ; Thu, 11 Apr 2013 23:43:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:x-gm-message-state; bh=Sp1eCPea67JTIlYneAkGYzx2jLo3xk8hGu2pbhjnjFQ=; b=I99qlLt2wETYs0sBapCKLEl29H81EEulICMBj0yxKk5H9/wqn6Ubdc6bQpD2I83VY6 H9fuEslsCtbHEu3sGnbg1b7DBMFQ408B8oYmCdjv5yRaDVi7nXHdJIM6PeqF6r/kznF3 JrLMcmdrHPc47EErq4EHto/yfOQFGy5nEGkaArj+TPy+sc6Zi1aaQwAJuR1azurQzvrV c1VFWDy5ZDOhrUBZdiUQyCn5rG9j7t1eMxQqzYAt5KNAnveH8R6GW8V6V9uVMkMNP2Qq L6LhDCOuihPscnibEDIS1yF/xD8q7vQLZ6LbIrFuMf7VVzmowJJ3zEcebaqvjw2Yft8L vXYg== MIME-Version: 1.0 X-Received: by 10.58.144.133 with SMTP id sm5mr7502161veb.23.1365748988445; Thu, 11 Apr 2013 23:43:08 -0700 (PDT) Received: by 10.52.115.170 with HTTP; Thu, 11 Apr 2013 23:43:08 -0700 (PDT) In-Reply-To: References: <51673FD1.2010704@garfieldtech.com> Date: Fri, 12 Apr 2013 10:43:08 +0400 Message-ID: To: Graham Kelly-Cohn Cc: Larry Garfield , PHP internals Content-Type: multipart/alternative; boundary=047d7b675b264f45bf04da243710 X-Gm-Message-State: ALoCoQn3+6Qgksdand4ENLh9311A/Hz77Ro1nMkJZXgjRhOU4r9pTAeR7myY8X6nkqOGqScrJXshO4kluVSbfgU2DcAJ+4i8APrrGKg1z7CvImo4dpbNd4wJIxOL+6sq3YDzzyKgikjW Subject: Re: [PHP-DEV] OPcache optimizer improvement in PHP-5.5? From: dmitry@zend.com (Dmitry Stogov) --047d7b675b264f45bf04da243710 Content-Type: text/plain; charset=UTF-8 Good point. Thanks. Dmitry. On Fri, Apr 12, 2013 at 3:09 AM, Graham Kelly-Cohn wrote: > I don't think this is a safe optimization. In the following case it would > output 'b' and not 'a' which is the correct result: > > a.php: > define('FOO', 'a'); > include('b.php'); > ?> > > b.php: > define('FOO', 'b'); > echo FOO; > ?> > > It is certainly not likely for a constant to be defined twice but PHP > currently just issues a notice and continues with the first constant value. > > > On Thu, Apr 11, 2013 at 3:57 PM, Larry Garfield >wrote: > > > Speaking as a userspace developer and site admin, I'd be fine with > trading > > a more expensive compilation for a runtime improvement. Even a 100% > > increase in compilation time would pay for itself over only a dozen or so > > requests (assuming the runtime improvements are non-trivial, too). > > > > Naturally some optimizations are harder to do than others given PHP's > > architecture, but trading more expensive compile for cheaper runtime, > even > > if not a 1:1 trade, would be a win IMO. > > > > --Larry Garfield > > > > > > On 4/10/13 9:16 AM, Dmitry Stogov wrote: > > > >> For now, the optimizations we do are quite chip. > >> They may increase the compilation time on first request by 2, but on > >> following requests we will get it back. > >> Once we come to really expensive optimizations we will do it "offline" > (in > >> context of a separate process). > >> > >> Thanks. Dmitry. > >> > >> > >> On Wed, Apr 10, 2013 at 5:16 PM, Florin Patan > >> wrote: > >> > >> On Wed, Apr 10, 2013 at 4:07 PM, Arvids Godjuks < > >>>> arvids.godjuks@gmail.com> > >>>> > >>> wrote: > >>> > >>>> 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. > >>>> > >>>> My 0.02$ > >>>> > >>> > >>> Hello, > >>> > >>> > >>> If applying optimizations in multiple passes would be a problem for > >>> speed, especially on the first request, then maybe a way to solve this > >>> would be to have a configurable variable like: opcache.passes which is > >>> between 1 and 10 (lets say) and then have the engine do something like > >>> this: > >>> - load the file, compile it and apply a first round of 'quick' > >>> optimizations for the first time and mark it as passed once; > >>> - next request, load the compiled version, apply another round of > >>> optimization then mark it as a second pass > >>> - repeat the above step until the optimization passes in the said file > >>> = opcache.passes value > >>> > >>> This way only the initial requests will be affected by this but in a > >>> way that the hit on those requests is smaller that applying all the > >>> steps at once. > >>> I'm really not sure if it's that easy to implement but 'on paper' this > >>> could be the way to solve it imho. > >>> > >>> What do you think, does it make sense? > >>> > >>> > >>> > >>> Best regards > >>> ---- > >>> Florin Patan > >>> https://github.com/dlsniper > >>> http://www.linkedin.com/in/**florinpatan< > http://www.linkedin.com/in/florinpatan> > >>> > >>> -- > >>> PHP Internals - PHP Runtime Development Mailing List > >>> To unsubscribe, visit: http://www.php.net/unsub.php > >>> > >>> > >>> > >> > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > --047d7b675b264f45bf04da243710--