Free ratio based heap shrinking in the parallel collector

Jon Masamitsu Jon.Masamitsu at Sun.COM
Mon Mar 15 19:03:53 UTC 2010


Hiroshi,

I'm looking at the code in psParallelCompact.cpp

2076     bool free_ratio_in_effect = false;
2077     if ((UseFreeRatioForParallelGC ||
2078          (UseFreeRatioOnlyInSystemGCForParallelGC &&
2079           gc_cause == GCCause::_java_lang_system_gc))) {
2080       ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
2081       free_ratio_in_effect = heap->try_to_shrink_by_free_ratio(true);
2082     }
2083 
2084     if (!free_ratio_in_effect && UseAdaptiveSizePolicy) {

If only UseFreeRatioForParallelGC is set to true, is it correct
that the heap

  a) will grow according to the original UseAdaptiveSizePolicy
policy until MaxHeapFreeRatio is exceeded (i.e., until
try_to_shrink_by_free_ratio() returns true)
  b) will then shrink until MaxHeapFreeRatio is no longer exceeded
(likely just that once)

then start with a) again?

What type of application fits with such a combination of policies?
Do you have a plots of how the heap sizing behaves (i.e., size of the
generations vs. collections/time)?

Jon

Hiroshi Yamauchi wrote On 03/10/10 15:17,:

> Hi,
>
> I'd like to have this patch
>
>   http://cr.openjdk.java.net/~rasbold/69XXXXX/webrev.00/
> <http://cr.openjdk.java.net/%7Erasbold/69XXXXX/webrev.00/>
>
> contributed, if appropriate.
>
> It implements a simple heap shrinking logic based on the free ratio
> (MaxHeapFreeRatio) in the parallel collector. The way it works is the
> following: If the free ratio, (1.0 - <used> / <capacity>) * 100 >
> MaxHeapFreeRatio, this logic kicks in. Otherwise, the (default)
> adaptive size policy runs the show (as before). This feature is turned
> off by default. There are two new flags to turn it on:
>
>   UseFreeRatioForParallelGC - this enables it.
>   UseFreeRatioOnlyInSystemGCForParallelGC - this enables it only in
> explicit System.gc() calls. This is more useful in apps that call
> System.gc() when it's idle and don't want shrinking to happen at all
> other times.
>
> In our tests, it appears to work well in a simple test and to help a
> real app reduce its footprint (RSS) when it's idle.
>
> Thanks to Chuck Rasbold who uploaded the webrev on my behalf.
>
> Thanks,
> Hiroshi
>




More information about the hotspot-gc-dev mailing list