Hotspot loves PHP.reboot
Rémi Forax
forax at univ-mlv.fr
Sun Sep 4 16:11:56 PDT 2011
I've just compiled the hotspot (64bits server) using the hotspot-comp
workspace of hotspot express (hsx)
http://hg.openjdk.java.net/hsx/hotspot-comp/hotspot/
Here are the result when running PHP.reboot on fibonacci
(-server is the server VM of jdk1.7.0):
Java:
java -server bigfibo 4.45 s
java -hsx bigfibo 4.44 s
PHP.reboot (no type annotation)
phpr.sh -server bigfibo 22.72 s
phpr.sh -hsx bigfibo 13.61 s
PHP.reboot (type specialization)
phpr.sh -server bigfibo 11.09 s
phpr.sh -hsx bigfibo 8.06 s
PHP.reboot (user defined type annotation)
phpr.sh -server bigfibo2 6.96 s
phpr.sh -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 object 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 file that declare 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 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 :)
cheers,
Rémi
More information about the mlvm-dev
mailing list