"Interview with PHP's father" PHP7 performance doubling key disclosure

Source: Internet
Author: User
Tags hhvm drupal

  

20-year-old long-established web programming language PHP, the fastest release of the new version of PHP 7 at the end of October, this is the first major revision in ten years, the biggest feature is the breakthrough in performance, can be faster than the previous version of PHP 5, Rasmus Lerdorf, the father of PHP, said, It can even be faster than the PHP program under the HHVM virtual machine.

HHVM is the PHP optimization mechanism that Facebook has tailored to the features of its own website and does not necessarily apply to any website. But Rasmus Lerdorf says one of the new goals is to make it possible for any web developer to use HHVM technology without losing the ability to use the development framework Drupal, the open source e-commerce system OpenCart. On the eve of the new release, he also took the opportunity to join the PHPCONF Taiwan Annual meeting to share the key to PHP 7 's performance breakthrough.

A 20 years after many revisions and countless optimization of the mature language, but also performance to improve the breakthrough is not easy, Rasmus Lerdorf Frankly, unlike the general new projects are easy to find many improvements in space, the new version of PHP is not modified part of the program to achieve such results. Instead, PHP 7 has the ability to perform without losing HHVM, through a lot of detail optimizations and performance cumulation.

Rasmus Lerdorf and the PHP core contribution team spent a lot of effort to reduce the number of memory bits moved during the program's operation, thereby accelerating performance. For example, the data schema for stored variables in PHP zval from 24 bits to 16 bits, hashtable from 72 bits to 56 bits, and examines functions in PHP to think about any room for improved performance.

In addition to reducing the use of memory, Rasmus Lerdorf to see how the CPU's cache line works, how the program code interacts with the CPU, how the compiler compiles the program code under the new CPU architecture, and ensures that PHP 7 's program code conforms to the modern CPU architecture. While the optimization of each project is less than 0.5% performance contribution, the overall corrected results can be made so much progress due to the number of optimized projects or an improved function being called repeatedly by the application.

Motivated by HHVM, we decided to build PHP with performance and functionality. In order to optimize PHP operation, Facebook has built a virtual machine HHVM with JIT compilation. While HHVM has fast execution performance, it is designed to be optimized for specific purposes and can only meet a small number of developers. Conversely, Rasmus Lerdorf in addition to improving the performance of PHP, but also to meet the needs of high-end users and amateur users, PHP 70% for both performance and common functions of the program language.

However, it is not difficult to develop a programming language that meets the needs of a small segment of the market, but the PHP project is aimed at many objects and must be in accordance with the requirements of both the amateur user and the professional developer, because there will always be some ethnic needs that cannot be met, "it's like a large-scale spraying of water pipes, And everyone's clothes will be wet a little, but no one's clothes are completely soaked. "rasmus Lerdorf metaphor.

PHP does not use the external framework of the operation performance is very good, but by the impact of the framework, the original can be processed in a few seconds of thousands of web page requirements of PHP, the performance has been greatly reduced, changed to only dozens of requirements. Rasmus Lerdorf said that before HHVM, compared to the performance requirements of PHP, users are more concerned about whether PHP can reduce the difficulty of web development, and these frameworks can make the work of developers easier. But after the launch of HHVM on Facebook, many users who value PHP performance have been introduced, making Rasmus Lerdorf aware that many users have performance needs. He began to think about how to integrate HHVM's JIT architecture with PHP.

But Rasmus Lerdorf said that PHP and HHVM are quite different in architecture design, for example, HHVM's multithreaded architecture is not very solid. In addition, HHVM portability is not good enough to work on the Windows platform, there are a lot of developers in the Windows environment development, and HHVM can not take care of those users.

Rasmus Lerdorf said he could not abandon the main structure of PHP, although they have considered the integration of both, but there are many restrictions on the use of HHVM. While HHVM is a great tool for Facebook and many developers, the scope of HHVM for PHP projects is not broad enough to meet the needs of specific projects like Facebook or Wikipedia.

Non-strong type language of PHP, import JIT is more difficult. However, it is very difficult to add JIT compilation to PHP. Rasmus Lerdorf says that the JIT must learn to recognize the operational model of the Program (Patterns), such as knowing which parts are important program codes, and predicting when the program is called, or which parts of the program will be called before the program works.

