How to change compilation policy to trigger C2 compilation ASAP?

Krystal Mok rednaxelafx at gmail.com
Thu May 21 00:22:40 UTC 2015


ReadyNow does save profiles to disk and read them back in subsequent runs.
There are also other changes on the side in the runtime and compilers to
make it work smoothly.

Cc'ing Doug Hawkins who's the one working on ReadyNow if anybody's
interested in more information.

- Kris

On Wed, May 20, 2015 at 6:40 AM, Vitaly Davidovich <vitalyd at gmail.com>
wrote:

> Training mode is also dangerous unless built in from beginning as there's
> risk some unwanted application effect will take place.  This is beside the
> possibility of feeding it "wrong" profile.
>
> What does Azul ReadyNow do? Saves profiles to disk and reads them upon
> startup?
>
> sent from my phone
> On May 20, 2015 4:58 AM, "Chris Newland" <cnewland at chrisnewland.com>
> wrote:
>
>> Hi Wei,
>>
>> Thanks! OpenJDK has no support for persisting compilation profile data
>> between VM runs. For some industries it can be economical to use a
>> commercial VM to get the lowest latencies.
>>
>> One "free" alternative is to add a training mode to your application and
>> feed it the most realistic input data so that you get a good set of JIT
>> optimisations before the inputs you care about arrive.
>>
>> Is there a reason why you are cold-starting your VM? (For example your GC
>> strategy is to use a huge Eden space and reboot daily to avoid any garbage
>> collections).
>>
>> Regards,
>>
>> Chris
>> @chriswhocodes
>>
>> On Wed, May 20, 2015 09:17, Tangwei (Euler) wrote:
>> > Hi Chris,
>> > Your tool looks cool. I think OpenJDK has no technology to mitigate
>> > cold-start costs, please correct if I am wrong. I can control some
>> > compilation passes with option -XX:CompileCommand, but the profiling
>> > data, such as invocation count and backedge count, has to reach some
>> > threshold before trigger execution level transition. This causes
>> > simulator doesn't trigger C2 compilation within reasonable time span.
>> >
>> > Regards!
>> > wei
>> >
>> >> -----Original Message-----
>> >> From: Chris Newland [mailto:cnewland at chrisnewland.com]
>> >> Sent: Wednesday, May 20, 2015 3:46 PM
>> >> To: Vitaly Davidovich
>> >> Cc: Tangwei (Euler); Vladimir Kozlov; hotspot compiler
>> >> Subject: RE: How to change compilation policy to trigger C2 compilation
>> >> ASAP?
>> >>
>> >>
>> >> Hi Wei,
>> >>
>> >>
>> >> Is there any reason why you need to cold-start your application each
>> >> time and begin with no profiling information?
>> >>
>> >> Depending on your input data, would it be possible to "warm up" the VM
>> >> by running typical inputs through your code to build a rich profile and
>> >> have the JIT compilations performed before your real data arrives?
>> >>
>> >> One reason *against* doing this would be wide variations in your input
>> >> data that could result in the wrong optimisations being made and
>> >> possibly suffering a decompilation event.
>> >>
>> >> There are commercial VMs that have technology to mitigate cold-start
>> >> costs (for example Azul Zing's ReadyNow).
>> >>
>> >>
>> >> Have you examined the HotSpot LogCompilation output to make sure there
>> >> is nothing you could change at source code level which would result in
>> a
>> >> better JIT decisions? I'm thinking of things like inlining failures due
>> >> to call-site megamorphism.
>> >>
>> >> There's a free tool called JITWatch that aims to make it easier to
>> >> understand the LogCompilation output
>> >> (https://github.com/AdoptOpenJDK/jitwatch) (Sorry for the sales pitch
>> -
>> >> I'm the
>> >> author).
>> >>
>> >> Regards,
>> >>
>> >>
>> >> Chris
>> >> @chriswhocodes
>> >>
>> >>
>> >> On Wed, May 20, 2015 03:11, Vitaly Davidovich wrote:
>> >>
>> >>> I'll let Vladimir comment on the compile command, but turning off
>> >>> tiered doesn't prevent inlining.  What prevents inlining (an otherwise
>> >>>  inlineable  method), in a nutshell, is lack of profiling information
>> >>>  that would indicate the method or callsite is hot enough for
>> >>> inlining. So you can have tiered off and run C2 with standard
>> >>> compilation thresholds, and you'll likely get good inlining because
>> >>> you'll have a long profile.  If you turn C2 compile threshold down too
>> >>> far (and too far is going to be app-specific), C2 compilation may not
>> >>> have sufficient info in the shortened profile to decide to inline.  Or
>> >>> even worse, the profile collected is actually not reflective of the
>> >>> real profile you want to capture (e.g. app has a phase change after
>> >>> initialization).
>> >>>
>> >>> The theoretical advantage of tiered is you can get decent perf
>> >>> quickly, but also since you're getting better than interpreter speed
>> >>> quickly, you can run in C1 tier longer and thus collect an even
>> >>> larger profile, possibly leading to better code than C2 alone.  But
>> >>> unfortunately this may require serious tuning.  That's my
>> >>> understanding at
>> >> least.
>> >>>
>> >>> sent from my phone On May 19, 2015 10:00 PM, "Tangwei (Euler)"
>> >>> <tangwei6 at huawei.com> wrote:
>> >>>
>> >>>
>> >>>
>> >>>> Vladimir,
>> >>>> What the 'double' means in following command line? The option
>> >>>> CompileThresholdScaling you mentioned is same as
>> >>>> ProfileMaturityPercentage?
>> >>>> I cannot find the option in code. How much effect to function
>> >>>> inlining by turning off tiered compilation?
>> >>>>
>> >>>>>
>> >>>>
>> >> -XX:CompileCommand=option,SomeClass.someMethod,double,CompileThresh
>> >> ol
>> >>>> dS caling,0.5
>> >>>>
>> >>>> Regards!
>> >>>> wei
>> >>>>
>> >>>>> -----Original Message-----
>> >>>>> From: Vladimir Kozlov [mailto:vladimir.kozlov at oracle.com]
>> >>>>> Sent: Wednesday, May 20, 2015 9:12 AM
>> >>>>> To: Tangwei (Euler); Vitaly Davidovich
>> >>>>> Cc: hotspot compiler
>> >>>>> Subject: Re: How to change compilation policy to trigger C2
>> >>>>> compilation
>> >>>> ASAP?
>> >>>>
>> >>>>
>> >>>>>
>> >>>>> If you want only C2 compilation you can disable tiered
>> >>>>> compilation
>> >>>>>
>> >>>> (since you
>> >>>>
>> >>>>
>> >>>>> don't want to spend to much on profiling anyway) and set low
>> >>>>> CompileThreshold (you need only this one for non-tiered compile):
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>> -XX:-TieredCompilation -XX:CompileThreshold=100
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>> If your method is simple and don't need profiling or inlining the
>> >>>>>
>> >>>>>
>> >>>> generated code
>> >>>>> could be same quality as with long profiling.
>> >>>>>
>> >>>>> An other approach is to set threshold per method (scale all
>> >>>>> threasholds
>> >>>> (C1, C2,
>> >>>>
>> >>>>
>> >>>>> interpreter) by this value). For example to reduce thresholds by
>> >>>>> half:
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>>
>> >> -XX:CompileCommand=option,SomeClass.someMethod,double,CompileThresh
>> >>
>> >>>>> oldScaling,0.5
>> >>>>>
>> >>>>> Vladimir
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>> On 5/19/15 5:43 PM, Tangwei (Euler) wrote:
>> >>>>>
>> >>>>>
>> >>>>>> My goal is just to reach peak performance quickly. Following is
>> >>>>>> one tier threshold combination I tried:
>> >>>>>>
>> >>>>>> -XX:Tier0ProfilingStartPercentage=0
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>> -XX:Tier3InvocationThreshold=3
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>> -XX:Tier3MinInvocationThreshold=2
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>> -XX:Tier3CompileThreshold=2
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>> -XX:Tier4InvocationThreshold=4
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>> -XX:Tier4MinInvocationThreshold=3
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>> -XX:Tier4CompileThreshold=2
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>> Regards!
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>> wei
>> >>>>>>
>> >>>>>> *From:*Vitaly Davidovich [mailto:vitalyd at gmail.com]
>> >>>>>> *Sent:* Tuesday, May 19, 2015 9:33 PM
>> >>>>>> *To:* Tangwei (Euler)
>> >>>>>> *Cc:* hotspot compiler
>> >>>>>> *Subject:* Re: How to change compilation policy to trigger C2
>> >>>>>> compilation ASAP?
>> >>>>>>
>> >>>>>> Is your goal specifically to have C2 compile or just to reach
>> >>>>>> peak performance quickly? It sounds like the latter.  What
>> >>>>>> values did you  specify for the tier thresholds? Also, it may
>> >>>>>> help you to -XX:+PrintCompilation to tune the flags as this will
>> >>>>>> show you which methods are being compiled, when, and at what
>> >>>>>> tier.
>> >>>>>>
>> >>>>>> sent from my phone
>> >>>>>>
>> >>>>>> On May 19, 2015 9:01 AM, "Tangwei (Euler)" <tangwei6 at huawei.com
>> >>>>>>  <mailto:tangwei6 at huawei.com>> wrote:
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>> Hi All,
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>> I want to run a JAVA application on a performance simulator,
>> >>>>>> and do a profiling on a hot function JITTed with C2 compiler.
>> >>>>>>
>> >>>>>> In order to make C2 compiler compile hot function as early as
>> >>>>>> possible, I hope to reduce the threshold of function invocation
>> >>>>>>
>> >>>>>> count in interpreter and C1 to drive the JIT compiler
>> >>>>>> transitioned to Level 4 (C2) ASAP. Following is the option list
>> >>>>>> I try, but
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>> failed to find a right combination to meet my requirement.
>> >>>>>> Anyone
>> >>>>>> can help to figure out what options I can use?
>> >>>>>>
>> >>>>>> Thanks in advance.
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>> -XX:Tier0ProfilingStartPercentage=0
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>> -XX:Tier3InvocationThreshold
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>> -XX:Tier3MinInvocationThreshold
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>> -XX:Tier3CompileThreshold
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>> -XX:Tier4InvocationThreshold
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>> -XX:CompileThreshold
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>> -XX:Tier4MinInvocationThreshold
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>> -XX:Tier4CompileThreshold
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>> Regards!
>> >>>>>>
>> >>>>>>
>> >>>>>>
>> >>>>>> wei
>> >>>>>>
>> >>>>
>> >>>
>> >>
>> >
>> >
>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20150520/e5b7c2df/attachment-0001.html>


More information about the hotspot-compiler-dev mailing list