올바른 폴더에서 라이브러리 파일을 검색 할 때 응용 프로그램은 현재 가능한 위치 위치에 대해 두 개의 lstat를 수행합니다. 이제 나는이 lstat (응용 프로그램이 웹 서비스이므로 초당 수백 개의 lstat가있을 수 있음)가 항상 추가 디스크 탐색을 유발하는지, 아니면 탐색이 캐시되는지 궁금합니다.
시스템은 ext4 기반 파일 시스템이있는 Linux (2.6. 커널)입니다.
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