How HHVM Uses Modern C++ for Fun and Profit (Literally)
summary
HHVM is a production JIT for PHP that claims 10x throughput and 75% memory reduction versus older PHP over several years; the implementation shows the specifics: C++11 features (templates, lambdas, move ctors, unrestricted unions), X‑macro tables for bytecode, jemalloc tweaks to get low‑address 32‑bit pointers, bit‑stealing in activation records (~48 bytes), an enterTC trampoline to switch between C++ and generated x64, perf-based profiling, register_frame for exception integration, huge pages to cut ITLB misses, and workarounds for virtual methods and non‑POD unions.
AI-written summary · about
chapters (40)
- 0:00Intro
- 0:52What is HHVM?
- 1:45HHVM at Facebook
- 3:31Facebook Data Center
- 4:01Performance
- 4:33Productivity
- 5:39What can HHVM run?
- 6:24How does HHVM work?
- 7:10Basic Compilation Pipeline
- 8:38Tracelets
- 11:46Another translation example
- 13:56HHVM's Execution Model
- 14:33Why was C++ a good choice for building HHVM?
- 18:15Templates
- 23:13C++11's Lambdas
- 26:01X Macros
- 27:15Unions and field size
- 28:12TypedValue union
- 29:01Unsafe casts and bit-stealing
- 29:56Activation Records
- 33:58Bit-stealing with ActRecs
- 37:00Profiling
- 39:31Exception handling / unwinding
- 41:04Exception handling/ unwinding
- 43:37C++ / machine code interop
- 44:36enterTCHelper example
- 47:05Manual Memory Management
- 48:11Native allocation
- 49:26jemalloc
- 50:57Low addresses
- 52:20Memory Management for PHP
- 52:41HHVM's request allocator
- 53:23Huge pages
- 54:21Obstacles
- 54:55Unions and non-POD types
- 55:47C++11's Unrestricted Unions
- 56:36Avoiding unnecessary refcounting
- 57:06C++11's Move Constructors
- 57:53C++ instance methods
- 58:55C++ virtual methods
related talks
01h 00mJust-in-Time Compilation
58mLeveraging C++20/23 Features for Low Level Interactions
55mC++ 20 Innovations: High-Performance Cross-Platform Architecture in C++
59mC++ on its way to exascale and beyond
01h 49mKeynote: What C++ is and what it will become
01h 05mThe Most Important Optimizations to Apply in Your C++ Programs
01h 00mIntroduction to Hardware Efficiency in Cpp
01h 03mUnlocking the value of C++20
