首页 存档 技术 查看内容

PHP7正式发布

2018-3-30 13:00 |来自: 互联网 310 0

摘要: 今天临晨的时候, 在我们已经到了12月4日, 但是美国时间还是10月3日的时候, PHP7终于正式发布了. 官方的Release Note可以参看php.net: " The PHP development team announces the immediate availability of PHP 7. ...

今天临晨的时候, 在我们已经到了12月4日, 但是美国时间还是10月3日的时候, PHP7终于正式发布了.

官方的Release Note可以参看php.net:

"

The PHP development team announces the immediate availability of PHP 7.0.0. This release marks the start of the new major PHP 7 series.

PHP 7.0.0 comes with a new version of the Zend Engine, numerous improvements and new features such as

  • Improved performance: PHP 7 is up to twice as fast as PHP 5.6

  • Significantly reduced memory usage

  • Abstract Syntax Tree

  • Consistent 64-bit support

  • Improved Exception hierarchy

  • Many fatal errors converted to Exceptions

  • Secure random number generator

  • Removed old and unsupported SAPIs and extensions

  • The null coalescing operator (??)

  • Return and Scalar Type Declarations

  • Anonymous Classes

  • Zero cost asserts

"

下载地址(包括Windows): http://www.php.net/downloads.php

为了充分显示出PHP7的最佳性能, 这里有几点Tips给大家:

  1. 记得启用Zend Opcache, 因为PHP7即使不启用Opcache速度也比PHP-5.6启用了Opcache快, 所以之前测试时期就发生了有人一直没有启用Opcache的事情. 启用Opcache非常简单, 在php.ini配置文件中加入:

    "zend_extension=opcache.so

opcache.enable=1

opcache.enable_cli=1"

2. 使用新一点的编译器, 推荐GCC 4.8以上, 因为只有GCC 4.8以上PHP才会开启Global Register for opline and execute_data支持, 这个会带来5%左右的性能提升(Wordpres的QPS角度衡量)

3. 在服务端开启HugePages, 然后开启Opcache的huge_code_pages.

以我的CentOS 6.5为例, 通过:

"sudo sysctl vm.nr_hugepages=512" 分配512个预留的大页内存

然后在php.ini中:

"opcache.huge_code_pages=1"

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

4. 开启Opcache File Cache(实验性), 通过开启这个, 我们可以让Opcache把opcode缓存缓存到外部文件中, 对于一些脚本, 会有很明显的性能提升.

在php.ini中:

"opcache.file_cache=/tmp"

好了, 欢迎大家测试, 有问题欢迎反馈, 你可以提交bug到bugs.php.net, 或者你可以在微博上@我, 也可以在github上提交issue, 等等. Enjoy!

thanks

本文转载自:微信公众账号 - 风雪之隅,版权归原作者所有!

声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系 [邮箱地址] 删除

路过

雷人

握手

鲜花

鸡蛋

相关分类

返回顶部