Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67025 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 90241 invoked from network); 10 Apr 2013 13:07:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Apr 2013 13:07:57 -0000 Authentication-Results: pb1.pair.com header.from=arvids.godjuks@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=arvids.godjuks@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.174 as permitted sender) X-PHP-List-Original-Sender: arvids.godjuks@gmail.com X-Host-Fingerprint: 209.85.217.174 mail-lb0-f174.google.com Received: from [209.85.217.174] ([209.85.217.174:47334] helo=mail-lb0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7F/40-21449-B2465615 for ; Wed, 10 Apr 2013 09:07:56 -0400 Received: by mail-lb0-f174.google.com with SMTP id s10so497456lbi.19 for ; Wed, 10 Apr 2013 06:07:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=ORxAp38sGygXXLlvnoGZQeUuByCSNgPKhhoxaVUryBA=; b=i2MHvtZjZ1no4SEAeFNBamuSTtLb1TeNwRa7PsIRXtD2CtNst9kyUFMV8hYLF8fUgu +OWN+9nondXqAus1a2vYEENWxfGL0jXu0eneUaZfDbJaUVKmO8KhDl+koz8m9x3COS04 SGwoElF+yFPdaR8XvsNgVDKq2vfMvHd9MlwkVFJlgpap6VL6yRtUZrgQf9UAfGdpsJ3o RyTUhFEy7VSznmIuKkaF1kVeqvBKpVmXW8UBz0Tg6Tkrpq9d1NUz9bZaTUOOqA4ipWAX ZCa9mUzpWas7dO672yXVVzy8HzMqj7HiKmbd8V39ZL7CQVi5PFHbONmduFwxilJhusbd i8Aw== X-Received: by 10.152.20.193 with SMTP id p1mr1011322lae.33.1365599272569; Wed, 10 Apr 2013 06:07:52 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.142.170 with HTTP; Wed, 10 Apr 2013 06:07:31 -0700 (PDT) In-Reply-To: References: Date: Wed, 10 Apr 2013 16:07:31 +0300 Message-ID: To: PHP Internals Content-Type: multipart/alternative; boundary=089e0141a9a48c10f304da015b2e Subject: Re: [PHP-DEV] OPcache optimizer improvement in PHP-5.5? From: arvids.godjuks@gmail.com (Arvids Godjuks) --089e0141a9a48c10f304da015b2e Content-Type: text/plain; charset=UTF-8 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$ --089e0141a9a48c10f304da015b2e--