Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:2161 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5548 invoked from network); 4 Jun 2003 16:22:02 -0000 Received: from unknown (HELO www.lerdorf.com) (66.93.78.119) by pb1.pair.com with SMTP; 4 Jun 2003 16:22:02 -0000 Received: from rasmus2.corp.yahoo.com (rasmus2.corp.yahoo.com [207.126.232.175]) by www.lerdorf.com (8.12.9/8.12.9/Debian-3) with ESMTP id h54GM1KN000641; Wed, 4 Jun 2003 09:22:01 -0700 Date: Wed, 4 Jun 2003 09:21:55 -0700 (PDT) To: Jeff Moore cc: internals@lists.php.net In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [PHP-DEV] Benchmarking 4.3.2 vs 4.1.2 From: rasmus@lerdorf.com (Rasmus Lerdorf) Uh, the number of open() calls really shouldn't change. Are you sure you are comparing the same code? And how are you testing? Attach strace or truss to your running httpd process and hit your script a single time. Then look at the output and compare them. Some of the keys to reducing syscalls: - don't use open_basedir or safe_mode restrictions - always include/require files by their absolute paths (./foo.inc is ok) - if you have to use include_path includes, make sure the dir you hit most often is first in the include_path (even before .) - optimize your code. ie. don't use while(!feof($fp)) to loop through a file, check the return of your fgets() instead, for example. In your example, you can of course replace your code with a single call to file_get_contents() which is a new function in 4.3 and should significantly reduce your syscall overhead. 4.3.3 will have Sascha's fd-patch which gets rid of a stat() call associated with every file open, so if you are really keen on reducing your syscalls even further, you can grab a snapshot. I also have some hacks we use here at Yahoo that eliminate a bunch of other calls, but they aren't exactly generic in that they break various aspects of PHP that in my controlled environment here I am fine with. I have been pondering whether to add some sort of --broken-but-fast compile switch an commit those changes, but it would likely cause a whole lot of confusion. -Rasmus On Wed, 4 Jun 2003, Jeff Moore wrote: > I remember a discussion about system calls here earlier. What is the > status of that? > > I've been doing some tests and have found that this code runs about 2.5 > times slower under 4.3.2 than it did on 4.1.2 on the same machine > (running OS X): > > $filename = 'file.html'; > $fd = fopen($filename, 'rb'); > $content = fread($fd, filesize($filename)); > fclose($fd); > echo $content; > ?> > > I did some tests with fs_usage to check file system calls and found > that for a zero length test.php file, 4.3.2 makes the following > additional calls beyond 4.1.2: > > 1 chdir /Library/WebServer/Documents/rot/bench > 1 fchdir > 12 fstat > 5 fstatfs > 5 getdirentries > 7 lseek O=0x00000000 > 1 lstat test.php > 6 lstat (., .., ../.., etc. > 6 open (., .., ../.., etc) > 1 stat > > The fread example above made the following additional calls in 4.3.2 > beyond 4.1.2: > > 2 chdir /Library/WebServer/Documents/rot/bench > 2 fchdir > 32 fstat > 15 fstatfs > 15 getdirentries > 16 lseek O=0x00000000 > 1 lstat file.html > 1 lstat test.php > 18 lstat (., .., ../.., etc.) > 17 open (., .., ../.., etc) > 4 stat > 1 stat . > > some of my counts my be slightly off - I counted them by hand. > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >