hotspot inlining decision seems to be random

Ulf Zibis Ulf.Zibis at gmx.de
Mon Dec 14 03:22:10 PST 2009


Christian Thalinger schrieb:
> On Sat, 2009-12-12 at 18:01 +0100, Ulf Zibis wrote:
>   
>> Please refer to:
>> [1]
>> https://java-nio-charset-enhanced.dev.java.net/source/browse/java-nio-charset-enhanced/branches/j7_EUC_TW/log/C_d_b_reverse1-2_highSurrogate_PA.xml?rev=866&view=markup
>> [2]
>> https://java-nio-charset-enhanced.dev.java.net/source/browse/java-nio-charset-enhanced/branches/j7_EUC_TW/log/C_d_b_reverse1-2_highSurrogate_PA_2.xml?rev=866&view=markup
>> [3] 
>> https://java-nio-charset-enhanced.dev.java.net/source/browse/java-nio-charset-enhanced/branches/j7_EUC_TW/log/C_d_b_reverse1-2_highSurrogate_PA_3.xml?rev=868&view=markup
>>
>> I have run [4] the same code [5] 3 times.
>> On 1st run, method highSurrogate(int) [6] was inlined in Decoder$decode(...) [7] as hot ([1] line 
>> 276-293), but not on 2nd run ([2] line 332-358).
>> Can someone explain this, because method highSurrogate() was executed 26,314,402 times ([3] line 1932) ?
>>
>> In [2] (line 125, 215) hotspot log says:
>> @ 479   sun.nio.cs.ext.EUC_TW_C_d_b_reverse1$Decoder::decode  never executed
>> @ 95   java.lang.Character::highSurrogate  executed < MinInliningThreshold
>>
>> On 3rd run, method highSurrogate(char,char) [6] was inlined in Decoder$decode(...) [8] as hot ([3] 
>> line 832-846), but not in 1st ([1] line 1012-1034) or 2nd run ([2] line 992-1014).
>> So I can see that hotspot inlining decision was different in each 3 runs:
>>
>>                               [1]       [2]       [3]
>>
>> highSurrogate(int)         276-293   332-358   473-490
>> [7] line 277                inline     call     inline
>>
>> highSurrogate(char,char)  1012-1034  992-1014  832-846
>> [8] line 277                 call      call     inline
>>     
>
> I don't know what to do with all this information.  "I've run the same
> code 3 times" is not very informative.  How did you run it 3 times?
>   

As you maybe know, I run my code under NetBeans IDE.
'run it 3 times' just means, that I hit the "Run Project" button 3 times 
consecutively (here using configuration [4]).

> It's true that the logs look different but without being able to
> reproduce I can't tell what's going on.
>   

I you have NetBeans 6.8 installed, just checkout the project and run it 
several times from configuration [4].
If not, use:
java -server -Xbootclasspath/p:build/classes \
-XX:+UnlockDiagnosticVMOptions -XX:-DisplayVMOutput \
-XX:MaxInlineSize=250 \
-XX:+PrintCompilation \
-XX:+PrintInlining \
-XX:CompileCommand=print,sun.nio.cs.ext.EUC_TW_C_d_b_reverse1$Decoder::decode 
\
-XX:CompileCommand=print,sun.nio.cs.ext.EUC_TW_C_d_b_reverse2$Decoder::decode 
\
-XX:CompileCommand=print,java.lang.Character::highSurrogate \
-XX:CompileCommand=print,java.lang.Character::lowSurrogate \
sun.nio.cs.ext.EUC_TWBenchmark EUC_TW_C_d_b_reverse1 EUC_TW_C_d_b_reverse2

The Problem I have is, how to reliably see the effect of my code changes 
on the resulting performance.
For example, in [3] (at the end) you can see, that 
highSurrogate(char,char) is much faster than highSurrogate(int), if 
inlined. If not inlined [1],[2], it's opposite.
So how can I reliably force the inlining of method highSurrogate(...) as 
too as of decode(...) for my benchmark testing?
-XX:MaxInlineSize=250 seems not reliable

-Ulf



More information about the hotspot-compiler-dev mailing list