Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60671 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 46745 invoked from network); 24 May 2012 15:23:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 May 2012 15:23:55 -0000 Authentication-Results: pb1.pair.com smtp.mail=tom@punkave.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tom@punkave.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain punkave.com designates 209.85.213.42 as permitted sender) X-PHP-List-Original-Sender: tom@punkave.com X-Host-Fingerprint: 209.85.213.42 mail-yw0-f42.google.com Received: from [209.85.213.42] ([209.85.213.42:36639] helo=mail-yw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D2/99-31936-7825EBF4 for ; Thu, 24 May 2012 11:23:52 -0400 Received: by yhfq11 with SMTP id q11so8918122yhf.29 for ; Thu, 24 May 2012 08:23:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding:x-gm-message-state; bh=JaCcgbUM50X8VZ/ezlWsENTxhFquink47kk9uqRNyAA=; b=nN7gwUaT72znLFYPOKvwpm3ZCoPDKAGCFSqzzp2D736H40XFafWT5V5FAVwb7YcE1k JDbNV6yhpVghIxUMuf2RPXy0JCapCq4do490ulxHwHQIKfFxckSikiZ56/EGYphF2jMU kJUrrmCHZHeHpk43MnmZdR1/Rax/O4yjIKFJXcCmf8/MgDGSOBpX4QQV4uF+Zydmn2k3 bycMohZ1oSUPXfJZE7/2BnyeujXK8qLAaSZVHV4dec7ns2HBSdF6tmwShQXFQCqMKsvQ J3M/Cf+JM4KfELGVE2YXBgxWVrhk+R11lQdS6jaqqvNLfCs29I7vqRaI2EXpXcnegEFO PCKA== MIME-Version: 1.0 Received: by 10.236.201.229 with SMTP id b65mr36810216yho.80.1337873029262; Thu, 24 May 2012 08:23:49 -0700 (PDT) Received: by 10.100.109.13 with HTTP; Thu, 24 May 2012 08:23:49 -0700 (PDT) In-Reply-To: <55e590f078f22ca2bbe10d5187cd3d84.squirrel@www.l-i-e.com> References: <55e590f078f22ca2bbe10d5187cd3d84.squirrel@www.l-i-e.com> Date: Thu, 24 May 2012 11:23:49 -0400 Message-ID: To: PHP Internals Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQkEjfuUmcItWp19TMFeTZ7Otfrqtq6k1yvp8mdEcLkjZEdXlVyhdp/MPpMqiU98JuUxB3Lq Subject: Re: [PHP-DEV] php interpreter From: tom@punkave.com (Tom Boutell) 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 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 =3D in_cache($path)){ > } > else{ > =A0//super-duper slow!!! > =A0$source_code =3D file_get_contents($path); > } > $bytecode =3D zend_parse($source_code); > zend_execute($bytecode); > > //save hitting the hard disk > //and a small bonus, cache the bytecode, not source: > > if ($bytecode =3D in_cache($path)){ > =A0//do nothing > } > else{ > =A0$source_code =3D file_get_contents($path); > =A0$bytecode =3D 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=3D_s-xclick&hosted_button_id=3D= FS9NLTNEEKWBE > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > --=20 Tom Boutell P'unk Avenue 215 755 1330 punkave.com window.punkave.com