from the drum-machine-vst dept.
It’s been shown that even small delays in response time on websites can result in sharp declines in user retention. Now Ori Livneh writes on the Wikimedia Blog that over the last six months the Wikimedia Foundation has deployed a new technology that speeds up MediaWiki, Wikipedia’s underlying PHP-based code using a just-in-time compiler. HipHop Virtual Machine (HHVM) , an open-source virtual machine designed for executing programs written in Hack and PHP, reduces the median page-saving time for editors from about 7.5 seconds to 2.5 seconds, and the mean page-saving time from about 6 to 3 seconds which with than 100 million edits in 2014, means saving a decade’s worth of latency every year.
PHP is a dynamic, interpreted language, so it has the inherent performance disadvantage all interpreter languages have when compared to compiled languages such as C. HHVM is able to extract high performance from PHP code by acting as a just-in-time (JIT) compiler, optimizing the compiled code while the program is already running. The basic assumption guiding HHVM’s JIT is that while PHP is a dynamically typed language, the types flowing through PHP programs aren’t very dynamic in practice. HHVM observes the types present at runtime and generates machine code optimized to operate on these types. HHVM still fulfills the role of a PHP runtime interpreter, serving requests immediately upon starting up, without pre-compiling code. But while running, HHVM analyzes the code in order to find opportunities for optimization. The first few times a piece of code is executed, HHVM doesn’t optimize at all; it executes it in the most naive way possible. But as it’s doing that, it keeps a count of the number of times it has been asked to execute various bits of code, and gradually it builds up a profile of the “hot” (frequently invoked and expensive to execute) code paths in a program. This way, it can be strategic about which code paths to study and optimize.
According to Livneh, in addition to the improved response time the CPU load on MediaWiki's app servers has dropped drastically, from about 50% to 10%. MediaWiki IT "has been able to slash their planned purchases for new MediaWiki application servers substantially, compared to what would have been necessary without HHVM."