More performance explorations
Charles Oliver Nutter
headius at headius.com
Thu Jun 2 17:15:31 PDT 2011
On Thu, Jun 2, 2011 at 11:27 AM, John Rose <john.r.rose at oracle.com> wrote:
> You mean java -Djava.lang.invoke.GWT_FORCE_RICOCHET_FRAMES=true?
>
> If so, let's look at the code again. I want to see if those extra interface casts are still in there. We can get rid of them if they add significant bulk to the code.
Correct. And here we go (somehow I never get tired of dumping
assembly. Maybe I'm in the wrong job?)
I skipped over the earlier calls; current MLVM still chooses to jump
for one branch versus the other in the < call. I'm not sure if that
could indicate an issue, but I doubt it.
FWIW, I'm going to add a boolean-returning path for boolean-expecting
language constructs to avoid the load of true/false and the "isTrue"
interface calls. Should help perf, I imagine (not indy-related).
SO...jumping right down to the first mention of "invokedynamic" in the
PrintAssembly output, the first difference I see is this nugget:
MLVM:
0x00000001028ba7f9: mov 0x8(%r10),%r11d ; implicit exception:
dispatches to 4337695213
0x00000001028ba7fd: mov %r11d,0x18(%rsp)
0x00000001028ba802: mov 0x40(%r12,%r11,8),%r10
0x00000001028ba807: mov %r10,0x20(%rsp)
0x00000001028ba80c: movabs $0x7dbd00fc0,%r11 ;
{oop('org/jruby/RubyBasicObject')}
MACOSX:
4619030673: mov 0x8(%r10),%r11d ; implicit exception:
dispatches to 4619042117
4619030677: mov 0x40(%r12,%r11,8),%r10
4619030682: mov %r10,0x18(%rsp)
4619030687: movabs $0x7dbcfe460,%r11 ;
{oop('org/jruby/RubyBasicObject')}
It's unclear what the extra mov is doing, since most code leading up
to that point seems the same. Perhaps a jump target from somewhere
else?
Next difference seems to be what Tom R was talking about, the use of
Boolean for the newer GWT, and it also seems like there are still a
bunch of checkcasts and extra logic in the works:
MLVM:
0x00000001028bab60: jne 0x00000001028beb72 ;*if_icmpne
; -
org.jruby.runtime.invokedynamic.InvokeDynamicSupport::test at 11 (line
854)
; -
java.lang.invoke.MethodHandle::invokeExact at 3
; -
java.lang.invoke.MethodHandle::invokeExact at 8
; -
bench.bench_fib_recursive::method__0$RUBY$fib_ruby at 77 (line 7)
0x00000001028bab66: movabs $0x7f5962da0,%r10 ; {oop(a
'java/lang/Class' = 'java/lang/Boolean')}
0x00000001028bab70: mov 0x70(%r10),%r10d ;*areturn
; -
java.lang.Boolean::valueOf at 13 (line 149)
; -
java.lang.invoke.MethodHandle::invokeExact at 1
; -
java.lang.invoke.MethodHandle::invokeExact at 23
; -
bench.bench_fib_recursive::method__0$RUBY$fib_ruby at 77 (line 7)
0x00000001028bab74: movzbl 0xc(%r12,%r10,8),%r11d
0x00000001028bab7a: test %r11d,%r11d
0x00000001028bab7d: je 0x00000001028bec9d ;*ifeq
; -
java.lang.invoke.MethodHandleImpl::selectAlternative at 1 (line 1042)
; -
java.lang.invoke.MethodHandle::invokeExact at 22
; -
java.lang.invoke.MethodHandle::invokeExact at 10
; -
java.lang.invoke.MethodHandle::invokeExact at 23
; -
bench.bench_fib_recursive::method__0$RUBY$fib_ruby at 77 (line 7)
0x00000001028bab83: movabs $0x7f62b43d8,%rbp ;*areturn
; -
java.lang.invoke.MethodHandleImpl::selectAlternative at 9 (line 1042)
; -
java.lang.invoke.MethodHandle::invokeExact at 22
; -
java.lang.invoke.MethodHandle::invokeExact at 10
; -
java.lang.invoke.MethodHandle::invokeExact at 23
; -
bench.bench_fib_recursive::method__0$RUBY$fib_ruby at 77 (line 7)
; {oop(a
'java/lang/invoke/AdapterMethodHandle')}
0x00000001028bab8d: mov 0x70(%rsp),%r10
0x00000001028bab92: mov 0x8(%r10),%r11d ; implicit exception:
dispatches to 4337695453
0x00000001028bab96: mov %r11d,0x1c(%rsp)
0x00000001028bab9b: mov 0x28(%r12,%r11,8),%r10
0x00000001028baba0: movabs $0x7dbcbe420,%r11 ;
{oop('org/jruby/runtime/builtin/IRubyObject')}
0x00000001028babaa: cmp %r11,%r10
0x00000001028babad: jne 0x00000001028bc8f9 ;*checkcast
; -
java.lang.invoke.MethodHandle::invokeExact at 17
; -
java.lang.invoke.MethodHandle::invokeExact at 23
; -
bench.bench_fib_recursive::method__0$RUBY$fib_ruby at 77 (line 7)
0x00000001028babb3: mov 0x18(%rsp),%r10d
0x00000001028babb8: mov 0x28(%r12,%r10,8),%r8 ;*checkcast
; -
java.lang.invoke.MethodHandle::invokeExact at 37
; -
java.lang.invoke.MethodHandle::invokeExact at 23
; -
bench.bench_fib_recursive::method__0$RUBY$fib_ruby at 77 (line 7)
0x00000001028babbd: shl $0x3,%r10
0x00000001028babc1: mov %r10,0x28(%rsp)
0x00000001028babc6: movabs $0x7dbcbe420,%r10 ;
{oop('org/jruby/runtime/builtin/IRubyObject')}
0x00000001028babd0: cmp %r10,%r8
0x00000001028babd3: jne 0x00000001028bc945 ;*checkcast
; -
java.lang.invoke.MethodHandle::invokeExact at 31
; -
java.lang.invoke.MethodHandle::invokeExact at 23
; -
bench.bench_fib_recursive::method__0$RUBY$fib_ruby at 77 (line 7)
0x00000001028babd9: cmp %r10,%r8
0x00000001028babdc: jne 0x00000001028bc995 ;*checkcast
; -
java.lang.invoke.MethodHandle::invokeExact at 37
; -
java.lang.invoke.MethodHandle::invokeExact at 23
; -
bench.bench_fib_recursive::method__0$RUBY$fib_ruby at 77 (line 7)
0x00000001028babe2: movabs $0x7f62b3ee0,%r10 ; {oop(a
'java/lang/invoke/BoundMethodHandle')}
0x00000001028babec: cmp %r10,%rbp
0x00000001028babef: je 0x00000001028bba65 ;*invokespecial invokeExact
; -
java.lang.invoke.MethodHandle::invokeExact at 65
; -
java.lang.invoke.MethodHandle::invokeExact at 23
; -
bench.bench_fib_recursive::method__0$RUBY$fib_ruby at 77 (line 7)
0x00000001028babf5: movabs $0x7f5c3e7e8,%r10 ; {oop(a
'bench/bench_fib_recursive')}
0x00000001028babff: mov 0xc(%r10),%r11d ;*getfield runtimeCache
; -
org.jruby.ast.executable.AbstractScript::getCallSite0 at 1 (line 80)
; -
bench.bench_fib_recursive::method__0$RUBY$fib_ruby at 4 (line 4)
; -
java.lang.invoke.MethodHandle::invokeExact at 8
; -
java.lang.invoke.MethodHandle::invokeExact at 65
; -
java.lang.invoke.MethodHandle::invokeExact at 23
; -
bench.bench_fib_recursive::method__0$RUBY$fib_ruby at 77 (line 7)
MACOSX
4619030730: jne 4619037743 ;*if_icmpne
; -
org.jruby.runtime.invokedynamic.InvokeDynamicSupport::test at 11 (line
854)
; -
java.lang.invoke.MethodHandle::invokeExact at 15
; -
java.lang.invoke.MethodHandleImpl$GuardWithTest::invoke_L5 at 11 (line
865)
; -
java.lang.invoke.MethodHandle::invokeExact at 8
; -
bench.bench_fib_recursive::method__0$RUBY$fib_ruby at 51 (line 7)
4619030736: movabs $0x7f5c539e0,%r10 ; {oop(a
'bench/bench_fib_recursive')}
4619030746: mov 0xc(%r10),%r10d ;*getfield runtimeCache
; -
org.jruby.ast.executable.AbstractScript::getCallSite0 at 1 (line 80)
; -
bench.bench_fib_recursive::method__0$RUBY$fib_ruby at 4 (line 4)
; -
java.lang.invoke.MethodHandle::invokeExact at 20
; -
java.lang.invoke.MethodHandleImpl$GuardWithTest::invoke_L5 at 28 (line
866)
; -
java.lang.invoke.MethodHandle::invokeExact at 8
; -
bench.bench_fib_recursive::method__0$RUBY$fib_ruby at 51 (line 7)
At the moment, the recursive call to fib_ruby and + are the only
invokedynamic-based calls in the hot path of this benchmark. There are
calls to < and -, but they still use specialized JRuby CallSite
objects that inline very well and only ever pass a primitive long as
their argument (avoiding a FIxnum cache hit).
I've attached the new dump to this email.
> Or maybe there's a failed inline.
>From what I can tell, nothing along the invokedynamic call path (for
the recursive call, anyway) is failing to inline. There's just extra
logic happening.
> The door is about closed on JDK7 code changes (and the backed-off GWT stuff is in). I can help you work around weaknesses in the JDK7 code, by adjusting the JRuby code. Not optimal, but maybe practical.
I'm quite happy to do so! Did SwitchPoint optimization make it in?
I wish I knew more about Hotspot so I could lend a hand :)
- Charlie
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fib_ruby-mlvm_64bit_20110602.zip
Type: application/zip
Size: 63829 bytes
Desc: not available
Url : http://mail.openjdk.java.net/pipermail/mlvm-dev/attachments/20110602/42553bac/attachment-0001.zip
More information about the mlvm-dev
mailing list