1
When searching for a library file from a right folder, my application currently does couple of lstat's for the possible locationslocations. Now I'm wondering whether these lstat's (application is being a web service, thereby there can be hundred's of lstat's per second) cause always a an additional disk seek, or are those seeks cached?
System is Linux (2.6. kernel) with ext4 -based filesystem.
Part of PHP-CGI strace:
PHP-CGI strace:
lstat("/home/www/mydomain.com/inc/myLibrary/php/classes/myClass.php", 0x7fffa805a710) = -1 ENOENT (No such file or directory)
lstat("/usr/share/php/inc/myLibrary/php/classes/myClass.php", 0x7fffa805a710) = -1 ENOENT (No such file or directory)
getcwd("/home/www/mydomain.com/misc", 4096) = 32
lstat("/home/www/mydomain.com/misc/./inc/myLibrary/php/classes/myClass.php", 0x7fffa805a710) = -1 ENOENT (No such file or directory)
lstat("/home/www/mydomain.com/inc/inc/myLibrary/php/classes/myClass.php", 0x7fffa805a710) = -1 ENOENT (No such file or directory)
lstat("/home/www/mydomain.com/inc/myLibrary/php/classes/myClass.php", 0x7fffa805a660) = -1 ENOENT (No such file or directory)
lstat("/usr/share/php/inc/myLibrary/php/classes/myClass.php", 0x7fffa805a660) = -1 ENOENT (No such file or directory)
getcwd("/home/www/mydomain.com/misc", 4096) = 32
lstat("/home/www/mydomain.com/misc/./inc/myLibrary/php/classes/myClass.php", 0x7fffa805a660) = -1 ENOENT (No such file or directory)
lstat("/home/www/mydomain.com/inc/inc/myLibrary/php/classes/myClass.php", 0x7fffa805a660) = -1 ENOENT (No such file or directory)
getcwd("/home/www/mydomain.com/misc", 4096) = 32
lstat("/home/www/mydomain.com/misc/inc/myLibrary/php/classes/myClass.php", 0x7fffa805c7c0) = -1 ENOENT (No such file or directory)
lstat("/home/www/mydomain.com/misc/inc/myLibrary/php/classes", 0x7fffa805c600) = -1 ENOENT (No such file or directory)
lstat("/home/www/mydomain.com/misc/inc/myLibrary/php", 0x7fffa805c450) = -1 ENOENT (No such file or directory)
lstat("/home/www/mydomain.com/misc/inc/myLibrary", 0x7fffa805c2a0) = -1 ENOENT (No such file or directory)
lstat("/home/www/mydomain.com/misc/inc", 0x7fffa805c0f0) = -1 ENOENT (No such file or directory)
open("/home/www/mydomain.com/misc/inc/myLibrary/php/classes/myClass.php", O_RDONLY) = -1 ENOENT (No such file or directory)
/* FILE FOUND */
open("/home/www/mydomain.com/inc/classes/myClass.php", O_RDONLY) = 7
fstat(7, {st_mode=S_IFREG|0775, st_size=7734, ...}) = 0
fstat(7, {st_mode=S_IFREG|0775, st_size=7734, ...}) = 0
fstat(7, {st_mode=S_IFREG|0775, st_size=7734, ...}) = 0
fstat(7, {st_mode=S_IFREG|0775, st_size=7734, ...}) = 0
mmap(NULL, 7734, PROT_READ, MAP_SHARED, 7, 0) = 0x7f2225786000
stat("/home/www/mydomain.com/inc/classes/myClass.php", {st_mode=S_IFREG|0775, st_size=7734, ...}) = 0
1If you want to prove this to yourself, try this out. Restart the system, so the cache is cleared out. Then run a "find" command. Watch as your disk seeks. Once the command finishes, run the command again. They amount of disk activity will be noticeably lower. – Anthony Giorgio – 2011-10-14T11:40:40.780