does PHP code get compiled from source every time the page is served, or is some compiled form (bytecodes or something) get cached by the server?
Thanks,
...Mike
does PHP code get compiled from source every time the page is served, or is some compiled form (bytecodes or something) get cached by the server?
Thanks,
...Mike
handcraftedweb;10962785 wrote:does PHP code get compiled from source every time the page is served
yes.
there are accelerators that cache the bytecode.
It feels like a good idea to cache it but in practical terms its still freakishly fast, and for most sites your user wont experience any benefit. Therese usually a lot in the code that could be optimised that would far greater benefit than bytecode caching.
I think I found the answer to my own question. I came across this page
http://talks.php.net/show/php-best-practices/37
which said the Zend engine compiles to opcodes and caches them, and upon further searching I found the opcode spec.
So the Zend implementation compiles to opcodes (and the server service I'm using uses the Zend engine), but I wonder how popular (if at all) any non-Zend PHP implementations are?
...Mike
handraftedweb wrote:I came across this page
It's badly written (as is usually the case with presentation slides, since they're written with the assumption that someone will be standing next to them talking). As distributed, PHP does not have an opcode cache; instead there are several different mechanisms available as extensions or commercial platforms (as listed).
handcraftedweb wrote:any non-Zend PHP implementations
The only ones I know of are Phalanger and Parrot.
dagon, Weedpacket,
Thanks for setting straight on that. I must say I am surprised that it does get compiled from source every time.
I'm just learning this language, and have gone through most of the obvious best-practices/optimization tips on the web. Thanks again.
Well, like dagon observes, it's usually fast enough anyway - the performance bottleneck is usually elsewhere (disk access, process communication, network bandwidth...) and parse time is usually negligible in comparison. Zend Optimizer, for example, gets most of its performance boost from analysing and tuning the bytecode before caching it.
Scripts that would best benefit from it would be scripts that are both very large and very complex - unlike the usual database→webpage script (and as for the unusual ones, there's a good chance they'd benefit more from attention elsewhere).
But, like anything to do with optimisation, Your Results May Vary.
Weedpacket;10962989 wrote:...
Scripts that would best benefit from it would be scripts that are both very large and very complex - unlike the usual database→webpage script (and as for the unusual ones, there's a good chance they'd benefit more from attention elsewhere).
...
I'm going to generate the whole site from PHP, and make heavy use of OO. If performance suffers then I'll look at optimizing it by doing more in straight HTML and reducing message sends.
...Mike