PHP improvements to boost real-world app performance

Developers are tinkering with how the language deals with data structures, data types, and memory allocation

Developers in the PHP community are working on major improvements to the language to dramatically boost real-world application performance, an official at PHP tools vendor Zend Technologies said.

Improvements in a branch of the PHP tree, dubbed phpng, will tinker with how the language, which is used often in server-side Web development, deals with data structures such as hash tables, as well as data types and memory allocation.

These changes in the lab have resulted in significant decreases in memory usage and the number of machine instructions needed to execute an application, said Andi Gutmans, CEO of Zend, which is involved in the development of PHP. For example, the PHP team ran the WordPress CMS on phpng, and it resulted in a drop from 27 seconds to 18 seconds for 100 requests. The number of machine instructions went from 9.4 billion down to 4.99 billion. "This is a real-world app running real-world PHP and starting to see very dramatic improvements," Gutmans said.

One specific change involved separating native types such as integers from complex types like arrays, objects, and strings. PHP thus far has involved a lot of overhead to manage native and complex types. "For native types, we're actually not doing a lot of the unnecessary memory allocations and reference-counting [in phpng]," Gutmans said. "In general, this is not happening anymore for native types." This results in less memory allocation and reference-counting happening around native types in the runtime.

Another improvement to PHP involved re-implementing hash tables -- the foundation for arrays -- to make them significantly more efficient, Gutmans said. One example involved optimizations similar to how the C language would manage arrays versus how a dynamic language would, thus improving efficiency.

The PHP team still has not voted on accepting the improvements into the main code base, but Gutmans expects them to be incorporated into the next major version of PHP, likely in 2015. The intention is that these improvements would not require any changes to existing applications. "Our design point going into this is it has to be 100 percent compatible," he said.

The team had pondered implementing Just-in-Time compilation, involving compiling at runtime into machine code, theoretically giving native-like performance similar to C and C++. But this only resulted in improvements in benchmarks but not necessarily in applications, Gutmans said.

"What we realized was JiT was nice," Gutmans said. "But really, the biggest bottleneck that we were seeing in PHP was around things like memory consumption and other constraints that we had around data structures and data types."

This story, "PHP improvements to boost real-world app performance," was originally published at Get the first word on what the important tech news really means with the InfoWorld Tech Watch blog. For the latest developments in business technology news, follow on Twitter.


Copyright © 2014 IDG Communications, Inc.