php进程LD_LIBRARY_PATH大cpu用法

时间:2013-02-27 15:44:45

标签: php system-calls strace

我发现使用这么多CPU的PHP进程的原因,服务器是Apache mpm worker + suphp 下面是'strace php'的一些输出,正如你所看到的,进程是在'不正确'的路径中寻找dso,这些只是编译的PHP扩展,有没有办法指定搜索路径为'/ lib64:/ usr / lib64'? 因为我发现它最终在lib64或/ usr / lib64中加载dso,经过多次否定路径尝试,这是系统CPU消耗,你知道,这么多系统调用是徒劳的。提前谢谢。

open("/opt/xslt/lib/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/tidy/lib/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/mhash/lib/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/libmcrypt/lib/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/pcre/lib/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/curlssl/lib/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/mysql/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/xml2/lib/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/pcre/lib64/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/curlssl//lib64/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/php_with_imap_client//lib64/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/libmcrypt//lib64/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/mhash//lib64/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/tidy//lib64/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/xslt//lib64/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/tls/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib64/libselinux.so.1", O_RDONLY) = 3

open("/opt/xslt/lib/libsepol.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/tidy/lib/libsepol.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/mhash/lib/libsepol.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/libmcrypt/lib/libsepol.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/pcre/lib/libsepol.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/curlssl/lib/libsepol.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/mysql/libsepol.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/xml2/lib/libsepol.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/pcre/lib64/libsepol.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/curlssl//lib64/libsepol.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/php_with_imap_client//lib64/libsepol.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/libmcrypt//lib64/libsepol.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/mhash//lib64/libsepol.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/tidy//lib64/libsepol.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/xslt//lib64/libsepol.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/tls/libsepol.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/libsepol.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib64/libsepol.so.1", O_RDONLY)  = 3
open("/opt/xslt/lib/libnss_files.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/tidy/lib/libnss_files.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/mhash/lib/libnss_files.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/libmcrypt/lib/libnss_files.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/pcre/lib/libnss_files.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/curlssl/lib/libnss_files.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/mysql/libnss_files.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/xml2/lib/libnss_files.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/pcre/lib64/libnss_files.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/curlssl//lib64/libnss_files.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/php_with_imap_client//lib64/libnss_files.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/libmcrypt//lib64/libnss_files.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/mhash//lib64/libnss_files.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/tidy//lib64/libnss_files.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/xslt//lib64/libnss_files.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/tls/libnss_files.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/libnss_files.so.2", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib64/libnss_files.so.2", O_RDONLY) = 3

我的意见是否正确?或者下面是否导致CPU占用率过高?

lstat("/home", {st_mode=S_IFDIR|0711, st_size=4096, ...}) = 0
lstat("/home/socialth", {st_mode=S_IFDIR|0711, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components/com_content", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components/com_content/router.php", {st_mode=S_IFREG|0644, st_size=8157, ...}) = 0
stat("/home/socialth/public_html/components/com_content/router.php", {st_mode=S_IFREG|0644, st_size=8157, ...}) = 0
stat("/home/socialth/public_html/index.php", {st_mode=S_IFREG|0644, st_size=1971, ...}) = 0
access("/home/socialth/public_html/components/com_content/router.php", F_OK) = 0
lstat("/home", {st_mode=S_IFDIR|0711, st_size=4096, ...}) = 0
lstat("/home/socialth", {st_mode=S_IFDIR|0711, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components/com_content", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components/com_content/router.php", {st_mode=S_IFREG|0644, st_size=8157, ...}) = 0
lstat("/home", {st_mode=S_IFDIR|0711, st_size=4096, ...}) = 0
lstat("/home/socialth", {st_mode=S_IFDIR|0711, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components/com_content", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components/com_content/router.php", {st_mode=S_IFREG|0644, st_size=8157, ...}) = 0
stat("/home/socialth/public_html/components/com_content/router.php", {st_mode=S_IFREG|0644, st_size=8157, ...}) = 0
stat("/home/socialth/public_html/index.php", {st_mode=S_IFREG|0644, st_size=1971, ...}) = 0
access("/home/socialth/public_html/components/com_content/router.php", F_OK) = 0
lstat("/home", {st_mode=S_IFDIR|0711, st_size=4096, ...}) = 0
lstat("/home/socialth", {st_mode=S_IFDIR|0711, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components/com_content", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components/com_content/router.php", {st_mode=S_IFREG|0644, st_size=8157, ...}) = 0
lstat("/home", {st_mode=S_IFDIR|0711, st_size=4096, ...}) = 0
lstat("/home/socialth", {st_mode=S_IFDIR|0711, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components/com_content", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components/com_content/router.php", {st_mode=S_IFREG|0644, st_size=8157, ...}) = 0
stat("/home/socialth/public_html/components/com_content/router.php", {st_mode=S_IFREG|0644, st_size=8157, ...}) = 0
stat("/home/socialth/public_html/index.php", {st_mode=S_IFREG|0644, st_size=1971, ...}) = 0
access("/home/socialth/public_html/components/com_content/router.php", F_OK) = 0
lstat("/home", {st_mode=S_IFDIR|0711, st_size=4096, ...}) = 0
lstat("/home/socialth", {st_mode=S_IFDIR|0711, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components/com_content", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components/com_content/router.php", {st_mode=S_IFREG|0644, st_size=8157, ...}) = 0
lstat("/home", {st_mode=S_IFDIR|0711, st_size=4096, ...}) = 0
lstat("/home/socialth", {st_mode=S_IFDIR|0711, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components/com_content", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components/com_content/router.php", {st_mode=S_IFREG|0644, st_size=8157, ...}) = 0
stat("/home/socialth/public_html/components/com_content/router.php", {st_mode=S_IFREG|0644, st_size=8157, ...}) = 0
stat("/home/socialth/public_html/index.php", {st_mode=S_IFREG|0644, st_size=1971, ...}) = 0
access("/home/socialth/public_html/components/com_content/router.php", F_OK) = 0
lstat("/home", {st_mode=S_IFDIR|0711, st_size=4096, ...}) = 0
lstat("/home/socialth", {st_mode=S_IFDIR|0711, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components/com_content", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components/com_content/router.php", {st_mode=S_IFREG|0644, st_size=8157, ...}) = 0
lstat("/home", {st_mode=S_IFDIR|0711, st_size=4096, ...}) = 0
lstat("/home/socialth", {st_mode=S_IFDIR|0711, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components/com_content", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components/com_content/router.php", {st_mode=S_IFREG|0644, st_size=8157, ...}) = 0
stat("/home/socialth/public_html/components/com_content/router.php", {st_mode=S_IFREG|0644, st_size=8157, ...}) = 0    
stat("/home/socialth/public_html/index.php", {st_mode=S_IFREG|0644, st_size=1971, ...}) = 0
access("/home/socialth/public_html/components/com_content/router.php", F_OK) = 0
lstat("/home", {st_mode=S_IFDIR|0711, st_size=4096, ...}) = 0
lstat("/home/socialth", {st_mode=S_IFDIR|0711, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components/com_content", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components/com_content/router.php", {st_mode=S_IFREG|0644, st_size=8157, ...}) = 0
lstat("/home", {st_mode=S_IFDIR|0711, st_size=4096, ...}) = 0
lstat("/home/socialth", {st_mode=S_IFDIR|0711, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components/com_content", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components/com_content/router.php", {st_mode=S_IFREG|0644, st_size=8157, ...}) = 0
stat("/home/socialth/public_html/components/com_content/router.php", {st_mode=S_IFREG|0644, st_size=8157, ...}) = 0
stat("/home/socialth/public_html/index.php", {st_mode=S_IFREG|0644, st_size=1971, ...}) = 0
access("/home/socialth/public_html/components/com_content/router.php", F_OK) = 0
lstat("/home", {st_mode=S_IFDIR|0711, st_size=4096, ...}) = 0
lstat("/home/socialth", {st_mode=S_IFDIR|0711, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html", {st_mode=S_IFDIR|0750, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components/com_content", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/home/socialth/public_html/components/com_content/router.php", {st_mode=S_IFREG|0644, st_size=8157, ...}) = 0

1 个答案:

答案 0 :(得分:0)

你无能为力,特别是因为所有这些软件包都在自己的小目录树中安装了自己。虽然/ opt是一个很好的概念,可以将整个软件包相互隔离,但它确实意味着任何提供给系统其余部分的共享库的软件包都必须放入库搜索路径,最后你会得到长时间无意义的打开/搜索任何共享库时的stat调用。您可以做的唯一优化可能是重新排列路径,以便不常使用的库位于搜索路径的尾端,以便命中“更快”,并且不会浪费时间检查很少使用的区域。

同样适用于您的PHP自动加载器。由于系统会在每个阶段检查访问权限,因此还需要通向任何特定文件的长统计链。

顺便说一句,这就是为什么不鼓励使用.htaccess文件的确切原因。一旦启用了.htaccess,Apache就必须检查每个单个目录,然后检查所请求的文件是否存在.htaccess文件。如果文件存在,则必须加载/解析/等等......所有这些都浪费了大量的cpu周期和磁盘带宽。

.htaccess在开发/测试时很好,但是一旦你有一个可行的设置,.htaccess指令应该转移到主服务器.conf文件,所以它们只在服务器启动时加载/解析ONCE