Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45472 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63262 invoked from network); 3 Sep 2009 17:38:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Sep 2009 17:38:28 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 209.85.220.212 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 209.85.220.212 mail-fx0-f212.google.com Received: from [209.85.220.212] ([209.85.220.212:60660] helo=mail-fx0-f212.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FA/6F-19451-31FFF9A4 for ; Thu, 03 Sep 2009 13:38:28 -0400 Received: by fxm8 with SMTP id 8so119135fxm.23 for ; Thu, 03 Sep 2009 10:38:24 -0700 (PDT) Received: by 10.204.15.151 with SMTP id k23mr8145438bka.41.1251999503460; Thu, 03 Sep 2009 10:38:23 -0700 (PDT) Received: from trainburn-lm.corp.yahoo.com (trainburn-lm.corp.yahoo.com [207.126.233.11]) by mx.google.com with ESMTPS id g28sm187663fkg.15.2009.09.03.10.38.21 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 03 Sep 2009 10:38:22 -0700 (PDT) Message-ID: <4A9FFF0B.1060508@lerdorf.com> Date: Thu, 03 Sep 2009 10:38:19 -0700 User-Agent: Thunderbird 2.0.0.18 (Macintosh/20081105) MIME-Version: 1.0 To: PHP Developers Mailing List X-Enigmail-Version: 0.96.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Logic for mmap in php_stream_open_for_zend_ex From: rasmus@lerdorf.com (Rasmus Lerdorf) Guys, what was the reasoning behind the mmap in php_stream_open_for_zend_ex()? Especially for small files, I don't see a speedup here, and because of some rather sub-optimal fstat behaviour it seems like this has slowed things down quite a bit. See http://bugs.php.net/49383 We now have 3 fstats on the same file between the open() and the mmap() on every compile. The 3 paths to the fstat look like this: #1 0x0137642f in do_fstat () #2 0x0137768f in _php_stream_fopen () #3 0x013719ba in _php_stream_open_wrapper_ex () #4 0x0135a1a3 in php_stream_open_for_zend_ex () #5 0x0135a2e0 in php_stream_open_for_zend () #6 0x013ca05f in zend_stream_fixup () #7 0x01383ae7 in open_file_for_scanning () #8 0x01383c8d in compile_file () #9 0x011eb8f7 in phar_compile_file () #10 0x013b4fa7 in zend_execute_scripts () #11 0x0135be38 in php_execute_script () #1 0x0137642f in do_fstat () #2 0x01376ee1 in php_stdiop_stat () #3 0x0135a148 in php_zend_stream_fsizer () #4 0x0135a206 in php_stream_open_for_zend_ex () #5 0x0135a2e0 in php_stream_open_for_zend () #6 0x013ca05f in zend_stream_fixup () #7 0x01383ae7 in open_file_for_scanning () #8 0x01383c8d in compile_file () #9 0x011eb8f7 in phar_compile_file () #10 0x013b4fa7 in zend_execute_scripts () #11 0x0135be38 in php_execute_script () #1 0x0137642f in do_fstat () #2 0x01377189 in php_stdiop_set_option () #3 0x0136fc8e in _php_stream_set_option () #4 0x0137dcec in _php_stream_mmap_range () #5 0x0135a295 in php_stream_open_for_zend_ex () #6 0x0135a2e0 in php_stream_open_for_zend () #7 0x013ca05f in zend_stream_fixup () #8 0x01383ae7 in open_file_for_scanning () #9 0x01383c8d in compile_file () #10 0x011eb8f7 in phar_compile_file () #11 0x013b4fa7 in zend_execute_scripts () #12 0x0135be38 in php_execute_script () Each of those do_fstat() calls sets the 'force' flag which ignores the cached stat struct and these are called in rapid succession from php_stream_open_for_zend_ex in main/main.c As far as I am concerned, we don't need any of those stats. Not even the first one for the top-level script. sapi_get_stat() will give us the stat struct from the sapi-level stat which has already been done and all those forced stats make mmap'ing small files smaller than simply reading them. -Rasmus