Home >Backend Development >PHP7 >Do you know what causes php7 to be faster than 5?

Do you know what causes php7 to be faster than 5?

藏色散人
藏色散人forward
2020-07-14 13:18:593056browse

Do you know what causes php7 to be faster than 5?

Reasons for performance improvement?

1. The structure that stores variables becomes smaller, and try to make the members of the structure share memory. space and reduce references, so that the memory usage is reduced and the operation speed of variables is improved.

2. Changes to the string structure. The string information and data itself were originally stored in two independent memory blocks. PHP7 tries to store them in the same memory block, which improves the CPU cache hit rate.

3. Changes in the array structure. Array elements and hash mapping tables will be stored in multiple memory blocks in php5. php7 tries to allocate them in the same block of memory, reducing memory usage and improving cpu cache. Hit rate.

4. The function calling mechanism has been improved. By optimizing the parameter transfer link, some instruction operations have been reduced and execution efficiency has been improved.

Why can the performance of PHP7 be improved so much?

1. JIT
2. Changes to Zval
3. Internal type zend_string
4. Changes to PHP arrays (HashTable and Zend Array)
5. Function calls Mechanism (Function Calling Convention)
6. Through macro definition and inline function (inline), let the compiler complete part of the work in advance

Why is the actual business performance improvement of PHP7 only about 30%?

Actual business does not necessarily have very complex calculation logic

Actual business will use Redis and MYSQL, and network and IO bottlenecks affect the overall performance of PHP7

HTTPS performance issues limit the capabilities of PHP7

Recommended: "PHP7"

The above is the detailed content of Do you know what causes php7 to be faster than 5?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete