分享五个PHP7性能优化提升技巧_PHP

WBOY
Release: 2016-05-28 13:13:00
Original
965 people have browsed it

PHP7已经发布了, 作为PHP10年来最大的版本升级, 最大的性能升级, PHP7在多放的测试中都表现出很明显的性能提升, 然而, 为了让它能发挥出最大的性能, 我还是有几件事想提醒下.

代码如下:


 opcache.huge_code_pages=1


这样一来, PHP会把自身的text段, 以及内存分配中的huge都采用大内存页来保存, 减少TLB miss, 从而提高性能.

代码如下:


opcache.file_cache=/tmp


这样PHP就会在/tmp目录下Cache一些Opcode的二进制导出文件, 可以跨PHP生命周期存在.

代码如下:


$ make prof-gen

然后用你的项目训练PHP, 比如对于Wordpress:

代码如下:


$ sapi/cgi/php-cgi -T 100 /home/huixinchen/local/www/htdocs/wordpress/index.php >/dev/null


也就是让php-cgi跑100遍wordpress的首页, 从而生成一些在这个过程中的profile信息.

最后:

$ make prof-clean
$ make prof-use && make install
Copy after login

这个时候你编译得到的PHP7就是为你的项目量身打造的最高性能的编译版本.

暂时就这么多吧, 以后想起来再加, 欢迎大家尝试, thanks

以上小编给大家分享五个PHP7性能优化提升技巧,希望大家喜欢。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!