< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahMetrics.cpp

Print this page

 26 #include "gc/shenandoah/shenandoahMetrics.hpp"
 27 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
 28 #include "gc/shenandoah/shenandoahHeapRegion.hpp"
 29 #include "gc/shenandoah/shenandoahFreeSet.hpp"
 30 
 31 ShenandoahMetricsSnapshot::ShenandoahMetricsSnapshot() {
 32   _heap = ShenandoahHeap::heap();
 33 }
 34 
 35 void ShenandoahMetricsSnapshot::snap_before() {
 36   _used_before = _heap->used();
 37   _if_before = _heap->free_set()->internal_fragmentation();
 38   _ef_before = _heap->free_set()->external_fragmentation();
 39 }
 40 void ShenandoahMetricsSnapshot::snap_after() {
 41   _used_after = _heap->used();
 42   _if_after = _heap->free_set()->internal_fragmentation();
 43   _ef_after = _heap->free_set()->external_fragmentation();
 44 }
 45 
 46 bool ShenandoahMetricsSnapshot::is_good_progress() {












 47   // Under the critical threshold?
 48   size_t free_actual   = _heap->free_set()->available();
 49   size_t free_expected = _heap->max_capacity() / 100 * ShenandoahCriticalFreeThreshold;






 50   bool prog_free = free_actual >= free_expected;
 51   log_info(gc, ergo)("%s progress for free space: " SIZE_FORMAT "%s, need " SIZE_FORMAT "%s",
 52                      prog_free ? "Good" : "Bad",
 53                      byte_size_in_proper_unit(free_actual),   proper_unit_for_byte_size(free_actual),
 54                      byte_size_in_proper_unit(free_expected), proper_unit_for_byte_size(free_expected));
 55   if (!prog_free) {
 56     return false;
 57   }
 58 
 59   // Freed up enough?
 60   size_t progress_actual   = (_used_before > _used_after) ? _used_before - _used_after : 0;
 61   size_t progress_expected = ShenandoahHeapRegion::region_size_bytes();
 62   bool prog_used = progress_actual >= progress_expected;
 63   log_info(gc, ergo)("%s progress for used space: " SIZE_FORMAT "%s, need " SIZE_FORMAT "%s",
 64                      prog_used ? "Good" : "Bad",
 65                      byte_size_in_proper_unit(progress_actual),   proper_unit_for_byte_size(progress_actual),
 66                      byte_size_in_proper_unit(progress_expected), proper_unit_for_byte_size(progress_expected));
 67   if (prog_used) {
 68     return true;
 69   }

 26 #include "gc/shenandoah/shenandoahMetrics.hpp"
 27 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
 28 #include "gc/shenandoah/shenandoahHeapRegion.hpp"
 29 #include "gc/shenandoah/shenandoahFreeSet.hpp"
 30 
 31 ShenandoahMetricsSnapshot::ShenandoahMetricsSnapshot() {
 32   _heap = ShenandoahHeap::heap();
 33 }
 34 
 35 void ShenandoahMetricsSnapshot::snap_before() {
 36   _used_before = _heap->used();
 37   _if_before = _heap->free_set()->internal_fragmentation();
 38   _ef_before = _heap->free_set()->external_fragmentation();
 39 }
 40 void ShenandoahMetricsSnapshot::snap_after() {
 41   _used_after = _heap->used();
 42   _if_after = _heap->free_set()->internal_fragmentation();
 43   _ef_after = _heap->free_set()->external_fragmentation();
 44 }
 45 
 46 // For degenerated GC, generation is Young in generational mode, Global in non-generational mode.
 47 // For full GC, generation is always Global.
 48 //
 49 // Note that the size of the chosen collection set is proportional to the relevant generation's collection set.
 50 // Note also that the generation size may change following selection of the collection set, as a side effect
 51 // of evacuation.  Evacuation may promote objects, causing old to grow and young to shrink.  Or this may be a
 52 // mixed evacuation.  When old regions are evacuated, this typically allows young to expand.  In all of these
 53 // various scenarios, the purpose of asking is_good_progress() is to determine if there is enough memory available
 54 // within young generation to justify making an attempt to perform a concurrent collection.  For this reason, we'll
 55 // use the current size of the generation (which may not be different than when the collection set was chosen) to
 56 // assess how much free memory we require in order to consider the most recent GC to have had good progress.
 57 
 58 bool ShenandoahMetricsSnapshot::is_good_progress(ShenandoahGeneration* generation) {
 59   // Under the critical threshold?
 60   ShenandoahFreeSet* free_set = _heap->free_set();
 61   size_t free_actual   = free_set->available();
 62 
 63   // ShenandoahCriticalFreeThreshold is expressed as a percentage.  We multiple this percentage by 1/100th
 64   // of the generation capacity to determine whether the available memory within the generation exceeds the
 65   // critical threshold.
 66   size_t free_expected = (generation->max_capacity() / 100) * ShenandoahCriticalFreeThreshold;
 67 
 68   bool prog_free = free_actual >= free_expected;
 69   log_info(gc, ergo)("%s progress for free space: " SIZE_FORMAT "%s, need " SIZE_FORMAT "%s",
 70                      prog_free ? "Good" : "Bad",
 71                      byte_size_in_proper_unit(free_actual),   proper_unit_for_byte_size(free_actual),
 72                      byte_size_in_proper_unit(free_expected), proper_unit_for_byte_size(free_expected));
 73   if (!prog_free) {
 74     return false;
 75   }
 76 
 77   // Freed up enough?
 78   size_t progress_actual   = (_used_before > _used_after) ? _used_before - _used_after : 0;
 79   size_t progress_expected = ShenandoahHeapRegion::region_size_bytes();
 80   bool prog_used = progress_actual >= progress_expected;
 81   log_info(gc, ergo)("%s progress for used space: " SIZE_FORMAT "%s, need " SIZE_FORMAT "%s",
 82                      prog_used ? "Good" : "Bad",
 83                      byte_size_in_proper_unit(progress_actual),   proper_unit_for_byte_size(progress_actual),
 84                      byte_size_in_proper_unit(progress_expected), proper_unit_for_byte_size(progress_expected));
 85   if (prog_used) {
 86     return true;
 87   }
< prev index next >