Skip to main content

Is it too frequent for a Server JVM if YGC occurred in less one second?

5 replies [Last post]
jianwu
Offline
Joined: 2003-06-18

Hi,

I'm running some L&P Testing for a Java NIO based Application on a Sun Solaris 10
x86 4cpu boxes over the weekend, we are just using the default VM setting ( server
vm, 4 parallel gc threads, MarkSweep, and Scavenge for [Eden Space and Survivor
Space] ).

I found an interesting scenario I could not explain it by myself.

With 80 concurrent connections to my server application, it seems that the VM is
settling into a LOW heap memory consumption with very frequent YGC events
occurred less per second as the following jstat result shown:
=============================================================
-bash-3.00$ uname -a
SunOS musilla 5.10 Generic_118855-14 i86pc i386 i86pc
/usr/java/bin/jstat -gcnew 1390 250 8
S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT
576.0 576.0 512.0 0.0 13 15 576.0 2560.0 1393.2 90424 262.046
576.0 576.0 512.0 0.0 13 15 576.0 2560.0 2194.6 90424 262.046
576.0 576.0 0.0 480.0 13 15 576.0 2560.0 949.7 90425 262.048
576.0 576.0 0.0 480.0 13 15 576.0 2560.0 1704.8 90425 262.048
576.0 576.0 480.0 0.0 13 15 576.0 2560.0 227.7 90426 262.051
576.0 576.0 480.0 0.0 13 15 576.0 2560.0 1568.5 90426 262.051
576.0 576.0 480.0 0.0 13 15 576.0 2560.0 2418.1 90426 262.051
576.0 576.0 0.0 496.0 13 15 576.0 2560.0 396.5 90427 262.054
============================================================

You can see in 2 seconds ( 250ms * 8 ), YGC counts increased from 90424 to
90427.

I ran this kind of testing a lot of times, this is first time I saw the total Heap Size
actually went down after running a full day.

So, what is the normal frequency of YGC running on a Server JVM? If I want to
further investigate this scenario, where I should look into or dig?

Any suggestion or tip is really appreciated

Thanks a lot!

Jian

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
briand
Offline
Joined: 2005-07-11

> So, what is the normal frequency of YGC running on a Server JVM? If I want to
> further investigate this scenario, where I should look into or dig?

Sorry about being somewhat flippant with an answer here, but only you can
answer this question. What I mean is that some applications can handle highly
frequent GC events of short duration and others cannot. You need to get an idea
of what your performance goals are - response time, throughput, gc overhead -
in order to answer this question.

Generally, there are ways to go about reducing frequency, but there are always
tradeoffs. If you increase the size of the young generation, you can decrease the
frequency of the young gen collections but in exchange for this, you may be
increasing worst case response time and footprint (large heap, for example).
You might also be improving throughput, and reducing gc overhead too.

The best place to go for GC tuning advice is probably here:

http://java.sun.com/javase/technologies/performance.jsp

In particular, check out the following papers:

http://java.sun.com/performance/reference/whitepapers/tuning.html
http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html

HTH
Brian

jianwu
Offline
Joined: 2003-06-18

Hi Briand,

Thanks a lot for your reply!

> Generally, there are ways to go about reducing frequency, but there are always
> tradeoffs. If you increase the size of the young generation, you can decrease the
> frequency of the young gen collections but in exchange for this, you may be
> increasing worst case response time and footprint (large heap, for example).
> You might also be improving throughput, and reducing gc overhead too.

From VisualGC, I could see the default setting of my VM:
=======================================
Eden Space ( 138M 2.5M )
Survivor 0 ( 38M 128K )
Survivor 1 ( 38M 128K)
=======================================
And, I can see both Eden and Survivor still have space when YGC
occurred, should I tune SurvivorRatio or other parameter to change its
behavior?

I'll turn on verbose;gc to dig deeper into it

Also, another question in my mind is that, if I am able to run my Server
Application in a low heap size, it is actually great since that means the
Server can run a very very long time without restarting it, and I can run
more Server Instances with existing Server Memory. How can I tune the
JVM to make it happen in a more predictable way?

Any suggestion or tip is really appreciated

Thanks a lot for your help!

Jian

briand
Offline
Joined: 2005-07-11

> And, I can see both Eden and Survivor still have space when YGC
> occurred,

By definition, the eden space must be essentially filled for a young gen
collection to occur. I say 'essentially' because there can be some fragmentation
within the TLABs when object allocations can't be satisfied with the remaining
space in the TLAB. But this is not easy to see with visualgc.

One possible explanation for what you are seeing is that you have -Xms != -Xmx,
which allows the heap to grow and shrink as needed. In this case, the young
generation will not grow until a full gc event occurs. Setting -Xms == -Xmx and
setting -Xmn will fix the size of the heap and may make this more obvious to you.

Another possible explanation of what you are seeing is the sampling nature
of visualgc and jstat. If visualgc is sampling at interval that is close to or
longer than the gc interval, it is likely to present incomprehensible data that
could lead to this kind of misinterpretation. If you are running visualgc locally
and can afford the additional CPU consumption, you can run visualgc at 20
or 30ms intervals and get a better view of what's happening.

> Also, another question in my mind is that, if I am able to run my Server
> Application in a low heap size, it is actually great since that means the
> Server can run a very very long time without restarting it, and I can run

Restarting of applications should be independent of heap size - if it's not,
then you likely have a memory leak in your application. If you do have
a memory leak, you may be restarting it more often with a smaller heap.

Smaller heap sizes will certainly translate into more concurrent application
instances, but the trade off may be reduced application throughput and
increased application response times as a result of increased GC overhead
for one or more of those instances.

> How can I tune the
> JVM to make it happen in a more predictable way?

To make what happen in a more predicable way? Also, what's your
definition of predictable?

You really need to communicate what your performance goals are -
maximize throughput, minimize response time, minimize memory
utilization - pick one. If you pick more than one, then there will be
trade offs with the others.

Brian

linuxhippy
Offline
Joined: 2004-01-07

> So, what is the normal frequency of YGC running on a
> Server JVM? If I want to
> further investigate this scenario, where I should
> look into or dig?
Well this can't be answered. It depends a lot on the type of your workload and the amount of eden space available. If you create many short-lived objects its quite ok to see that frequent GCs.
I would not worry except if you've performance problems, really ;)

lg Clemens

jianwu
Offline
Joined: 2003-06-18

Sorry, I forgot to mention that I'm running JVM 1.5.0_06-b05