Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:44166 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30373 invoked from network); 4 Jun 2009 23:21:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Jun 2009 23:21:01 -0000 Authentication-Results: pb1.pair.com header.from=paul.biggar@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=paul.biggar@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.221.184 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: paul.biggar@gmail.com X-Host-Fingerprint: 209.85.221.184 mail-qy0-f184.google.com Received: from [209.85.221.184] ([209.85.221.184:33099] helo=mail-qy0-f184.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3B/F5-44672-DD6582A4 for ; Thu, 04 Jun 2009 19:21:01 -0400 Received: by qyk14 with SMTP id 14so225626qyk.29 for ; Thu, 04 Jun 2009 16:20:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; bh=xoj3Vw3uQrdIDNj5XcKoiwYNfgn4dsFwNvQx4yuKefo=; b=dkrkOl7Lu3yuo8WGZM9J2p0NIeAyS8YEeMmhi+P/sNnPLb7YEPp5bhATDRSJPaIYyp 6MgRf4klONDamWwhmGCRg6bIlnFrfPBA5SXikTIPOXIlAsIHwg8Bt87cK48lTfpN/G8t qrVp8GFvn2gtVWR1hwJ7oyGAL9FQN39KbMhD8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; b=E0K8y3sZmpc3TCUFmarHP52ilBuCB+LJZYCz4MbBja11ntMTz0028V3SOzc+UYyW+u lNnKmeUwJq52D+3reOk21U7lsMHCFbXd8Y2MCQfGvnkY8xEtwt+DqwSM0XzqmzepN0a2 86GXumGDdICE5G4XL+gjbmaMbt+wsdeh5quKE= MIME-Version: 1.0 Received: by 10.231.16.134 with SMTP id o6mr778101iba.11.1244157657145; Thu, 04 Jun 2009 16:20:57 -0700 (PDT) Date: Fri, 5 Jun 2009 00:20:37 +0100 Message-ID: To: grahamk@facebook.com Cc: PHP Internals , shire Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Optimizer discussion From: paul.biggar@gmail.com (Paul Biggar) Graham and I are having a brief chat about the work he's going to do on the PECL optimizer. People have asked me to do this on-list (they may have meant the PECL list, but optimizations on PHP seem more relevant here), so here goes. Hi Graham, So the general gist of what I have to say is that dataflow optimizations on PHP are very difficult, and nearly impossible at the function-local level. Loop-invariant hoisting and other redundant expression computation liekwise. If you're planning on working on them, we can go into more detail. I guess the biggest thing is that I'm wondering what your plans are for the PECL optimizer? I've spent about 2 years working on the phc optimizer, (and a bit longer on relevant things) so I hope that my advice will be relevant. I've taken a look through the optimizer a few times over the last while, (and even stolen some ideas from it). Here are my comments on the current code: - There is lots of code which reimplements parts of the engine, for example: ini_bool_decode, optimizer_acosh and friends, optimize_md5, optimize_crc32, optimize_sha1, optimize_class_exists and friends (to a lesser extent). There are also lots of constant foldings, like casts and "0 == false" (etc) in optimize_code_block. I don't understand why there is logic in the code for that, rather than simply executing the opcodes, or constructing an eval and executing that. - is_numeric_result: there has been great effort to figure out numeric results from pure functions, when it seems straightforward to optimizer the results straight in. Maybe that is being done elsewhere? If so, there may need to be some care taken to ensure that all optimizations terminate. - File system functions are very iffy. I would be surprised if people have content that reads from files repeatedly, but where the files do not change, and who are willing to use that flag. - Most of the identity optimizations arent safe. $x + 0 !== $x, unfortunately, due to integer coercions (parallels exist for other types/operators) - I think I saw an optimizations converting ("45" + $x) into (45+$x) - that's a great idea, which I will steal. - How does runkit (and other weird extensions) affect optimizations on constants, class_exists, etc? - The optimization "unsafe: optimize out isset()/empty() ops on GLOBALS['foo'] into $foo " is not safe, as GLOBALS['foo'] may not be the same variable as $foo ($GLOBALS may be unset, and indeed, there may be good reasons to do so). I'm also wondering what the optimizations are on fcall? I couldn't make it out. That's quite a lot, but its everything I have on the current PECL optimizer :) Thanks, Paul -- Paul Biggar paul.biggar@gmail.com