
10/18/2011 · Minghui Yang
What this post added
This post details several optimizations made to the HPHPi interpreter to improve its performance. These include: sharing parse trees across sandboxes to reduce parsing time and memory usage, moving PHP file parsing out of a critical region to enable parallel parsing, AST node specialization (e.g., for increment/decrement operations) to reduce node size and speed up operations, caching pointers to built-in function metadata to avoid hash table lookups, precomputing static values and scalar arrays, preprocessing AST nodes for frequently evaluated expressions, type prediction to bypass overloaded operators for common types, improving hash table lookups by using HipHop's StringIMap/StringMap and making StaticStrings unique, making common function calls faster by avoiding argument array packing for up to 6 arguments, and enabling unit tests to run in server mode for parallel execution and parse tree reuse. These optimizations resulted in a 53.6% increase in speed for the bench.php benchmark.