MethodHandle lookup&invocation performance

Rémi Forax forax at univ-mlv.fr
Mon Jul 11 06:38:23 PDT 2011


On 07/11/2011 03:17 PM, Christian Thalinger wrote:
> On Jul 9, 2011, at 3:27 PM, Hiroshi Nakamura wrote:
>> Hello,
>>
>> Thanks for you comments.
>>
>> On Sat, Jul 9, 2011 at 19:01, Jochen Theodorou<blackdrag at gmx.org>  wrote:
>>>> Code is here:
>>>> https://raw.github.com/nahi/jsr292-sandbox/master/src/jp/gr/java_conf/jruby/MethodHandleTest.java
>>> lookup I don't know. I am not sure about the recent versions, I think
>>> the lookup is using the same "core" as Reflection plus additional
>>> checks. I don't expect that to be faster. It would be very nice though.
>>>
>>> The performance of the invocation cannot be meassured like you do it I
>>> think. The big pro comes from the ability to inline the method calls,
>>> but this is only present if you use the invokedynamic bytecode
>>> instruction. There is currently no way in Java to express invokedynamic.
>> Sure. I should have written it clearly. I heard from someone at Java
>> SE 7 launch event that reflection would get faster on Java SE 7 even
>> if you don't use dynamic language, so I wanted to measure the
>> MethodHandle perf without invokedynamic.
>>
>> For invokedynamic, I did some (bogus, experimental, micro)benchmark
>> with current JRuby.
>> http://bit.ly/invokedynamic (Flash, Japanese)
>> Please see the circle at the right edge of 5 circles. Invokedynamic
>> support of JRuby is still experimental but it already outperforms
>> existing optimization code for some microbenchmarks. Great job,
>> Charles.
> Just a quick follow up on the tak numbers, which look really bad.  The problem here is that we inline the fallback path (a bug we know about).  Excluding that one method from inlining actually gives better numbers with invokedynamic:
>
> intelsdv03.us.oracle.com:/export/twisti/jruby$ jruby -X+C --server bench/bench_tak.rb 5
>        user     system      total        real
>    1.300000   0.000000   1.300000 (  1.263000)
>    1.018000   0.000000   1.018000 (  1.018000)
>    1.018000   0.000000   1.018000 (  1.018000)
>    1.027000   0.000000   1.027000 (  1.027000)
>    1.024000   0.000000   1.024000 (  1.023000)
>
> intelsdv03.us.oracle.com:/export/twisti/jruby$ jruby -X+C --server -J-XX:CompileCommand=dontinline,*.invocationFallback bench/bench_tak.rb 5
> CompilerOracle: dontinline *.invocationFallback
>        user     system      total        real
>    0.619000   0.000000   0.619000 (  0.580000)
>    0.422000   0.000000   0.422000 (  0.422000)
>    0.422000   0.000000   0.422000 (  0.422000)
>    0.422000   0.000000   0.422000 (  0.422000)
>    0.422000   0.000000   0.422000 (  0.422000)
>
> intelsdv03.us.oracle.com:/export/twisti/jruby$ jruby -X+C --server -Xcompile.invokedynamic=false bench/bench_tak.rb 5
>        user     system      total        real
>    0.824000   0.000000   0.824000 (  0.788000)
>    0.565000   0.000000   0.565000 (  0.565000)
>    0.565000   0.000000   0.565000 (  0.565000)
>    0.565000   0.000000   0.565000 (  0.565000)
>    0.565000   0.000000   0.565000 (  0.565000)

Nice numbers.
And we know how to improve the invokedynamic speed a little bit more.

> -- Christian

Rémi



More information about the mlvm-dev mailing list