Despite the proliferation of NodeJS, PHP is still very widely used on the Internet, and recent changes in the lastest version (PHP 7) have improved performance, and indirectly sustainability.
However, they require that the engine be recompiled for the particular server where it is going to be used. This is Performance-Guided Optimization, or PGO. The description on how to re-create a PGO PHP binary from a C++ recompile may be found on the following site:
The original Intel article:
Quoted values are up to 14% performance increases for WordPress.
What Needs to Be Done
To benefit from PGO you need to change the procedure slightly.
- In the first time you need to replace the first make command by make prof-gen
- Run your target application that you want to optimize
- Repeat the make command using make prof-use
- Run make install
This results in an optimized version of PHP for the application. It implies that most of your use will be for a specific app like WordPress or other CMS systems.
Useful, but not in Use?
Trouble is, most hosts and Linux distributions don’t have this optimized version. Unless a web host recompiles PHP this way, they lose several percent in efficiency. The ability to do this optimization has been around for several years…but how many hosts have done this optimization? According to the Intel article, Mozilla uses PGO when compiling Firefox. But we don’t know about the thousands of hosts running WordPress for clients on their servers.
My guess is that many have not.
Now, if you have a virtual server, you may have the ability to re-compile PHP just for your account. But this kind of hosting account is more expensive than the ones usually used.
The application-specific nature – you have to optimize for a specific application – means that hosting companies would have to split their generic web servers into a group of application servers – in other words, a “cloud”. So, a PHP/Apache combo running WordPress, with PGO applied during the compile, could be efficient with WordPress but inefficient with another CMS.
Now, modern web services use things like NodeJS or Ruby on Rails, which replace a generic web server with an application-specific one. If NodeJS supported PGO, it is likely it could be highly efficient. However, I couldn’t find anything about how the NodeJS binary is compiled for various systems. All I found was a suggestion:
My guess is that PGO has not been a priority for Node. This is a shame, because Node is typically used to create very specific kinds of applications, in contrast to the generic Apache/PHP hosts. Among other things, it would require that web devs recompile their Node binaries after they’ve built their apps, and distribute the binaries into their “cloud” servers.
Here, manual profiling of code running in an application allows significant speed bumps – by finding the most common paths through the code during actual operation, and making “shortcuts” for these common paths.