Re: php interpreter

From: Date: Thu, 24 May 2012 15:23:49 +0000
Subject: Re: php interpreter
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-60671@lists.php.net to get a copy of this message
I've seen this statement before about the impact of caching the actual compilation (or mere tokenization?) to bytecode being very small compared to the impact of avoiding disk access. I am curious if there are any measurements breaking this down. Read-only access to code in files already buffered by the OS (not files read for the first time) ought to be very fast. On Tue, May 22, 2012 at 11:00 AM, Richard Lynch <ceo@l-i-e.com> wrote: > On Wed, May 9, 2012 5:05 pm, Xin Tong wrote: > >> I am new to php runtime. i am doing some research on runtime >> interpreter. can anyone please tell me where the interpreter of the >> php runtime is ? which file ? and does the php runtime has a JIT >> compiler ? > > I believe the interpreter is built out of bison/yacc files, so you > could start with those to find out where they put it. > > The php runtime is a JIT parser/compiler to a bytecode, which is then > run by the Zend Engine (see above). > > Actually, that last statement might imply the the zend directory would > also be a good place to look. > > Finally, it should be noted that APC and other caching mechanisms save > a great deal of time by not hitting the disk to load the script, but > keeping it in RAM, if possible. > > As "gravy" on top of that, the bytecode is saved in cache instead of > source, so it is not a JIT if one of those caches is in use. > > Psuedo code to describe the difference the APC (or other cache) makes: > > > //save hitting the hard disk > if ( $source_code = in_cache($path)){ > } > else{ >  //super-duper slow!!! >  $source_code = file_get_contents($path); > } > $bytecode = zend_parse($source_code); > zend_execute($bytecode); > > //save hitting the hard disk > //and a small bonus, cache the bytecode, not source: > > if ($bytecode = in_cache($path)){ >  //do nothing > } > else{ >  $source_code = file_get_contents($path); >  $bytecode = zend_parse($source_code); > } > zend_execute($bytecode); > > > The savings from parsing is chump change compared to disk I/O. > > It's also trivial chump change to implement. > > Ever ounce counts :-) > > -- > brain cancer update: > http://richardlynch.blogspot.com/search/label/brain%20tumor > Donate: > > https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FS9NLTNEEKWBE > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > -- Tom Boutell P'unk Avenue 215 755 1330 punkave.com window.punkave.com

« previous php.internals (#60671) next »