Explored some ideas for HipHop optimisation. Made a preprocessor implementation,...
authorTim Starling <tstarling@users.mediawiki.org>
Thu, 2 Jun 2011 02:44:33 +0000 (02:44 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Thu, 2 Jun 2011 02:44:33 +0000 (02:44 +0000)
commit52350820950b2b7a97165372417c29d25430047d
tree848ae01674cfd77439455ee1b398f04481709e49
parent6f7e2eb71ec4e1a7ce40feb3508c8f8a06e64081
Explored some ideas for HipHop optimisation. Made a preprocessor implementation, based on a copy of Preprocessor_Hash, with a preprocessToObj() which is optimised. It takes 33% less time than Preprocessor_Hash for a certain realistic test case (the Barack Obama article). Some notes about what I did:
* Set EnableHipHopSyntax=true to enable string and integer type hints. I gave the file a .hphp extension to avoid false alarms in syntax checking scripts.
* Made sure almost all the local variables in preprocessToObj() have a specific type, instead of being variants. This is useful for integers, but has the largest impact for objects, since dynamic method calls can be avoided.
* Stopped using extract() since it forces all local variables to be variants, and adds some hashtable initialisation overhead.
* Found a way to cast a variant to a specific object class, by abusing argument type hinting. The method does not require special syntax; it is harmless in Zend PHP.
* Wrapped various internal function calls with type casts. strspn() and substr() need to be wrapped with intval() and strval() respectively, since they return a variant to support special error return values. HipHop isn't smart enough to know whether the error case will be triggered.
* Replaced most instances of double-equals with triple-equals. Profiling indicates that this makes a very large difference when comparing strings, much more so than in Zend.
includes/AutoLoader.php
includes/parser/Preprocessor_HipHop.hphp [new file with mode: 0644]
maintenance/hiphop/compiler.conf