Skip to main content

Hotspot loves PHP.reboot

Posted by forax on September 4, 2011 at 4:51 PM PDT

I've just compiled the hotspot (server 64bits) using the hotspot-comp workspace of hotspot express

Here are the result (average of 8 best run on 10) when running PHP.reboot (my own toy language) on fibonacci function,
(-server is the server VM of jdk7, -hsx is server VM of upcoming jdk7 update)

java -server bigfibo        4.45 s
java -hsx bigfibo           4.44 s

PHP.reboot (no type annotation) -server bigfibo    22.72 s -hsx bigfibo       13.61 s

PHP.reboot (type specialization) -server bigfibo    11.09 s -hsx bigfibo        8.06 s

PHP.reboot (user defined type annotation) -server bigfibo2    6.96 s -hsx bigfibo2       4.21 s

PHP.reboot is an hybrid runtime, it starts with an interpreter that walks the AST (really slow) and then compile to bytecode.

The first test is with no type information provided by the user, so all variables are objects and invokedynamic is used for the operations, the comparison and for function calls. As you see, there is a huge speedup.

The second test enables a flag that ask the runtime to try to specialize the function at runtime. Because the algorithm used is a fast-forward typechecker, the parameter of fibo is san pecialized as int but the return type is still an object (because fibo is recursive). So basically here, invokedynamic is used for the function calls and the '+' between the results of the function calls. This '+' is a nasty one because the two parameters are objects, so it requires a double guards. You can see the speedup is nice too.

The third test uses a function fibo that declares the parameter type and return type of fibo as int, so only the function calls are done using invokedynamic. You can also see the speedup and weirdly it's now faster than Java (not a lot if you compare the value but don't forget that PHP.reboot starts in interpreter mode) so it's clearly faster. I will take a look to the inlining tree to try to understand why, it's maybe because fibo is a recursive call or because using an invokedynamic which is resolved as an invokestatic enables more inlining than just an invokestatic.

John, Christian, Tom and all the others of the hotspot-comp team,
you make my day


Related Topics >>