On 04/05/2011 04:45 PM, Ashar Voultoiz wrote:
On 05/04/11 04:47, Tim Starling wrote:
Speaking of "fast", I did a quick
benchmark of the [[Barack Obama]]
article with templates pre-expanded. It took 22 seconds in HipHop and
112 seconds in Zend, which is not bad, for a first attempt. I reckon
it would do better if a few of the regular expressions were replaced
with tight loops.
<snip>
I have imported in my local wiki the english [[Barack Obama]] article
with all its dependencies. I can not have it parsed under either 256MB
max memory or 1 minute max execution time limits.
Hiphop helps, but there is still a highly broken code somewhere in our
PHP source code. No matter how much hacks we throw at bad code, the
algorithm still need to get fixed.
Let me know when you find that broken code. Try using the profiling
feature from xdebug to narrow down the causes of CPU usage.
Also, browsing
the generated source turns up silly things like:
if (equal(switch2, (NAMSTR(s_ss34c5c84c, "currentmonth"))))
goto case_2_0;
if (equal(switch2, (NAMSTR(s_ss55b88086, "currentmonth1"))))
goto case_2_1;
<snip>
71 string comparisons in total, in quite a hot
function. A hashtable
would probably be better.
As I understand it, hiphop is just a straight translator from PHP to C
language but does not actually enhance the code. Just like you would use
Google translator instead of Charles Baudelaire [1].
It's not just a translator, it's also a reimplementation of the bulk
of the PHP core.
Your code above comes from Parse.php
getVariableValue() which use a long
switch() structure to map a string to a method call. If you manage to
find unoptimized code in the translated code, fix it in the PHP source
code :-b
In Zend PHP, switch statements are implemented by making a hashtable
at compile time, and then doing a hashtable lookup at runtime. The
HipHop implementation is less efficient. So getVariableValue() is not
broken, it's just not optimised for HipHop.
-- Tim Starling