Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60656 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 39218 invoked from network); 22 May 2012 15:00:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 May 2012 15:00:33 -0000 Authentication-Results: pb1.pair.com smtp.mail=ceo@l-i-e.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ceo@l-i-e.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain l-i-e.com designates 67.139.134.202 as permitted sender) X-PHP-List-Original-Sender: ceo@l-i-e.com X-Host-Fingerprint: 67.139.134.202 o2.hostbaby.com FreeBSD 4.7-5.2 (or MacOS X 10.2-10.3) (2) Received: from [67.139.134.202] ([67.139.134.202:4108] helo=o2.hostbaby.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0E/13-22099-01AABBF4 for ; Tue, 22 May 2012 11:00:32 -0400 Received: (qmail 32449 invoked by uid 98); 22 May 2012 15:00:31 -0000 Received: from localhost by o2.hostbaby.com (envelope-from , uid 1013) with qmail-scanner-2.05 ( Clear:RC:1(127.0.0.1):. Processed in 0.119416 secs); 22 May 2012 15:00:31 -0000 Received: from localhost (HELO www.l-i-e.com) (127.0.0.1) by localhost with SMTP; 22 May 2012 15:00:31 -0000 Received: from webmail (SquirrelMail authenticated user ceo@l-i-e.com) by www.l-i-e.com with HTTP; Tue, 22 May 2012 10:00:31 -0500 Message-ID: <55e590f078f22ca2bbe10d5187cd3d84.squirrel@www.l-i-e.com> In-Reply-To: References: Date: Tue, 22 May 2012 10:00:31 -0500 To: internals@lists.php.net User-Agent: SquirrelMail/1.4.21 [SVN] MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal Subject: Re: [PHP-DEV] php interpreter From: ceo@l-i-e.com ("Richard Lynch") 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