Fwd: how to know jvm is stopping the world?

Li Li fancyerii at gmail.com
Tue Dec 13 03:38:33 UTC 2011

  yes, this is not a perfect solution, but it can alleviate this painful
  e.g. our application receives 10 request per second, it means every 100
ms a request. and the stop the world is 500ms
if we don't monitor the status of jvm, when jvm stop the world, 5 requests
are not processed. but if we send request before consulting the jvm, then
only one request are blocked.
  of course there are extreme situation that the 5 requests comes at the
same time and jvm tells them I am not stop the world, but when requests
come, it stops the world.
  but comparing with these two solutions. asking then sending is a better

On Mon, Dec 12, 2011 at 9:57 PM, Vitaly Davidovich <vitalyd at gmail.com>wrote:

> But suppose you had this feature and the VM tells you that it's not doing
> (or doesn't have any pending) full gc.  Your load balancer then sends the
> request to that server - what happens if the processing of this request
> triggers a full gc? I just don't think there's a comprehensive solution
> here since you'd still run the risk of having a STW pause amidst request
> processing.
> As for jmx notifications on heap usage it's still just a guess in terms of
> what that actually means - the gc that follows may be concurrent (not STW)
> or there may not be a gc at all if the mem allocations aren't high enough.
> I agree with Krystal that it makes most sense in tuning the GC + checking
> your own code to make sure it plays well with the GC algorithm that you're
> using (I.e. CMS).
> On Dec 11, 2011 10:56 PM, "Li Li" <fancyerii at gmail.com> wrote:
>> ---------- Forwarded message ----------
>> From: Krystal Mok <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>
>> 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> 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/20111213/f348686c/attachment.htm>

More information about the hotspot-gc-dev mailing list