Re: Reducing the number of system calls for includes
| From: | Rasmus Lerdorf | Date: | Sat, 25 Jan 2003 00:51:45 +0000 |
| Subject: | Re: Reducing the number of system calls for includes | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-93656@lists.php.net to get a copy of this message | ||
On Sat, 25 Jan 2003, Andi Gutmans wrote:
> At 04:32 PM 1/24/2003 -0800, Rasmus Lerdorf wrote:
> > > I can't really think of any way of getting around this. include_once() and
> > > require_once() are basic language constructs and they require this.
> >
> >Well, they require us to be able to uniquely identify a file, they do not
> >necessarily require us to know the canonical filename. This could be done
> >in a single stat where we grab the device number and inode.
>
> Yeah but on broken systems single stat's also stat each directory (AFAIK).
> I don't think it's any faster or at least not noticably.
Which broken systems? Certainly not on FreeBSD or Linux. A little test:
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
int main(void) {
struct stat sb;
stat("/home/rasmus/foo/u2.inc",&sb);
printf("%d:%d\n",sb.st_dev, sb.st_ino);
}
That ends up doing just a single stat on FreeBSD:
stat("/home/rasmus/foo/u2.inc",0x9fbffa0c) = 0 (0x0)
and on Linux:
stat64("/home/rasmus/foo/u2.inc", {st_mode=S_IFREG|0644, st_size=12, ...}) = 0
-Rasmus