Home > headlines > body text

In-depth testing of the latest PHP version and features: PHP 7.3 is more than 3 times faster than PHP 5

无忌哥哥
Release: 2018-07-12 10:36:02
Original
14160 people have browsed it

How is the performance of PHP 7.3? The following is an in-depth test of the latest version and features of PHP: PHP 7.3 is more than 3 times faster than PHP 5!

As the last version of PHP5 and currently the most widely used PHP version, PHP 5.6 started in 2014 AD (not 1804, hehe), and its first beta version, PHP 5.6 alpha 1, was released in 2014 Released in January. The first large-scale performance-improved version PHPNG (PHP next generation, next generation PHP) was randomly generated by Chinese people (Niao Ge, Hui Xinchen) and participated in the main research and development. In 2015, the PHP 7 version was produced based on PHPNG. PHP7 brings revolutionary performance improvements, running at twice the speed of 5.6 and other improvements, such as 64-bit support, type declarations, runtime optimization, etc. Since 2015, officials have been recommending that everyone upgrade to php7 as soon as possible, although expansion support was still very problematic at that time.

According to the latest W3techs statistics, PHP 7 currently accounts for more than 16.6% of PHP's share. Overall PHP still holds the majority share of server-side web development languages ​​at around 83%.

In-depth testing of the latest PHP version and features: PHP 7.3 is more than 3 times faster than PHP 5



##According to the PHP development support cycle, PHP 5.6 will no longer be available after December 31 this year Official support. So now there is only half a year left for you to upgrade your PHP to PHP7. After that, the fate of PHP5 will come to an end, and as a matter of fact, most of the frameworks and programs currently fully support PHP7.

In-depth testing of the latest PHP version and features: PHP 7.3 is more than 3 times faster than PHP 5

In-depth testing of the latest PHP version and features: PHP 7.3 is more than 3 times faster than PHP 5





#Performance test: PHP 7.3 is 25% faster than PHP 7.0

There are many performance test comparisons that reveal that PHP 7 is at least 2 times faster than PHP 5.6. The following is a performance comparison chart of major PHP frameworks:

In-depth testing of the latest PHP version and features: PHP 7.3 is more than 3 times faster than PHP 5


##The latest Phoronix benchmark results are below It shows the performance comparison of PHP 7 since PHP7 was released. The performance improvement of the latest version of PHP 7.3 Alpha is quite objective compared to the initial version of PHP 7. According to the latest data PHP 7.3 is 3 times faster than PHP 5.6! 25% faster than PHP 7.0. Not to mention anything else, this performance comparison chart can bring a little bit of coolness to the scorching summer. And this can also be directly reflected in the cost. For example, after upgrading to PHP7, Badoo can save about 1 million US dollars per year.

In-depth testing of the latest PHP version and features: PHP 7.3 is more than 3 times faster than PHP 5


##Badoo company data:


u=3038392179,3900257165&fm=173&app=25&f=JPEG (1).jpg



PHP 7 compatibility line check


As of now, basically the vast majority of PHP All can perfectly support PHP7.0. But maybe you happen to have some scripts and programs left over from history, so it’s easy to handle. The community already has many tools for compatibility checking and even direct code translation. Here are a few recommended tools:

php7cc: A very good tool, but it is no longer updated. (github address: /sstalle/php7cc)

In-depth testing of the latest PHP version and features: PHP 7.3 is more than 3 times faster than PHP 5


##php7mar: PHP 7 migration assistant, bug Highly recommended tool. (github address: /Alexia/php7mar)


In-depth testing of the latest PHP version and features: PHP 7.3 is more than 3 times faster than PHP 5

##Usage:

php mar.php -f="/path/to/project/root/" -r="/path/to/output/"


phan: Static analyzer for PHP scripts. Can be used as a syntax checker for PHP 7. (github address: /phan/phan)

In-depth testing of the latest PHP version and features: PHP 7.3 is more than 3 times faster than PHP 5

##Usage method: phan --project- root-directory --progress-bar -o phan.out


phpstan - PHP static analysis and compatibility checking tool. (github address: /phpstan/phpstan)


PHP 7 performance setting points

1. Opcache

First, make sure it is enabled OpCache. This can be done through the main configuration file php.ini or its unique configuration file opcache.ini file (for example /etc/php/7.2/fpm/conf.d/10-opcache.ini). to set it up.

zend_extension=opcache.so

opcache.enable=1

opcache.enable_cli=1

You can use phpinfo() to check, or you can use the terminal command

php -v or php -i | grep opcache.enable

After confirming that PHP OpCache has been enabled, many ln(a)mp packages have an opCache monitoring script that can monitor their performance in real time, as shown below

In-depth testing of the latest PHP version and features: PHP 7.3 is more than 3 times faster than PHP 5



2. Set an appropriate realpath_cache_size

You can improve the performance of your server by setting an appropriate realpath_cache_size value Concurrency:

realpath_cache_size = 256k

realpath_cache_ttl = 300

In-depth testing of the latest PHP version and features: PHP 7.3 is more than 3 times faster than PHP 5



##3. Disable mysqlnd.collect_statistics

mysqlnd.collect_statistics = Off

mysqlnd.collect_memory_statistics = Off

The online server chooses to disable these two options to reduce the number of errors. Necessary database access. If you need relevant statistics, you can use MySQL tools or monitoring.

4. Use the new compiler

PHP can only enable Global Register for opline and execute_data support when compiling under the GCC 4.8 compiler. This will bring about a 5% performance improvement.

5. Turn on Transparent HugePage (Transparent HugePage)

The memory is paged by 4KB by default, and the virtual address and memory address need to be converted, and a search needs to be performed during conversion in order to speed up the conversion process. , which can be obtained through the memory TLB (Translation Lookaside Buffer). So by enabling large memory pages you can increase TLB cache hits, thereby improving performance.

Set system support:

sysctl vm.nr_hugepages=512

php.ini Add support

opcache.huge_code_pages=1

Regarding this value, many practices have found that enabling transparent transmission of large pages will cause excessive system load and high CPU usage. This can be solved by turning it off. Therefore, this parameter needs to be considered and tested according to the actual situation.

6. Turn on PGO

PHP is specifically designed to serve a project, such as a Wordpress or Drupal site, so you can use PGO to improve performance.

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!