Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89208 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 1785 invoked from network); 13 Nov 2015 21:36:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Nov 2015 21:36:02 -0000 X-Host-Fingerprint: 68.118.157.39 68-118-157-39.dhcp.mdsn.wi.charter.com Received: from [68.118.157.39] ([68.118.157.39:20905] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 12/A1-62946-CB756465 for ; Fri, 13 Nov 2015 16:36:01 -0500 Message-ID: <12.A1.62946.CB756465@pb1.pair.com> To: internals@lists.php.net X-Mozilla-News-Host: news://news.php.net:119 Date: Fri, 13 Nov 2015 15:35:52 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 68.118.157.39 Subject: Support for writing and executing compiled opcode From: me@stephencoakley.com (Stephen Coakley) Hello all, I've been thinking about PHP optimization and distribution, and I would like to hear some opinions on introducing a new feature for a future PHP 7 version. Here's the concept: allow PHP opcode to be both saved after parsing a file, and to be loaded and executed, similar to the bcompiler extension and the APC bin functions back in the day. The advantages are clear: libraries and applications could be compiled to opcode ahead of time so PHP wouldn't have to compile it again and again (assuming you're not already using OPcache). A new function could be provided to parse a PHP file, but instead of executing it, the compiled opcode would be saved to a file. It might part of the OPcache extension if it makes sense, and could be called opcache_compile_to_file() or something. Another option would be to add a command-line flag to the interpreter to write compiled opcode instead of executing it after parsing. Another part of the feature would be to enable the interpreter to execute compiled opcode scripts directly. This would work for both compiled scripts passed to the interpreter, and scripts loaded with `include` and `require`. We would probably need to introduce a new file extension to specify opcode files. I'd recommend *.phpo or *.phpc. This is quite similar to Python's ability to execute Python scripts compiled to bytecode as *.pyc files. The feature has seen great success in Python, mostly for distributing releases of software or deploying to a server. I'm not at this moment planning an RFC, but I'd like to gauge your opinions and reactions first. -- Stephen