Fwd: how to know jvm is stopping the world?
yumin.qi at oracle.com
yumin.qi at oracle.com
Mon Dec 12 16:13:53 UTC 2011
Your calling method (even there were such method, in fact there is no
such function) will not be executed during STW, since all java threads
stopped. The result is that after JVM resumes all java threads, your
call will return true always. To know the jvm status, you have to use
some agents like JVMTI.
--Yumin
On 12/11/2011 7:55 PM, Li Li wrote:
>
> ---------- Forwarded message ----------
> From: *Krystal Mok* <rednaxelafx at gmail.com <mailto:rednaxelafx at gmail.com>>
> Date: Sun, Dec 11, 2011 at 5:53 PM
> Subject: Re: how to know jvm is stopping the world?
> To: Li Li <fancyerii at gmail.com <mailto:fancyerii at gmail.com>>
>
>
> HI,
>
> You're probably looking in the wrong direction. When the JVM
> "stops-the-world", it stops the world -- all Java threads (or
> "mutators") are suspended. There's no way for you to execute any Java
> code during that period.
> HotSpot VM uses a "safepoint" mechanism to stop-the-world. You can get
> safepoint stats with -XX:+PrintSafepointStatistics.
>
> There's an alternative that might help. Try GC notification with JMX
> [1]. Setup a notification threshold, and when the heap usage crosses
> the threshold, you'll get a notification. Put the load balancing logic
> in the callback. Even though this is different from "a notification of
> stop-the-world pause", it might work for you.
>
> There's a GC notification mechanism in .NET that might have been
> closer to what you wanted [2].
>
> - Kris
>
> [1]:
> http://docs.oracle.com/javase/6/docs/api/java/lang/management/MemoryMXBean.html
> [2]: http://msdn.microsoft.com/en-us/library/cc713687.aspx
>
> On Sun, Dec 11, 2011 at 2:31 PM, Li Li <fancyerii at gmail.com
> <mailto:fancyerii at gmail.com>> 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.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/hotspot-gc-dev/attachments/20111212/a344d2e8/attachment.htm>
More information about the hotspot-gc-dev
mailing list