Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:57935 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42130 invoked from network); 22 Feb 2012 06:29:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Feb 2012 06:29:26 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 209.85.210.42 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 209.85.210.42 mail-pz0-f42.google.com Received: from [209.85.210.42] ([209.85.210.42:63811] helo=mail-pz0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AC/32-16342-24B844F4 for ; Wed, 22 Feb 2012 01:29:23 -0500 Received: by dang27 with SMTP id g27so8833763dan.29 for ; Tue, 21 Feb 2012 22:29:17 -0800 (PST) Received-SPF: pass (google.com: domain of rasmus@lerdorf.com designates 10.68.189.39 as permitted sender) client-ip=10.68.189.39; Authentication-Results: mr.google.com; spf=pass (google.com: domain of rasmus@lerdorf.com designates 10.68.189.39 as permitted sender) smtp.mail=rasmus@lerdorf.com Received: from mr.google.com ([10.68.189.39]) by 10.68.189.39 with SMTP id gf7mr77649872pbc.142.1329892157649 (num_hops = 1); Tue, 21 Feb 2012 22:29:17 -0800 (PST) Received: by 10.68.189.39 with SMTP id gf7mr64353496pbc.142.1329892157546; Tue, 21 Feb 2012 22:29:17 -0800 (PST) Received: from [192.168.200.5] (c-50-131-44-225.hsd1.ca.comcast.net. [50.131.44.225]) by mx.google.com with ESMTPS id q1sm18131271pbv.49.2012.02.21.22.29.16 (version=SSLv3 cipher=OTHER); Tue, 21 Feb 2012 22:29:16 -0800 (PST) Sender: Rasmus Lerdorf Message-ID: <4F448B3B.9060801@php.net> Date: Tue, 21 Feb 2012 22:29:15 -0800 Organization: PHP Development Team User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 MIME-Version: 1.0 To: John Crenshaw CC: Deepak Balani , "flavius@php.net" , "internals@lists.php.net" References: <4F448356.3020008@php.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQl1Wwew5jxL1pHKu9Wu2av2BTki7ZAPPhG+REehZr7CqvHm+K9yeR/EstRt2CWNvcFoRJAD Subject: Re: [PHP-DEV] PHP Script Compile System From: rasmus@php.net (Rasmus Lerdorf) On 02/21/2012 10:16 PM, John Crenshaw wrote: >> -----Original Message----- >> From: Deepak Balani [mailto:wgpdeepak1989@gmail.com] >> Sent: Wednesday, February 22, 2012 1:07 AM >> To: flavius@php.net >> Cc: internals@lists.php.net >> Subject: Re: [PHP-DEV] PHP Script Compile System >> >> No I mean persistent compilation system like >> >> Java >> >> HelloWorld.Java -> HelloWorld.class >> >> >> HelloWorld.php -> HelloWorld.gpc >> >> When you call >> >> gpc_import('HelloWorld.php'); >> >> then function first look for HelloWorld.gpc if found then include it and if not then look for >> HelloWorld.php or HelloWorld.inc (whatever the setting is) if found compile it and include it else >> raise an error. > > Can you explain how this is better or functionally different from the behavior of APC? APC caches bytecode this way too. Unless I've horribly misunderstood something, when you include the file APC uses the cached bytecode as long as it is available and the file was not since modified. If the file was modified APC recompiles it and caches the bytecode. Sounds like the same net result to me, except that APC is less complicated, requires no code changes, and automatically clears its own cache. > > Did I miss something? There is also apc_bin_dump() and apc_bin_load() if you absolutely must have something stored on disk, but assuming you are interested in the performance aspect here, you don't want to be loading anything from disk on a per-request basis. If the interest is along the lines of being able to distribute obfuscated binaries or something, then this is completely the wrong approach because it is trivial to reverse engineer unless you add an encryption layer on top of it. I think one thing that people miss when comparing the php compile phase to java/c/c++ compilation is that compiling a php script to opcodes is super fast because we don't do complicated optimization passes or any of those things, so the performance you gain by only skipping the compilation phase isn't actually that much unless you combine it with also caching the op_arrays, function and class tables in memory. Imagine needing to compile a C++ program on every request? That just isn't feasible. Without an opcode cache, the PHP compiler runs on every request and it is fast enough for millions of sites out there. -Rasmus