I hope that the PHP Daniel will discuss
Reply content:
Facebook tells us that PHP wants to improve efficiency, it's better to change the grammar, and then make a HHVM about this problem, I actually want to come in and spit a slot
In general, the simplest way to improve efficiency is to pay attention to many of PHP's efficiency optimization techniques in development. such as algorithms, syntax, architecture, and so on. These can accumulate in many ways both in experience and on the Internet.
If you find that the bottleneck of efficiency is not something that doesn't matter. Some functions are slow in some functions and functions, that OK, where there are problems to solve where, with the C extension of the way to solve. However, there are a number of joint issues, such as business logic that tends to change depending on the way C is extended.
Or you find that the explanatory language of PHP itself is slow, slow (laughter), how to break. This has the accelerator, with the way of cache opcode to avoid re-analysis of some of the relevant introduction and explanation of the main topic can simply look at this
Three free PHP accelerators: APC, Eaccelerator, xcache comparison
Or if we change our mind, would it be quicker to switch directly to binary language execution? The caption can look at the following solutions. C (Roadsend and PHC), C + + (hiphop), Java (Quercus), C # (Phalanger). But with Hipop for example, the goods
FACEBOOK/HHVM GitHub
。 The predecessor of Facebook's HHVM, he actually translates PHP into highly optimized C + + code and compiles it with g++, and there are others like code transformer. In this way, PHP is essentially transformed into another language. But this cargo deployment of the pit father, the use of difficulties, debugging trouble, compile time is simply anti-human.
I think the hhvm of the above-mentioned merits is born.
HHVM is actually hiphop's improved version, the current stable version is 2.3, performance is higher than hiphop40%. / http hhvm.com/
Language expression is not clear, here do not say well zend and HHVM principle, I think hhvm if to and Zend do contrast is HHVM if the JIT,HHVM can directly execute machine code. Zend Although the cache opcode but still have to call C to execute the machine code.
There are a lot of related documents online, the main topic can focus on
The master can also look at this solution HIPPYVM
is said to be specifically used to face Facebook's
The official claims that it is faster than native PHP 7.x than the Facebook HHVM faster 2x
Posted on an official website to see the figure
I haven't tested it specifically.
I can only say pypy.
I don't know if Facebook will feel beaten up. (מּ_מּ)
Small white One, if there is a wrong place to hope that the great God to correct you. By the way, PHP is the best language in the World (laughter) Phpng end this post phpng, HHVM, YAF, Baidu ODP, Swoole actually said PHP performance is poor, do not know how many years have not used PHP. Like YAF and Phalcon C development framework, how bad do you feel about performance? In addition to the interpretation of the language, it is completely unaware that there is opcache this kind of thing, now PHP, is run once automatically precompiled. 0. Have you encountered this level of bottleneck?
1. PHP 7, please look forward to ... Change it to static language! PHP is a generic programming language, but 99.9% of the time is still used in web development, so bottlenecks are generally not on the side of PHP, but appear in the network IO such as the DB layer.
I am currently doing optimization using tools such as Xhprof first
MeasurementTo find the most time-consuming part: Most of them are called in db, such as PDO connections, and can be reduced by optimizing the code.
In addition, the optimization of the DB layer is generally indexed, through the analysis of executed SQL statements (preferably with log) and explain, the appropriate addition of the combined index, by the way also good coverage index. Although adding an index can affect the efficiency of the insert, the write is consistent with the 28 rule, as opposed to reading.
Finally, as the system becomes more complex, you need to optimize the architecture to improve performance, such as caching between DB and app, time-consuming task asynchrony, and so on.
—————— There are too many things to write about, I just talk about it in general ————————
From the point of view of the PHP language, development will generally use the framework, and the framework will bring unavoidable consumption, so there will be phalcon and yaf such an excellent extension of PHP written by the MVC framework;
PHP HHVM is another way to improve the performance of PHP, more than Phalcon and YAF framework may bring better performance, but a bit of a different portal bright, so in the PHP community is quite mature, most people do not choose HHVM, the risk is great. Even phalcon such a C language framework, for the relatively small team, the risk of using it is relatively large, can not control the C language, the problem is very serious ~ ~ directly with the HHVM bar, Facebook in use, or to replace the framework of async.
However, in a typical PHP application scenario, performance does not depend on PHP itself. asynchronous, parallel, distributed extension of swoole:php
There's a picture of the truth