Rasmus Lerdorf analogy, in many cars, the JIT must be able to predict which part of the car will turn right, which part of the car will turn left or some color car will go straight, "and the JIT must all predict the correct, otherwise performance will be greatly reduced." "However, if the predictions are correct, the performance of the program execution will be greatly improved.

It is not easy to add JIT to the compilation of the general programming language, Rasmus Lerdorf says, because the dynamic property of PHP makes it difficult to join the JIT. For example, the developer declares that the parameter $ A value is 1, but does not mean that all of the program's value is 1, because the parameter values in PHP can be easily redefined. In the C language, when the developer declares that parameter A is an integer, A is always an integer. If there is any place in the program that declares a is a type other than an integer, even compilation cannot be performed. And because of the C language of this strong programming language, "jit can predict that variable A is an integer, but in PHP we don't have that luxury. He explains that HHVM's approach is to assume that a is always an integer when the JIT learns that a is an integer type.

and HHVM in order to use JIT compile, to some extent, limited the development of PHP. HHVM users must clearly declare the nature of the variable, but developers using PHP can first declare a class that is not of the nature, and then specify the variable properties of the category later. "Without any restrictions, adding JIT to PHP is something we do." He said PHP must take into account the developers of WordPress, Drupal and other frameworks, can not arbitrarily stop support for these frameworks. As a HHVM, PHP is more restrictive in terms of JIT creation than the other.

But, "it doesn't mean we can't be JIT." In addition, we have to control the development of PHP. "rasmus Lerdorf said.

Currently, Dmitry Stogov, one of PHP's core contributors, develops a prototype JIT and uses some experimental applications to test the operation. Rasmus Lerdorf says that if you use this JIT to perform some repetitive operations or loop programs, you can make PHP 7 performance 10 times times faster.

But he admits that when the experimental JIT was used for WordPress, it didn't get any acceleration, "the JIT we want to build is not what we want to learn in college textbooks, but the JIT that works in the real world." "he said. Because PHP has always held such ideals, trying to solve problems in people's lives, and being able to operate in a real-world online environment, not just in textbook theory.

Rasmus Lerdorf says he spent at least 16 hours a day developing PHP when PHP was first invented. But he has now gradually reduced his efforts to develop and put his focus on promoting and speaking around the world. He jokingly said: "Rather than develop their own, I would like to inspire far smarter than me, but also willing to spend 18 hours a day to write the program of people to develop PHP." He says his ultimate goal is that there is no line of code in PHP that he writes, "any growing project should not be dominated by a developer, and old program code should be replaced by new program code." And he thinks that other developers should target it.

Invitation http://www.biyinjishi.com/products/a10-b1030/
Card http://www.biyinjishi.com/products/a10-b1035/
label http://www.biyinjishi.com/products/a10-b1035/
promotional material http://www.biyinjishi.com/products/a20/
single page http://www.biyinjishi.com/products/a20-b2010/
Folding http://www.biyinjishi.com/products/a20-b2010/
Leaflet Page http://www.biyinjishi.com/products/a20-b2010/d100015/
Propaganda Hinge http://www.biyinjishi.com/products/a20-b2010/d100016/
Poster http://www.biyinjishi.com/products/a20-b2030/d100020/
Display Board http://www.biyinjishi.com/products/a20-b2030/d100021/
Exhibition stand http://www.biyinjishi.com/products/a20-b2035/d100021
X-Show Stand http://www.biyinjishi.com/products/a20-b2035/d100023/
Easy Paula http://www.biyinjishi.com/products/a20-b2035/d100024/
Tote Bag http://www.biyinjishi.com/products/a20-b2050/d100024
Paper tote Bag http://www.biyinjishi.com/products/a20-b2050/d100026/
Fabric Tote Bag http://www.biyinjishi.com/products/a20-b2050/d100027/
Plastic bag http://www.biyinjishi.com/products/a20-b2050/d100028/
Promotional Gift http://www.biyinjishi.com/products/a20-b2055/d100028

"Interview with PHP's father" PHP7 performance doubling key disclosure

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.