- 本文地址: https://www.laruence.com/2020/04/18/5832.html
- 转载请注明出处
经过俩周多的重构,终于一咬牙今天发布了Yaf 3.2.0 beta, 要不然一直在想各种可能的优化点,不停的写,没完了, 🙂
这次的重构的最初出发点是把原来的Yaf对象从PHP的原生对象,改成了自定义的对象:
结构重构
之前的Yaf版本,比如我们拿Yaf_Request为例,它原来是一个PHP的对象,它有属性,用起来也跟用户在PHP中定义的对象一样,比如在之前的版本的Yaf中,在扩展中如果要获取Request对象的uri属性,那么:
zend_read_property(yaf_request_ce, obj, “uri”, sizeof(“uri”)-1, 1, NULL);
去”读取“这个request对象的uri属性,一定程度上这个有一定的历史原因,毕竟这个Yaf是十年前写的:)
而在3.2.0以后,Yaf_Request对象成为了一个纯粹的C结构体:
typedef struct { zend_uchar flags; zend_string *method; zend_string *module; zend_string *controller; zend_string *action; zend_string *base_uri; zend_string *uri; zend_string *language; zend_array *params; zend_array *properties; zend_object std; } yaf_request_object;
这样的定义如果大家看过我之前的文章深入理解PHP7内核之Object应该不会陌生,当用户在PHP脚本端获取到Yaf_Request对象的时候,对应的就是yaf_request_object.std这个成员。
这样以来,如果要获取uri的话,只需要根据偏移量,从std获取到yaf_request_object的地址,然后(yaf_request_object)->uri,就可以了。这样性能就会有较为明显的提升。
所有的Yaf提供的类都被重写成这种形式,但这样以来就需要模拟PHP的对象行为,让用户在PHP脚本中也想获取Yaf_Request对象的uri属性的时候,也可以正常访问。
另外,就是对缓存友好的提升,除了尽量降低内存使用以外,举一个例子:比如原来的时候,对全局变量的使用较多, 主要是指YAF_G(),这样对于一些很热点的函数来说,如果使用了太多的全局变量,对缓存也不够友好,于是把很多flag类的字段,收敛到了对象本身,比如对于Yaf_Loader, 他需要关注是否启用了use_spl_autoload, name_suffix, name_separtor以及lowercase_path等多个flag, 原来都是需要访问Yaf_G(). 现在统一都收敛到了yaf_loader_object->flags中。(实际上是复用了std.properties_table[0].u2.var_flags字段作为flags,没有新增内存)
#define YAF_LOADER_FLAGS(loader) YAF_VAR_FLAGS(loader->std.properties_table[0]) typedef struct { zend_object std; zend_string *library; zend_string *glibrary; zend_array *properties; } yaf_loader_object
PSR-4 Autoloading
另外这次对自动加载器新增了部分PSR-4的支持,用户现在可以申明一个namespace的加载路径:
Yaf_Loader::getInstance()->registerNamespace(“\Foo\Bar”, “/var/lib/foo”);
那么所有在\Foo\Bar命名空间下的类就会从/var/lib/foo目录下查找:
\Foo\Bar\Dummy -> /var/lib/foo/Dummy.php
当然你也可以在配置文件中注册namespace path:
application.library.namespace./Foo/Bar=“/var/lib/foo”
\Foo\Bar\Ver_Don -> /var/lib/foo/Ver/Don.php
性能提升
这次的重构本质上还是为了性能提升, 那实际效果如何呢?
为了能较为真实的反应测试,我采用了Yaf代码下的demo生成器tool/cg/yaf_cg来生成一个完整的Yaf应用框架,然后通过cachegrind来详细对比。
tools/cg/yaf_cg -d yaf
首先php-7.4 , yaf-3.1.4, 跑1000次 :
valgrind --tool=cachegrind /path-to-php74/bin/php-cgi -T 1000 index.php
Elapsed time: 6.020169 sec ==11203== ==11203== I refs: 232,666,798 ==11203== I1 misses: 3,669,999 ==11203== LLi misses: 10,163 ==11203== I1 miss rate: 1.57% ==11203== LLi miss rate: 0.00% ==11203== ==11203== D refs: 102,960,876 (61,041,772 rd + 41,919,104 wr) ==11203== D1 misses: 5,065,700 ( 2,386,201 rd + 2,679,499 wr) ==11203== LLd misses: 909,412 ( 363,850 rd + 545,562 wr) ==11203== D1 miss rate: 4.9% ( 3.9% + 6.3% ) ==11203== LLd miss rate: 0.8% ( 0.5% + 1.3% ) ==11203== ==11203== LL refs: 8,735,699 ( 6,056,200 rd + 2,679,499 wr) ==11203== LL misses: 919,575 ( 374,013 rd + 545,562 wr) ==11203== LL miss rate: 0.2% ( 0.1% + 1.3% ) ==11203== ==11203== Branches: 44,906,888 (42,750,345 cond + 2,156,543 ind) ==11203== Mispredicts: 4,112,611 ( 3,492,036 cond + 620,575 ind) ==11203== Mispred rate: 9.1% ( 8.1% + 28.7% )
然后php-7.4 yaf-3.2.0 也跑1000次:
Elapsed time: 4.658264 sec ==18814== ==18814== I refs: 171,236,262 ==18814== I1 misses: 2,940,070 ==18814== LLi misses: 10,007 ==18814== I1 miss rate: 1.71% ==18814== LLi miss rate: 0.00% ==18814== ==18814== D refs: 75,584,870 (44,264,393 rd + 31,320,477 wr) ==18814== D1 misses: 4,302,787 ( 1,956,414 rd + 2,346,373 wr) ==18814== LLd misses: 908,224 ( 363,351 rd + 544,873 wr) ==18814== D1 miss rate: 5.6% ( 4.4% + 7.4% ) ==18814== LLd miss rate: 1.2% ( 0.8% + 1.7% ) ==18814== ==18814== LL refs: 7,242,857 ( 4,896,484 rd + 2,346,373 wr) ==18814== LL misses: 918,231 ( 373,358 rd + 544,873 wr) ==18814== LL miss rate: 0.3% ( 0.1% + 1.7% ) ==18814== ==18814== Branches: 32,043,848 (30,444,567 cond + 1,599,281 ind) ==18814== Mispredicts: 3,033,847 ( 2,460,365 cond + 573,482 ind) ==18814== Mispred rate: 9.4% ( 8.0% + 35.8% )
对比结果:
3.1.4 | 3.2.0 | Detal | |
---|---|---|---|
IR | 232,666,798 | 171,236,262 | -26% |
I1 Misses | 3,669,999 | 2,940,070 | -20% |
DR | 102,960,876 | 75,584,870 | -27% |
D1 Misses | 5,065,700 | 4,302,787 | -15% |
Branch | 44,906,888 | 32,043,848 | -29% |
MisPred | 4,112,611 | 3,033,847 | -26% |
我们可以看到,无论执行的指令数,访问的内存数,以及cache miss, branch mispred都有很明显的下降。
当然,我们也能看到D1 Misses想对于DR的下降不成比例,这部分的主要原因还在于用户脚本访问Yaf类对象的时候导致的新增差异,后续还要想想怎么提升这块。
总体来说,这次的重构获得了20%以上的性能提升,但这个只是针对框架本身,对实际使用Yaf的业务来说,那肯定没这么明显了,具体多少大家可以自行测试。
好了,就简单介绍这么多,具体详细变化可以参看Changelog, 欢迎下载测试Yaf-3.2 后续我来慢慢完善文档。
前面也说了,这次对版本代码量变更很大,几乎相当于重写了:
新增代码量就将近9000,鉴于此,3.2.0目前发布为beta,虽然我做了很多的测试,也做到了能想到的最大可能去保证行为不发生变化,但还是不能保证完全对以前的版本兼容,大家如果在使用的过程中有任何问题,欢迎即时在Github反馈。
good
Thank you! This is what I need to find.
I really appreciate this wonderful post that you have provided for us. I assure you this would be beneficial for most people.
鸟哥你好, 我觉得这句话好像少了标点符号.”这次的重构的最初出发点是把原来的Yaf对象从PHP的原生对象,改成了自定义的对象:”->这次的重构的最初出发点是把原来的Yaf对象,从PHP的原生对象改成了自定义的对象:
lstat(“/m/www/glocash-code/new-admin/yafapp/application/modules/Admin/controllers/Index.php”, {st_mode=S_IFREG|0755, st_size=9108, …}) = 0
lstat(“/m/www/glocash-code/new-admin/yafapp/application/modules/Admin/controllers”, {st_mode=S_IFDIR|0777, st_size=24576, …}) = 0
lstat(“/m/www/glocash-code/new-admin/yafapp/application/modules/Admin”, {st_mode=S_IFDIR|0777, st_size=0, …}) = 0
lstat(“/m/www/glocash-code/new-admin/yafapp/application/modules”, {st_mode=S_IFDIR|0777, st_size=0, …}) = 0
open(“/m/www/glocash-code/new-admin/yafapp/application/modules/Admin/controllers/Index.php”, O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0755, st_size=9108, …}) = 0
read(4, “<?php\n\n/////////////////////////"…, 9108) = 9108
stat("/m/www/glocash-code/new-admin/yafapp/application/controllers/Admin.php", {st_mode=S_IFREG|0755, st_size=10183, …}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591339836, tv_nsec=995624200}) = 0
lstat("/m/www/glocash-code/new-admin/yafapp/application/controllers/Admin.php", {st_mode=S_IFREG|0755, st_size=10183, …}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/controllers/Admin.php", O_RDONLY) = 5
fstat(5, {st_mode=S_IFREG|0755, st_size=10183, …}) = 0
read(5, "<?php // Admin default\n\n///////"…, 10183) = 10183
stat("/m/www/glocash-code/new-admin/yafapp/application/controllers/Abstract.php", {st_mode=S_IFREG|0755, st_size=13315, …}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591339837, tv_nsec=514400}) = 0
lstat("/m/www/glocash-code/new-admin/yafapp/application/controllers/Abstract.php", {st_mode=S_IFREG|0755, st_size=13315, …}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/controllers/Abstract.php", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0755, st_size=13315, …}) = 0
read(6, "<?php // Base\n/////////////////"…, 13315) = 13315
write(2, "NOTICE: PHP message: PHP Depreca"…, 197) = 197
close(6) = 0
close(5) = 0
close(4) = 0
access("/language/en.php", F_OK) = -1 ENOENT (No such file or directory)
clock_gettime(CLOCK_REALTIME, {tv_sec=1591339837, tv_nsec=8285200}) = 0
lstat("/language/en.php", 0x7ffe22c8a200) = -1 ENOENT (No such file or directory)
clock_gettime(CLOCK_REALTIME, {tv_sec=1591339837, tv_nsec=8942900}) = 0
lstat("/language/en.php", 0x7ffe22c8b310) = -1 ENOENT (No such file or directory)
lstat("/language", 0x7ffe22c8b1a0) = -1 ENOENT (No such file or directory)
open("/language/en.php", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/index.php", 0x7ffe22c8d9c0) = -1 ENOENT (No such file or directory)
— SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=NULL} —
+++ killed by SIGSEGV +++
这没法看啊,去github提issue吧,最好能有backtrace出来
从3.0.9升级到3.2.4发现个问题,不知道是不是bug,导致php-fpm进程被SIGSEGV信号杀掉。环境版本信息: yaf: 3.2.4 , php: 7.4.6
下面是trace 信息:
strace: Process 8469 attached
accept(8, {sa_family=AF_INET, sin_port=htons(56138), sin_addr=inet_addr(“172.17.0.1”)}, [112->16]) = 3
poll([{fd=3, events=POLLIN}], 1, 5000) = 1 ([{fd=3, revents=POLLIN}])
clock_gettime(CLOCK_MONOTONIC, {tv_sec=2080, tv_nsec=56714600}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591339836, tv_nsec=954819900}) = 0
times({tms_utime=0, tms_stime=0, tms_cutime=0, tms_cstime=0}) = 4295145301
read(3, “\1\1\0\1\0\10\0\0”, 8) = 8
read(3, “\0\1\0\0\0\0\0\0”, 8) = 8
read(3, “\1\4\0\1\6K\5\0”, 8) = 8
read(3, “\17+SCRIPT_FILENAME/m/www/glocash-“…, 1616) = 1616
read(3, “\1\4\0\1\0\0\0\0″, 8) = 8
clock_gettime(CLOCK_REALTIME, {tv_sec=1591339836, tv_nsec=956774600}) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=2080, tv_nsec=59270200}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591339836, tv_nsec=957447200}) = 0
rt_sigaction(SIGPROF, NULL, {sa_handler=0x55a8a39e7f00, sa_mask=~[ILL TRAP ABRT BUS FPE KILL SEGV CONT STOP TSTP TTIN TTOU SYS RTMIN RT_1 RT_2], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f9f238db27d}, 8) = 0
rt_sigaction(SIGHUP, NULL, {sa_handler=0x55a8a39e7f00, sa_mask=~[ILL TRAP ABRT BUS FPE KILL SEGV CONT STOP TSTP TTIN TTOU SYS RTMIN RT_1 RT_2], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f9f238db27d}, 8) = 0
rt_sigaction(SIGINT, NULL, {sa_handler=0x55a8a39e7f00, sa_mask=~[ILL TRAP ABRT BUS FPE KILL SEGV CONT STOP TSTP TTIN TTOU SYS RTMIN RT_1 RT_2], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f9f238db27d}, 8) = 0
rt_sigaction(SIGQUIT, NULL, {sa_handler=0x55a8a39e7f00, sa_mask=~[ILL TRAP ABRT BUS FPE KILL SEGV CONT STOP TSTP TTIN TTOU SYS RTMIN RT_1 RT_2], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f9f238db27d}, 8) = 0
rt_sigaction(SIGTERM, NULL, {sa_handler=0x55a8a39e7f00, sa_mask=~[ILL TRAP ABRT BUS FPE KILL SEGV CONT STOP TSTP TTIN TTOU SYS RTMIN RT_1 RT_2], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f9f238db27d}, 8) = 0
rt_sigaction(SIGUSR1, NULL, {sa_handler=0x55a8a39e7f00, sa_mask=~[ILL TRAP ABRT BUS FPE KILL SEGV CONT STOP TSTP TTIN TTOU SYS RTMIN RT_1 RT_2], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f9f238db27d}, 8) = 0
rt_sigaction(SIGUSR2, NULL, {sa_handler=0x55a8a39e7f00, sa_mask=~[ILL TRAP ABRT BUS FPE KILL SEGV CONT STOP TSTP TTIN TTOU SYS RTMIN RT_1 RT_2], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f9f238db27d}, 8) = 0
setitimer(ITIMER_PROF, {it_interval={tv_sec=0, tv_usec=0}, it_value={tv_sec=60, tv_usec=0}}, NULL) = 0
rt_sigaction(SIGPROF, {sa_handler=0x55a8a39e7f00, sa_mask=~[ILL TRAP ABRT BUS FPE KILL SEGV CONT STOP TSTP TTIN TTOU SYS RTMIN RT_1 RT_2], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f9f238db27d}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [PROF], NULL, 8) = 0
getpid() = 8469
uname({sysname=”Linux”, nodename=”8b4b072e135b”, …}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591339836, tv_nsec=962929500}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591339836, tv_nsec=963321900}) = 0
access(“/var/log/www/default”, F_OK) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591339836, tv_nsec=964032200}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591339836, tv_nsec=964310200}) = 0
open(“/m/www/glocash-code/new-admin/www/index.php”, O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0755, st_size=478, …}) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=2080, tv_nsec=71419900}) = 0
getcwd(“/”, 4095) = 2
chdir(“/m/www/glocash-code/new-admin/www”) = 0
setitimer(ITIMER_PROF, {it_interval={tv_sec=0, tv_usec=0}, it_value={tv_sec=30, tv_usec=0}}, NULL) = 0
read(4, “<?php\n//////////////////////////"…, 478) = 478
close(4) = 0
stat("/m/www/glocash-code/new-admin/yafapp/conf/default.ini", {st_mode=S_IFREG|0755, st_size=5121, …}) = 0
open("/m/www/glocash-code/new-admin/yafapp/conf/default.ini", O_RDONLY) = 4
ioctl(4, TIOCGWINSZ, 0x7ffe22c8eba8) = -1 ENOTTY (Not a tty)
fstat(4, {st_mode=S_IFREG|0755, st_size=5121, …}) = 0
readv(4, [{iov_base="[common]\napplication.directory ="…, iov_len=5120}, {iov_base="e", iov_len=1024}], 2) = 5121
close(4) = 0
stat("/m/www/glocash-code/new-admin/yafapp/application/Bootstrap.php", {st_mode=S_IFREG|0755, st_size=2777, …}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591339836, tv_nsec=981996100}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/Bootstrap.php", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0755, st_size=2777, …}) = 0
read(4, "<?php\n\n/////////////////////////"…, 2777) = 2777
close(4) = 0
stat("/m/www/glocash-code/new-admin/yafapp/application/modules/Admin/controllers/Index.php", {st_mode=S_IFREG|0755, st_size=9108, …}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591339836, tv_nsec=989485000}) = 0
lstat("/m/www/glocash-code/new-admin/yafapp/application/modules/Admin/controllers/Index.php", {st_mode=S_IFREG|0755, st_size=9108, …}) = 0
lstat("/m/www/glocash-code/new-admin/yafapp/application/modules/Admin/controllers", {st_mode=S_IFDIR|0777, st_size=24576, …}) = 0
lstat("/m/www/glocash-code/new-admin/yafapp/application/modules/Admin", {st_mode=S_IFDIR|0777, st_size=0, …}) = 0
lstat("/m/www/glocash-code/new-admin/yafapp/application/modules", {st_mode=S_IFDIR|0777, st_size=0, …}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/modules/Admin/controllers/Index.php", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0755, st_size=9108, …}) = 0
read(4, "<?php\n\n/////////////////////////"…, 9108) = 9108
stat("/m/www/glocash-code/new-admin/yafapp/application/controllers/Admin.php", {st_mode=S_IFREG|0755, st_size=10183, …}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591339836, tv_nsec=995624200}) = 0
lstat("/m/www/glocash-code/new-admin/yafapp/application/controllers/Admin.php", {st_mode=S_IFREG|0755, st_size=10183, …}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/controllers/Admin.php", O_RDONLY) = 5
fstat(5, {st_mode=S_IFREG|0755, st_size=10183, …}) = 0
read(5, "<?php // Admin default\n\n///////"…, 10183) = 10183
stat("/m/www/glocash-code/new-admin/yafapp/application/controllers/Abstract.php", {st_mode=S_IFREG|0755, st_size=13315, …}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591339837, tv_nsec=514400}) = 0
lstat("/m/www/glocash-code/new-admin/yafapp/application/controllers/Abstract.php", {st_mode=S_IFREG|0755, st_size=13315, …}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/controllers/Abstract.php", O_RDONLY) = 6
fstat(6, {st_mode=S_IFREG|0755, st_size=13315, …}) = 0
read(6, "16]) = 3
poll([{fd=3, events=POLLIN}], 1, 5000) = 1 ([{fd=3, revents=POLLIN}])
clock_gettime(CLOCK_MONOTONIC, {tv_sec=3048, tv_nsec=772911500}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=670943400}) = 0
times({tms_utime=4, tms_stime=2, tms_cutime=0, tms_cstime=0}) = 4295242173
read(3, “\1\1\0\1\0\10\0\0”, 8) = 8
read(3, “\0\1\0\0\0\0\0\0”, 8) = 8
read(3, “\1\4\0\1\6_\1\0”, 8) = 8
read(3, “\17+SCRIPT_FILENAME/m/www/glocash-“…, 1632) = 1632
read(3, “\1\4\0\1\0\0\0\0”, 8) = 8
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=673237300}) = 0
lstat(“/m/www/glocash-code/new-admin/www/index.php”, {st_mode=S_IFREG|0755, st_size=525, …}) = 0
lstat(“/m/www/glocash-code/new-admin/www”, {st_mode=S_IFDIR|0777, st_size=4096, …}) = 0
lstat(“/m/www/glocash-code/new-admin”, {st_mode=S_IFDIR|0777, st_size=4096, …}) = 0
lstat(“/m/www/glocash-code”, {st_mode=S_IFDIR|0777, st_size=8192, …}) = 0
lstat(“/m/www”, {st_mode=S_IFDIR|0777, st_size=8192, …}) = 0
lstat(“/m”, {st_mode=S_IFDIR|0755, st_size=4096, …}) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=3048, tv_nsec=782944600}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=681083000}) = 0
rt_sigaction(SIGPROF, NULL, {sa_handler=0x565415649f00, sa_mask=~[ILL TRAP ABRT BUS FPE KILL SEGV CONT STOP TSTP TTIN TTOU SYS RTMIN RT_1 RT_2], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f874e98827d}, 8) = 0
rt_sigaction(SIGHUP, NULL, {sa_handler=0x565415649f00, sa_mask=~[ILL TRAP ABRT BUS FPE KILL SEGV CONT STOP TSTP TTIN TTOU SYS RTMIN RT_1 RT_2], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f874e98827d}, 8) = 0
rt_sigaction(SIGINT, NULL, {sa_handler=0x565415649f00, sa_mask=~[ILL TRAP ABRT BUS FPE KILL SEGV CONT STOP TSTP TTIN TTOU SYS RTMIN RT_1 RT_2], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f874e98827d}, 8) = 0
rt_sigaction(SIGQUIT, NULL, {sa_handler=0x565415649f00, sa_mask=~[ILL TRAP ABRT BUS FPE KILL SEGV CONT STOP TSTP TTIN TTOU SYS RTMIN RT_1 RT_2], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f874e98827d}, 8) = 0
rt_sigaction(SIGTERM, NULL, {sa_handler=0x565415649f00, sa_mask=~[ILL TRAP ABRT BUS FPE KILL SEGV CONT STOP TSTP TTIN TTOU SYS RTMIN RT_1 RT_2], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f874e98827d}, 8) = 0
rt_sigaction(SIGUSR1, NULL, {sa_handler=0x565415649f00, sa_mask=~[ILL TRAP ABRT BUS FPE KILL SEGV CONT STOP TSTP TTIN TTOU SYS RTMIN RT_1 RT_2], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f874e98827d}, 8) = 0
rt_sigaction(SIGUSR2, NULL, {sa_handler=0x565415649f00, sa_mask=~[ILL TRAP ABRT BUS FPE KILL SEGV CONT STOP TSTP TTIN TTOU SYS RTMIN RT_1 RT_2], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f874e98827d}, 8) = 0
setitimer(ITIMER_PROF, {it_interval={tv_sec=0, tv_usec=0}, it_value={tv_sec=60, tv_usec=0}}, NULL) = 0
rt_sigaction(SIGPROF, {sa_handler=0x565415649f00, sa_mask=~[ILL TRAP ABRT BUS FPE KILL SEGV CONT STOP TSTP TTIN TTOU SYS RTMIN RT_1 RT_2], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f874e98827d}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [PROF], NULL, 8) = 0
getpid() = 18585
uname({sysname=”Linux”, nodename=”8b4b072e135b”, …}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=686216700}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=686805400}) = 0
access(“/var/log/www/default”, F_OK) = -1 ENOENT (No such file or directory)
stat(“/var/log/www”, 0x7ffe9e7504e0) = -1 ENOENT (No such file or directory)
stat(“/var/log”, {st_mode=S_IFDIR|0755, st_size=4096, …}) = 0
mkdir(“/var/log/www”, 0777) = -1 EACCES (Permission denied)
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=689050200}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=689353400}) = 0
open(“/m/www/glocash-code/new-admin/www/index.php”, O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0755, st_size=525, …}) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=3048, tv_nsec=793485100}) = 0
getcwd(“/”, 4095) = 2
chdir(“/m/www/glocash-code/new-admin/www”) = 0
setitimer(ITIMER_PROF, {it_interval={tv_sec=0, tv_usec=0}, it_value={tv_sec=30, tv_usec=0}}, NULL) = 0
read(4, “<?php\n//////////////////////////"…, 525) = 525
close(4) = 0
stat("/m/www/glocash-code/new-admin/yafapp/conf/default.ini", {st_mode=S_IFREG|0755, st_size=5121, …}) = 0
open("/m/www/glocash-code/new-admin/yafapp/conf/default.ini", O_RDONLY) = 4
ioctl(4, TIOCGWINSZ, 0x7ffe9e74efe8) = -1 ENOTTY (Not a tty)
fstat(4, {st_mode=S_IFREG|0755, st_size=5121, …}) = 0
readv(4, [{iov_base="[common]\napplication.directory ="…, iov_len=5120}, {iov_base="e", iov_len=1024}], 2) = 5121
close(4) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=702651400}) = 0
lstat("/m/www/glocash-code/new-admin/yafapp/application/Bootstrap.php", {st_mode=S_IFREG|0755, st_size=2772, …}) = 0
lstat("/m/www/glocash-code/new-admin/yafapp/application", {st_mode=S_IFDIR|0777, st_size=4096, …}) = 0
lstat("/m/www/glocash-code/new-admin/yafapp", {st_mode=S_IFDIR|0777, st_size=4096, …}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=705404800}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/Bootstrap.php", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0755, st_size=2772, …}) = 0
read(4, "<?php\n\n/////////////////////////"…, 2772) = 2772
close(4) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=709011100}) = 0
lstat("/m/www/glocash-code/new-admin/yafapp/application/modules/Admin/controllers/Index.php", {st_mode=S_IFREG|0755, st_size=9108, …}) = 0
lstat("/m/www/glocash-code/new-admin/yafapp/application/modules/Admin/controllers", {st_mode=S_IFDIR|0777, st_size=24576, …}) = 0
lstat("/m/www/glocash-code/new-admin/yafapp/application/modules/Admin", {st_mode=S_IFDIR|0777, st_size=0, …}) = 0
lstat("/m/www/glocash-code/new-admin/yafapp/application/modules", {st_mode=S_IFDIR|0777, st_size=0, …}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=713380300}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/modules/Admin/controllers/Index.php", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0755, st_size=9108, …}) = 0
read(4, "<?php\n\n/////////////////////////"…, 9108) = 9108
close(4) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=717391200}) = 0
lstat("/m/www/glocash-code/new-admin/yafapp/application/controllers/Admin.php", {st_mode=S_IFREG|0755, st_size=10183, …}) = 0
lstat("/m/www/glocash-code/new-admin/yafapp/application/controllers", {st_mode=S_IFDIR|0777, st_size=4096, …}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=720034900}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/controllers/Admin.php", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0755, st_size=10183, …}) = 0
read(4, "<?php // Admin default\n\n///////"…, 10183) = 10183
close(4) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=722973900}) = 0
lstat("/m/www/glocash-code/new-admin/yafapp/application/controllers/Abstract.php", {st_mode=S_IFREG|0755, st_size=13315, …}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=724598500}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/controllers/Abstract.php", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0755, st_size=13315, …}) = 0
read(4, "<?php // Base\n/////////////////"…, 13315) = 13315
close(4) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=728158600}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=728645300}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/library/Misc/Http.php", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0755, st_size=6462, …}) = 0
read(4, "<?php\n\n/////////////////////////"…, 6462) = 6462
close(4) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=734791300}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=735341400}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/library/Log/Admin.php", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0755, st_size=472, …}) = 0
read(4, "<?php\n\n/////////////////////////"…, 472) = 472
close(4) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=739804400}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=740229900}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/models/Admin/Auth.php", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0755, st_size=8736, …}) = 0
read(4, "<?php\n\n/////////////////////////"…, 8736) = 8736
close(4) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=746723400}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=746999600}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/models/Admin/Main.php", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0755, st_size=15162, …}) = 0
read(4, "<?php\n\n/////////////////////////"…, 15162) = 15162
write(2, "NOTICE: PHP message: PHP Depreca"…, 194) = 194
write(2, "NOTICE: PHP message: PHP Depreca"…, 194) = 194
close(4) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=752232100}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=752474300}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/models/Abstract.php", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0755, st_size=4997, …}) = 0
read(4, "<?php\n\n/////////////////////////"…, 4997) = 4997
close(4) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=756124100}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=756402600}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/library/Redis/Base.php", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0755, st_size=5057, …}) = 0
read(4, "<?php\n\n/////////////////////////"…, 5057) = 5057
close(4) = 0
access("/m/www/glocash-code/new-admin/yafapp/application/modules/Admin/views/language/zh.php", F_OK) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=765288600}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/modules/Admin/views/language/zh.php", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0755, st_size=93023, …}) = 0
read(4, "<?php\n\n$lang = [\n '_code' "…, 93023) = 93023
close(4) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=769983400}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=770250700}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/models/Admin/Manager.php", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0755, st_size=4057, …}) = 0
read(4, "<?php\n\n/////////////////////////"…, 4057) = 4057
close(4) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=774634000}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=774994000}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=775291300}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/modules/Admin/views/index.php", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0755, st_size=139, …}) = 0
read(4, "<?php\n\ninclude('header.php');\nif"…, 139) = 139
getcwd("/m/www/glocash-code/new-admin/www", 4096) = 34
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=778632500}) = 0
lstat("/m/www/glocash-code/new-admin/www/./header.php", 0x7ffe9e7492f0) = -1 ENOENT (No such file or directory)
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=779696800}) = 0
lstat("/m/web/php7/lib/php/header.php", 0x7ffe9e7492f0) = -1 ENOENT (No such file or directory)
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=780302200}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/modules/Admin/views/header.php", O_RDONLY) = 5
fstat(5, {st_mode=S_IFREG|0755, st_size=2753, …}) = 0
read(5, "\n<html lang=\"<?ph"…, 2753) = 2753
close(5) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=784861700}) = 0
getpid() = 18585
getcwd("/m/www/glocash-code/new-admin/www", 4096) = 34
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=785703600}) = 0
lstat("/m/www/glocash-code/new-admin/www/./body.php", 0x7ffe9e7492f0) = -1 ENOENT (No such file or directory)
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=786525900}) = 0
lstat("/m/web/php7/lib/php/body.php", 0x7ffe9e7492f0) = -1 ENOENT (No such file or directory)
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=786993000}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/modules/Admin/views/body.php", O_RDONLY) = 5
fstat(5, {st_mode=S_IFREG|0755, st_size=6151, …}) = 0
read(5, "<?php $preAction = substr($actio"…, 6151) = 6151
close(5) = 0
getcwd("/m/www/glocash-code/new-admin/www", 4096) = 34
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=791445600}) = 0
lstat("/m/www/glocash-code/new-admin/www/./fdlblacklist.php", 0x7ffe9e7492f0) = -1 ENOENT (No such file or directory)
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=792545300}) = 0
lstat("/m/web/php7/lib/php/fdlblacklist.php", 0x7ffe9e7492f0) = -1 ENOENT (No such file or directory)
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=793023700}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/modules/Admin/views/fdlblacklist.php", O_RDONLY) = 5
fstat(5, {st_mode=S_IFREG|0755, st_size=12412, …}) = 0
read(5, "<table class=\"filter pw100\" cell"…, 12412) = 12412
close(5) = 0
write(3, "\1\7\0\1\1r\6\0PHP message: PHP Depreca"…, 8192) = 8192
getcwd("/m/www/glocash-code/new-admin/www", 4096) = 34
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=797580000}) = 0
lstat("/m/www/glocash-code/new-admin/www/./menu.php", 0x7ffe9e7492f0) = -1 ENOENT (No such file or directory)
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=798722400}) = 0
lstat("/m/web/php7/lib/php/menu.php", 0x7ffe9e7492f0) = -1 ENOENT (No such file or directory)
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=799248700}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/modules/Admin/views/menu.php", O_RDONLY) = 5
fstat(5, {st_mode=S_IFREG|0755, st_size=25352, …}) = 0
read(5, "\n <div class=\"n"…, 8192) = 8192
write(3, "\1\6\0\1\37\370\0\0\n <l"…, 8192) = 8192
getcwd("/m/www/glocash-code/new-admin/www", 4096) = 34
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=806826400}) = 0
lstat("/m/www/glocash-code/new-admin/www/./footer.php", 0x7ffe9e7492f0) = -1 ENOENT (No such file or directory)
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=808262400}) = 0
lstat("/m/web/php7/lib/php/footer.php", 0x7ffe9e7492f0) = -1 ENOENT (No such file or directory)
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=808774000}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/modules/Admin/views/footer.php", O_RDONLY) = 5
fstat(5, {st_mode=S_IFREG|0755, st_size=219, …}) = 0
read(5, "\n\n <di"…, 219) = 219
close(5) = 0
close(4) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=812589800}) = 0
lstat("/m/www/glocash-code/new-admin/yafapp/application/modules/Admin/views/index/fdlblacklist.php", 0x7ffe9e74b970) = -1 ENOENT (No such file or directory)
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=813587600}) = 0
lstat("/m/www/glocash-code/new-admin/yafapp/application/modules/Admin/controllers/Error.php", 0x7ffe9e74bcf0) = -1 ENOENT (No such file or directory)
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=814617300}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=814907200}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/controllers/Error.php", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0755, st_size=590, …}) = 0
read(4, "<?php // Error\n\n///////////////"…, 590) = 590
close(4) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=819044000}) = 0
clock_gettime(CLOCK_REALTIME, {tv_sec=1591340805, tv_nsec=819358600}) = 0
open("/m/www/glocash-code/new-admin/yafapp/application/library/Seaslog/Main.php", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0755, st_size=1862, …}) = 0
read(4, "\n “…, 1880) = 1880
shutdown(3, SHUT_WR) = 0
recvfrom(3, “\1\5\0\1\0\0\0\0”, 8, 0, NULL, NULL) = 8
recvfrom(3, “”, 8, 0, NULL, NULL) = 0
close(3) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=3048, tv_nsec=943223800}) = 0
munmap(0x7f874d400000, 2097152) = 0
write(2, “\0fscf\0”, 6) = 6
clock_gettime(CLOCK_MONOTONIC, {tv_sec=3048, tv_nsec=944739300}) = 0
pecl有时候安装扩展真的好慢,甚至打不开,有没有那种国内的源,鸟哥
PSR-4 Autoloading失败了,找不到类,有成功的同学吗?
不好意思,目录写错了,新项目用上了,谢谢鸟哥!
正好新项目,3.22我先品一下
问下大神,开发扩展,怎么避免内存泄露呢,用Valgrind好像逻辑走不到的地方检测不到泄露
没啥好办法,一般来说,处理好引用计数就好了,用的时候+1,用完了-1,经验多了就好了
PHP的扩展里面用emalloc,其实就算不释放,在请求结束后PHP也会释放掉所有申请的非持久型内存吧。
理论上是,但是内存如果不及时释放,会导致峰值内存变大,间接还是会影响性能
嗯,这个到是的,如果确实短时间内找不到问题所在,可以设置一下max_request,再配合php自动内存释放,可以临时应急用用。当然最好还是能开着debug mode做测试,把大部分路径都覆盖到,这样基本上问题不大了。
鸟哥,您好,我去年在您的 yaf 框架上面提交了 orm 的部分,不知道您咋看待,期待回复,俺微信 ****
好,我加你, 我把你微信号马赛克了哈
在用你的ycdb
诶!咱PHP的namespace Acme\Foo\Bar 不是反斜杠嘛?
哈哈,眼尖,改了
最近动作很快啊~~~ ^_^