Yesterday I made some tests on my site with strace to see how much lstat I have and how can I optimize them. Well, I managed to get rid of them almost at all, but now I have some questions about include_path and including files based on current dir.
I have such structire of files /home/file/www (that's my site root dir) include/ - bittorrent - global.php lang/ - eng.lang - rus.lang index.php My files are ---- index.php --- require './include/bittorrent.php'; --- common.php --- require './include/global.php'; require './lang/eng.lang'; And some other files from include dir Default include path is ".:/usr/share/php5:/usr/share/php" and if I don't change it it results in a bunch of lstat. Here is the trace http://pastebin.com/m37704b6a The thing I don't understand from trace is WHY it tests include path BEFORE the ./ ? Why it doesn't try to load file based on relative path first (it should hit it on first try) and then use include path? Ok, I make in bittorrent.php - set_include_path('/home/file/www'); The only lstat i have now is lstat("/home", {st_mode=S_IFDIR|0755, st_size=144, ...}) = 0 lstat("/home/file", {st_mode=S_IFDIR|0755, st_size=1112, ...}) = 0 lstat("/home/file/www", {st_mode=S_IFDIR|0755, st_size=11880, ...}) = 0 lstat("/home/file/www/bittorrent.php", 0x7fff8d95cca0) = -1 ENOENT (No such file or directory) open("/home/file/www/bittorrent.php", O_RDONLY) = -1 ENOENT (No such file or directory) open("/home/file/www/include/bittorrent.php", O_RDONLY) = 14 So the question is - why are they happen at all, if I include bittorrent.php as require './include/bittorrent.php' in index.php. As i understand it should hit the right folder from first time. Could you, please, explain how all this works, because as it turned out it is not so obvious as it should be... I have PHP 5.2.6 (Gentoo Linux package name is dev-php5/php-5.2.6-r2) and lighttpd 1.5