Zend Touts 2X Speedup With PHP 7 And New Runtime
May 16, 2016 Alex Woodie
The new release of Zend‘s PHP development language and PHP runtime will run twice as fast on Intel Xeon and IBM Power servers than previous versions, the company says. IBM i customers won’t need to do anything to take advantage of the speedup except use the new runtime, which should be available in the coming weeks. Zend, which is now owned by Rogue Wave Software, last week officially announced Zend Server 9, the newest version of the Zend runtime for Intel platforms. Zend Server 9 is based on PHP version 7, the newest version of the language, which the company shipped in 2015. The performance boost is the biggest new feature in Zend Server 9, but it didn’t come easy, according to Zend co-founder and CTO Zeev Suraski. “Basically we did two things–one that failed miserably, but showed a lot of promise in the beginning.” And another that actually paid dividends. JIT No Go The failed approach involved using a just in time (JIT) compiler for PHP code, similar to how Java and JavaScript work. The JIT approach showed great promise in the lab, giving PHP 7 performance gains of up to 6X compared to the PHP 5.6 codebase. But what sizzled in synthetic benchmarks fizzled on real-world PHP workloads, such as running a Magento e-commerce app or a WordPress content management system. Zend worked closely with Intel to figure out why the JIT approach wasn’t paying dividends.
“There were a lot of theories,” Suraski explains. “But the most substantial theory seemed to be that that because of relatively heavy memory utilization of PHP, the fact that the data structures are relatively large, you move a lot of data around–SQL queries, data coming from the Web, reading data back to the web–the optimization at the CPU level that we did were not delivering any meaningful performance gains.” So Suraski and his Zend colleagues went back to the drawing board. Since PHP’s memory utilization seemed to be so critical for complex workloads, the company decided to try to optimize its memory footprint. “We went ahead and did that and we actually reduced the data structures of PHP very substantially,” Suraski says. The company worked to slim down key components of the PHP stack. As you can see from Fig A, Zend shrunk the zVal (Zend value) structure from 24 bytes to 16 bytes, slimmed the hash table from 72 bytes to 56 bytes; and reduced the “bucket” from 72 bytes to 32 bytes. The memory diet resulted in a considerable improvement in how PHP used memory. For one particular app, the memory consumption went from 37 MB per request to about 5 MB, a 7X improvement. “You can’t always expect that,” Suraski says. “But you can expect anywhere from 50 percent better memory performance, up to 7X better performance, and maybe more.” Zend also took the knife to the Zend memory manager itself, slashing its CPU footprint by a considerable amount, as you can see by Fig B.
The optimized memory structures and CPU optimization will benefit customers by delivering either a 2X performance boost, or a 1/2X reduction in server density, depending on how they slice it. “It really helps with both the performance and the density: How many concurrent PHP processes can your server serve at the same time without running out of memory,” he says. “So this number has shot through the roof with PHP 7. It can run a lot more processes using the same amount of memory and each process runs a lot more efficiently.” After the big JIT letdown, the memory breakthrough was a relief to Zend. “We refer to PHP 7 kind of like magic. We know how we did it, but to be perfectly honest, we were surprised by how much gain we realized just from doing those refactoring and compacting of the data structures,” Suraksi says. The Zend R&D team never went back to JIT. But now that it’s bolstered the memory footprint of PHP, the company may revisit JIT in the future to optimize the CPU utilization. Powering Up PHP Zend hasn’t benchmarked PHP 7 and Zend Server 9 on IBM Power Systems servers yet. But Suraski sees no reason why IBM i shops won’t see the same kind of benefits that optimizing the memory showed on Intel machines. “The memory consumption should be identical and my assumption is that from the performance perspective, it should be very similar, if not identical,” he says. “The changes that we made are not platform specific. And both platforms are 64 bit. We can expect very similar behavior for both platforms.” There’s the possibility that, owing to Power’s already-superior memory bandwidth compared to Intel Xeon architectures, that apps running atop PHP 7 and Zend Server 9 won’t see quite the same boost as they showed on Intel, Suraski concedes. “It might be we see slightly less performance improvement. Maybe moving that much memory in IBM i doesn’t slow things down as much as it does on Intel.”
In any event, it’s academic until the new software starts hitting real-world workloads. That should come this summer, as the company expects to ship the version 9 release of Zend Server for IBM i in about two months, although an early release version of the code could be available within a matter of weeks. The delay in the IBM i runtime is due to the substantial amount of work that Zend had to do with this new release, Suraski says. “It’s not just a matter of recompiling, but you have to do a partial rewrite,” he says. Side-by-Side Install The performance gain is the headliner for PHP 7 and Zend Server 9, but there are several other enhancements that are worth noting. In particular, IBM i shops will benefit from a new feature that allows multiple versions of Zend Server to be installed on the same box. This will help make the move up from 5.x versions of PHP and their associated runtimes less painful, Suraski says. “A lot of people just update it and hope it will work in the same way,” he says. But with this feature, “Instead, you can actually install them side by side, copy the applications over, and make sure everything is working to your satisfaction, and then move the URL, the pointers to point to the PHP 7 version, and uninstall of PHP 5 when you’re confident that everything is working properly.” IBM i shops, in particular, will find this feature reassuring. “We wanted specifically for the IBM i crowd to have that piece of mind,” Suraski says, “instead of being on that bleeding edge of just upgrading and crossing their fingers. We wanted to give them the ability to do this more slowly.” The new release also brings new code tracing capabilities, which is primarily used to track down production problems in PHP applications and has been compared to an aircraft’s “black box” flight data recorder. Zend offered code tracing in the product before, but the new HTML5-based interface (compared to the old Flash-based UI) will make code tracing much more useful. “We’ve mastered code tracing,” Suraski says. “In terms of execution flow, we can see the whole thing–each and every step of the wait, each and every function that was called, the parameter that was passed to it all the way down to each and every detail. Everything is there. I believe people are going to start using it a lot more compared to previous versions.” Last but not least, the Z-Ray function, which is more geared toward developers, has also been improved in Zend Server 9. A new Z-Ray history feature will let developers see what just happened with a Magento application, for example. Developers can also now share their Z-Rays with this release. RELATED STORIES Zend Delivers Mobile App Enhancements to PHP Developers PHP And SQL Driving Modernization Strategies At IBM i Shops, Zend Says Zend Peers Deep into Your Code with Z-Ray Zend Server 6 for IBM i Goes GA Zend Adds Mobile, Problem-Resolution Features to PHP Stack Zend Updates PHP Server Stack for IBM i Zend Taps Percona to Provide Support and Maintenance for DBi Zend Reveals DBi, A New Version of MySQL for IBM i New Open Source PHP Toolkit for IBM i in the Works
|