Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:49885 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47174 invoked from network); 7 Oct 2010 18:09:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Oct 2010 18:09:44 -0000 X-Host-Fingerprint: 71.224.215.41 c-71-224-215-41.hsd1.pa.comcast.net Received: from [71.224.215.41] ([71.224.215.41:27117] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 73/09-01054-7EC0EAC4 for ; Thu, 07 Oct 2010 14:09:43 -0400 Message-ID: <73.09.01054.7EC0EAC4@pb1.pair.com> To: internals@lists.php.net Date: Thu, 7 Oct 2010 14:09:11 -0400 Lines: 20 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3664 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3664 X-RFC2646: Format=Flowed; Original X-Posted-By: 71.224.215.41 Subject: stat functions do each path component? From: snicholnews@scottnichol.com ("Scott Nichol") In comparing the performance of PHP 5.2.5 file_exists calls versus C stat calls, I discovered via Windows sysinternals ProcessMonitor that PHP seems to do a stat on each component of a file path. For example, file_exists("e:\\wamp\\www\\ra-v2\\system\\application\\libraries\\MY_Controller.php") appears to stat "E:\wamp", "E:\wamp\www", etc., finally getting to the file. That compares to doing _stat64 of "e:\\wamp\\www\\ra-v2\\system\\application\\libraries\\MY_Controller.php" in C, which just does the stat on the file. The timings from my tests show the C app finishing in about one-seventh the time, which is what I would expect from the PHP code doing seven times as many stat calls. Assuming my inference about all the stat calls is correct, is there a rationale for this? If the PHP app I am working on made just a couple of file_exists calls, I would not bother to ask, but it uses the CodeIgniter framework which is doing >100 file_exists calls for each page being accessed, so the affect is very noticeable. FYI, I poked around the PHP SVN web interface for a while and found php_check_open_basedir_ex called in plain_wrapper.c, which I suspect causes the calls, but ran out of steam before confirming the cause of the behavior. TIA -- Scott Nichol