Speeding up PHP-based development with HipHop VM

Visit the post for more.

Drew Paroski
12 min readadvanced
--
View Original

Overview

The article discusses the development of HipHop VM (HHVM) at Facebook, focusing on its performance improvements over the previous HipHop PHP-to-C++ compiler (HPHPc) and its impact on PHP development. It highlights the transition to a just-in-time (JIT) compilation approach, the unification of production and development environments, and ongoing optimization efforts.

What You'll Learn

1

How to implement HipHop VM for PHP development

2

Why JIT compilation improves PHP performance

3

When to transition from HPHPc to HHVM in production environments

4

How to optimize PHP applications using HHVM's features

Prerequisites & Requirements

  • Understanding of PHP and its execution models
  • Familiarity with Git for accessing the HHVM repository(optional)

Key Questions Answered

How does HHVM compare to HPHPc in terms of performance?
HHVM has achieved performance levels comparable to HPHPc, utilizing dynamic translation techniques to optimize PHP execution. This advancement allows Facebook to serve production traffic more efficiently, with HHVM's performance continuing to improve over time.
What are the benefits of using HHVM in development environments?
HHVM significantly reduces page load times by over 3x compared to the previous HPHPi interpreter, while maintaining a rapid development workflow. This unification allows developers to debug and iterate in the same environment used for production, enhancing productivity.
What optimizations have been made to the JIT in HHVM?
The JIT in HHVM has been improved by adding support for less common bytecode instructions, implementing side exits for better handling of edge cases, and using type prediction for method call return types, which collectively enhance execution efficiency.
Why is open sourcing HHVM important for the PHP community?
Open sourcing HHVM allows the broader PHP community to benefit from Facebook's optimizations and improvements, ensuring compatibility with popular PHP applications like WordPress and facilitating easier adoption of HHVM as a development and deployment platform.

Key Statistics & Figures

Performance improvement over HPHPi
over 3x
This improvement was observed after deploying HHVM in development sandboxes.
Reduction in CPU time from JIT optimizations
more than 13%
This reduction was achieved by implementing full JIT support for member instructions.
Reduction in CPU time from type prediction
~2%
This reduction was noted when running the facebook.com site.
Tracelet success rate improvement
from ~79.9% to ~91.6%
This improvement was achieved by changing how parallel tracelets link together.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Backend
Hiphop Vm
Used as a just-in-time compiler for PHP applications at Facebook.
Programming Language
Php
The primary language being optimized and executed by HHVM.
Tools
Git
Used for version control and accessing the HHVM public repository.

Key Actionable Insights

1
Transitioning to HHVM can drastically improve PHP application performance, especially for large codebases.
By leveraging HHVM's JIT compilation, developers can achieve performance gains that are critical for high-traffic applications, making it essential for teams looking to optimize their PHP environments.
2
Utilizing side exits in JIT can enhance the robustness of PHP applications.
This technique allows for better handling of unexpected changes in variable types during execution, which can prevent bugs and improve application stability.
3
Regularly updating and maintaining the HHVM environment is crucial for ongoing performance improvements.
As HHVM continues to evolve, staying current with the latest updates will ensure that developers can take advantage of new optimizations and features.

Common Pitfalls

1
Assuming that all PHP code will run without modification on HHVM.
Not all PHP applications are compatible with HHVM out of the box, and developers may need to make adjustments to ensure proper functionality.

Related Concepts

Jit Compilation
Php Optimization Techniques
Open Source Software Development