|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-08-27 07:54 UTC] olga at metacafe dot com
Description:
------------
Hi,
We recently upgraded our web servers with PHP 5.3 and found out that there are lots of empty fstat system calls. fstat is called 3 times on each file open. This does not happen on PHP 5.2.9.
PHP 5.2.9 shows better results in benchmarking vs. 5.3.0, and I suppose it's because of the fstat.
We're running Red Hat 3.4.6, Apache 2.0.59, PHP 5.3.0
Reproduce code:
---------------
Any code that loads PHP file.
Expected result:
----------------
Strace summary from 5.2.9
% time seconds usecs/call calls errors syscall
44.65 34.487815 159 217129 26 lstat
8.73 6.743625 170 39745 145 stat
8.23 6.355874 170 37466 18 open
8.21 6.345542 167 38091 close
7.99 6.170706 165 37410 fstat
Strace summary from 5.3.0
% time seconds usecs/call calls errors syscall
22.64 28.292541 301 93945 fstat
18.39 22.979631 312 73713 110 lstat
9.23 11.529433 311 37131 munmap
9.14 11.417404 306 37277 mmap
8.52 10.643572 306 34755 149 stat
Actual result:
--------------
Strace result.
I replaced full path by [path]
open("[path]/Flash.php", O_RDONLY) = 21
fstat(21, {st_mode=S_IFREG|0777, st_size=23902, ...}) = 0
fstat(21, {st_mode=S_IFREG|0777, st_size=23902, ...}) = 0
fstat(21, {st_mode=S_IFREG|0777, st_size=23902, ...}) = 0
mmap(NULL, 23902, PROT_READ, MAP_SHARED, 21, 0) = 0x2a971a2000
stat("[path]/Flash.php", {st_mode=S_IFREG|0777, st_size=23902, ...}) = 0
munmap(0x2a971a2000, 23902) = 0
close(21) = 0
lstat("[path]/VTalkNotification.php", {st_mode=S_IFREG|0777, st_size=778, ...}) = 0
lstat("[path]/VTalkNotification.php", {st_mode=S_IFREG|0777, st_size=778, ...}) = 0
open("[path]/VTalkNotification.php", O_RDONLY) = 21
fstat(21, {st_mode=S_IFREG|0777, st_size=778, ...}) = 0
fstat(21, {st_mode=S_IFREG|0777, st_size=778, ...}) = 0
fstat(21, {st_mode=S_IFREG|0777, st_size=778, ...}) = 0
mmap(NULL, 778, PROT_READ, MAP_SHARED, 21, 0) = 0x2a971a2000
stat("[path]/VTalkNotification.php", {st_mode=S_IFREG|0777, st_size=778, ...}) = 0
munmap(0x2a971a2000, 778) = 0
close(21) = 0
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 09:00:02 2025 UTC |
Any PHP code does it. The code: <?php echo "Hello!"; ?> The strace: open("[path]/test.php", O_RDONLY) = 16 fstat(16, {st_mode=S_IFREG|0644, st_size=82, ...}) = 0 fstat(16, {st_mode=S_IFREG|0644, st_size=82, ...}) = 0 fstat(16, {st_mode=S_IFREG|0644, st_size=82, ...}) = 0 mmap(NULL, 82, PROT_READ, MAP_SHARED, 16, 0) = 0x2a9a8b4000 munmap(0x2a9a8b4000, 82) = 0 close(16) = 0I wonder if this has been fixed. I've noticed the same behavior in php5.6 (PHP 5.6.39-1+ubuntu16.04.1+deb.sury.org+1). I know it's an old version but I am just checking if some solution was proposed. - opcache enabled - open_basedir disabled after open() is issued, 4 exactly same fstat() calls occur. I guess 3 of them are not necessary and in long-term it eats sys% like this: % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 20.23 0.008665 2 5511 fstat 18.91 0.008097 3 2382 poll 14.58 0.006244 3 2382 recvfrom 10.25 0.004390 3 1341 munmap 9.69 0.004151 3 1467 open 9.34 0.004000 222 18 shutdown 7.20 0.003083 10 318 brk 4.07 0.001741 1 1481 sendto 2.55 0.001093 1 1072 19 access 1.30 0.000555 6 90 write 0.72 0.000308 0 1341 mmap ... See the time CPU mostly spent in syscalls is at the very fast but redundant fstat() call. ... access("luigisBoxHtmlBodyEnd.php", R_OK) = 0 open("luigisBoxHtmlBodyEnd.php", O_RDONLY) = 7 fstat(7, {st_mode=S_IFREG|0644, st_size=438, ...}) = 0 fstat(7, {st_mode=S_IFREG|0644, st_size=438, ...}) = 0 fstat(7, {st_mode=S_IFREG|0644, st_size=438, ...}) = 0 fstat(7, {st_mode=S_IFREG|0644, st_size=438, ...}) = 0 mmap(NULL, 438, PROT_READ, MAP_SHARED, 7, 0) = 0x7f8560433000 ... Would this be fixed in php7 if the site is moved there? Thanks.我也遇到了这个问题好像是opchache无法使用的情况下 access("/data/web/releases/20190122_1036111_2/src/application/Models/LocalModel.php", F_OK) = 0 open("/data/web/releases/20190122_1036111_2/src/application/Models/LocalModel.php", O_RDONLY) = 9 fstat(9, {st_mode=S_IFREG|0755, st_size=416, ...}) = 0 fstat(9, {st_mode=S_IFREG|0755, st_size=416, ...}) = 0 fstat(9, {st_mode=S_IFREG|0755, st_size=416, ...}) = 0 mmap(NULL, 416, PROT_READ, MAP_SHARED, 9, 0) = 0x7fea60241000 munmap(0x7fea60241000, 416) = 0 close(9) = 0