Skip to main navigation

# Blogs & News

Maintenance

# Making a faster Web: The renewal of PHP 7 and beyond

12 Apr, 2017

##

by Victor Rodriguez Bahena

The Internet has changed the world in a way that history has never seen before. Every year new programming languages, tools, and platforms revolutionize what the Internet is capable of. One of the technologies behind this revolution is the hypertext preprocessor, or PHP. PHP is one of the most common programming languages used for website and web application development. PHP is a general purpose, server-side scripting language that was designed to make dynamic pages and applications [1]. The latest numbers show that PHP is used by 82.4% of all websites [2]. Because of this, any performance changes in PHP are extremely important to the industry.

PHP has evolved steadily since its origins in 1994 [3]. With more than 20 years of open source development, PHP has improved both in functionality and performance. With the deployment of PHP 7 in 2016, the world witnessed the first major PHP release in over a decade. This new version comes with many new features, including new operators, better error handling, type declarations, and improvements in execution performance.

In terms of performance, significant collaboration between Intel® and the PHP community leveraged new hardware features that improved processing efficiency and increased the execution speed of PHP 7 [4]. Benchmarks for PHP 7 consistently demonstrated speeds twice as fast as PHP 5.6 [4]. An article in the Phoronix* benchmarking site [9] reported that PHP 7 delivers an overall performance increase of up to two-and-a-half times that of PHP 5†.

The key changes made in PHP 7 to achieve such great performance are described in the whitepaper, Half the footprint, twice the speed: Accelerating performance for server-side PHP 7 [5]. These changes start with hardware-based optimizations, such as better memory management, more powerful branch miss prediction algorithms, the use of advanced vector extensions (AVX2) technology, and an enhanced fast_memcpy() function optimized using some of Intel's specialized SSE2 instructions.

In the Clear Linux* Project, we want to showcase the best of Intel® Architecture technology and performance, from low-level kernel features to complex applications that span the entire operating system stack. We are fully focused on power and performance optimizations throughout the operating system as a whole. This mission drove our decision to use PHP 7, since we know compiler flags are one of the most important keys to improving the performance of operating systems. The Clear Linux* Project ships with more aggressive defaults, including default compiler flags for faster performance of the resulting binaries.

##

In conjunction with the compiler flags, the use of Profile Guided Optimization (PGO)—also known as feedback-directed optimization (FDO)—helps to improve the performance based on real workloads. As we can see in [6], PGO can provide almost a 20%† improvement in performance.

The technology behind PGO applied to the GNU Compiler Collection* (GCC) is the use of static instrumentation to collect edge and value profiles. GCC uses execution profiles that consist of basic block and edge frequency counts to guide optimizations, such as instruction scheduling, basic block reordering, function splitting, and register allocation. The current method of PGO in GCC involves the following steps [7]:

1. Build an instrumented version of the program for edge and value profiling.
2. Run the instrumented version with representative training data to collect the execution profile. These runs typically incur significant overhead due to executing additional instrumentation code.
3. Build an optimized version of the program by using the collected execution profile to guide the optimizations.

The instrumentation and PGO builds are tightly coupled. GCC requires both builds use the same inline decisions and similar optimization flags. This ensures the control-flow graph (CFG) is instrumented in the instrumentation build and that it matches the CFG annotated with the profile data in the PGO build.

Despite all these advantages, only 2.4% of all websites where the server-side programming language is known use PHP version 7 [8]. This shows that only a very small part of the industry is taking advantage of the new technology provided by PHP 7 and GCC. In a world of rapid technological change, it is necessary to have fastest web we can, and we can't afford to leave optimizations on the table that enable robust solutions for datacenters.

##
Footnotes

1. Agarwal, M. S. (n.d.). Digital Pugs Media. Retrieved 02 02, 2017, from The Importance Of PHP Web Development : https://www.digitalpugs.com/articles/the-importance-of-php-web-development.php
2. W3Techs - World Wide Web Technology Surveys . (n.d.). Retrieved 02 02, 2017, from Comparison of the usage of PHP vs. Lua for websites : https://w3techs.com/technologies/comparison/pl-lua,pl-php
3. Achour, M. (n.d.). PHP Manual. Retrieved 02 02, 2017, from History of PHP: http://php.net/manual/en/history.php.php
4. Holligan, A. (2016, January 27). Treehouse. Retrieved January 02, 2017, from 5 New Features in PHP 7: http://blog.teamtreehouse.com/5-new-features-php-7
5. Intel Developer Zone. (2016, July 20). Retrieved January 02, 2017, from Half the footprint, twice the speed: Accelerating performance for server-side PHP 7 : https://software.intel.com/en-us/articles/half-the-footprint-twice-the-speed-accelerating-performance-for-server-side-php-7
6. Larabel, M. (2017, February 03). phoronix. Retrieved January 02, 2017, from Clear Linux's Latest Performance-Optimizing Effort: Greater PHP Performance : http://phoronix.com/scan.php?page=news_item&px=Clear-Linux-PHP7-PGO-Opt
7. Rodriguez, V. (n.d.). Clear Linux* Project. Retrieved January 02, 2017, from AutoFDO Automatic Feedback-Directed Optimizer: https://clearlinux.org/features/autofdo
8. W3Techs - World Wide Web Technology Surveys . (n.d.). Retrieved February 02, 2017, from Usage statistics and market share of PHP version 7 for websites : https://w3techs.com/technologies/details/pl-php/7/all
9. Larabel, M. (2016, June 01). Phoronix. PHP 5.3 Through PHP 7.1-dev Tests Along With HHVM On Ubuntu 16.04 - Phoronix: https://www.phoronix.com/scan.php?page=news_item&px=PHP-Tests-PTS-6.4

##
Legal disclaimers

- Intel technologies’ features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. No computer system can be absolutely secure. Check with your system manufacturer or retailer or learn more at www.intel.com.
- †Software and workloads used in performance tests may have been optimized for performance only on Intel microprocessors. Performance tests, such as SYSmark and MobileMark, are measured using specific computer systems, components, software, operations and functions. Any change to any of those factors may cause the results to vary. You should consult other information and performance tests to assist you in fully evaluating your contemplated purchases, including the performance of that product when combined with other products. For more information go to www.intel.com/benchmarks. Configurations: Review the configurations use by Phoronix here: http://phoronix.com/scan.php?page=news_item&px=Clear-Linux-PHP7-PGO-Opt.
- Intel, the Intel logo, Clear Linux are trademarks of Intel Corporation in the U.S. and/or other countries.
- *Other names and brands may be claimed as the property of others.
- © Intel Corporation.