On 02/21/2012 10:16 PM, John Crenshaw wrote:
>> -----Original Message-----
>> From: Deepak Balani [mailto:wgpdeepak1...@gmail.com] 
>> Sent: Wednesday, February 22, 2012 1:07 AM
>> To: flav...@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

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to