how to know jvm is stopping the world?

Charles K Pepperdine kirk at kodewerk.com
Tue Dec 13 17:45:07 UTC 2011


Hi,

Sorry but this thread looks like a train wreak about to happen with everyone shouting.. FASTER... FASTER..... FASTER!!!! :-)

First a call to System.gc() will *always* result in a Full GC being executed. The call to System.gc() is synchronized which means that is multiple threads call it, the will be blocked waiting for the previous call complete.
Second, hooking things up to the JVMPI can result in a much slower runtime, it can alter/prevent future optimizations.

IMHO, what is really needed here is an understanding of *why* your applications transactional rates are so slow and *why* you're having difficulties with GC. IME, many of the problems you describe are more easily addressable with memory tuning. This goes beyond just a technical tuning of the JVM. It will involve analyzing how your application uses (and in this case abuses) memory. Try object creation statistics via NetBeans memory profiler.. or if you like to spend money to get the same information, get a copy of YourKit (a great tool that does do a wee bit more than NB profiler). Worst you could do it force a heap dump (jmap) on your production machine and do a census of what's in it.

Finally, technical tuning requires that you look at GC logs. I collect GC logs as a hobby so if you happen to produce one from your production system (negligible performance penalty to turn on gc logging) send it along and I'm happy to take a look let you know what I see.

Kind regards,
Kirk Pepperdine


On Dec 13, 2011, at 8:10 AM, Li Li wrote:

> thanks.
> is there any resources about writing tools communicating with JVM using JVMTI?
> 
> On Tue, Dec 13, 2011 at 11:51 AM, Krystal Mok <rednaxelafx at gmail.com> wrote:
> The GC start/end events in JVMTI are available since a long time ago. You can use it in JDK 6 right now. [1] And in OpenJDK 7, too.
> 
> The problem (for you) is this interface does not allow you to execute any Java code in the event callback. You'll need make some non-Java interface in your dispatcher so that this notification can ultimately propagate from the JVM in full GC to your dispatcher.
> 
> - Kris
> 
> [1]: http://docs.oracle.com/javase/6/docs/platform/jvmti/jvmti.html#GarbageCollectionStart
> 
> On Tue, Dec 13, 2011 at 11:40 AM, Li Li <fancyerii at gmail.com> wrote:
> That's what I want.
> btw, this feature is only available in sun jdk7? 
> does it exist in openjdk7?
> 
> 
> On Mon, Dec 12, 2011 at 11:06 PM, Stefan Karlsson <stefan.karlsson at oracle.com> wrote:
> On 12/11/2011 07:31 AM, Li Li wrote:
> hi,
>    In our application of full text searching with lucene and solr. we will give jvm about 25GB memory. we use CMS as old generation garbage collector. But the jvm sometimes can't do anything. So our clients complain that the connection is time out. we find the reason is the jvm is doing full gc and it will stop service for about 1-3 seconds.
>    I know that this situation is inevitable when using CMS collector. but we have more than one searching machines, so if I know jvm is doing full gc(specially stop the world), I can send requests to other machines. But the question now is that jvm don't provide an api for that. I think it's not very difficult(for guys developing hotspot, but is in deed difficult for me ). So I want your help.
>    The first question is where is the position of CMS full gc.
>    from http://blogs.oracle.com/jonthecollector/entry/did_you_know
>    there are many steps:
>      1. STW initial mark
>      2. Concurrent marking
>      3. Concurrent precleaning
>      4. STW remark
>      5. Concurrent sweeping
>      6. Concurrent reset
>    there are 2 stop the world stages. I want to know the line number(or functions) of this stages. so I can tell java program that jvm now is doing full gc.
>     The second is that how to communicate between jvm and java program? My expected thing is like :
>     //java program
>     if(System.isStopTheWolrd()){
>           //system is busy, tell the dispatch node that don't send request to me
>     }else{
>           do service;
>     }
>     I have no experience in jvm developing. jvm is implemented in c and jni is the interface between them. is there any other method that jvm can achieve this? obviously, it can extend System class and add a static method named isStopTheWorld(). Could some one tell me how to do this in details? Thank you very much.
> 
> You could probably use JVMTI. See: http://docs.oracle.com/javase/7/docs/platform/jvmti/jvmti.html#GarbageCollectionStart
> 
> StefanK
> 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/hotspot-gc-dev/attachments/20111213/f4a4f270/attachment.htm>


More information about the hotspot-gc-dev mailing list