< prev index next >

src/hotspot/share/gc/shenandoah/heuristics/shenandoahCompactHeuristics.cpp

Print this page




  24 
  25 #include "precompiled.hpp"
  26 
  27 #include "gc/shenandoah/shenandoahCollectionSet.hpp"
  28 #include "gc/shenandoah/heuristics/shenandoahCompactHeuristics.hpp"
  29 #include "gc/shenandoah/shenandoahFreeSet.hpp"
  30 #include "gc/shenandoah/shenandoahHeapRegion.hpp"
  31 #include "logging/log.hpp"
  32 #include "logging/logTag.hpp"
  33 
  34 ShenandoahCompactHeuristics::ShenandoahCompactHeuristics() : ShenandoahHeuristics() {
  35   SHENANDOAH_ERGO_ENABLE_FLAG(ExplicitGCInvokesConcurrent);
  36   SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahImplicitGCInvokesConcurrent);
  37   SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahUncommit);
  38   SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahAlwaysClearSoftRefs);
  39   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahAllocationThreshold,  10);
  40   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahImmediateThreshold,   100);
  41   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahUncommitDelay,        1000);
  42   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahGuaranteedGCInterval, 30000);
  43   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahGarbageThreshold,     10);
  44 
  45   // Final configuration checks
  46   SHENANDOAH_CHECK_FLAG_SET(ShenandoahLoadRefBarrier);
  47   SHENANDOAH_CHECK_FLAG_SET(ShenandoahSATBBarrier);
  48   SHENANDOAH_CHECK_FLAG_SET(ShenandoahCASBarrier);
  49   SHENANDOAH_CHECK_FLAG_SET(ShenandoahCloneBarrier);
  50 }
  51 
  52 bool ShenandoahCompactHeuristics::should_start_gc() const {
  53   ShenandoahHeap* heap = ShenandoahHeap::heap();
  54 
  55   size_t capacity = heap->max_capacity();
  56   size_t available = heap->free_set()->available();
  57 
  58   size_t threshold_bytes_allocated = capacity / 100 * ShenandoahAllocationThreshold;
  59   size_t min_threshold = capacity / 100 * ShenandoahMinFreeThreshold;
  60 
  61   if (available < min_threshold) {
  62     log_info(gc)("Trigger: Free (" SIZE_FORMAT "%s) is below minimum threshold (" SIZE_FORMAT "%s)",
  63                  byte_size_in_proper_unit(available),     proper_unit_for_byte_size(available),
  64                  byte_size_in_proper_unit(min_threshold), proper_unit_for_byte_size(min_threshold));
  65     return true;
  66   }
  67 
  68   size_t bytes_allocated = heap->bytes_allocated_since_gc_start();
  69   if (bytes_allocated > threshold_bytes_allocated) {




  24 
  25 #include "precompiled.hpp"
  26 
  27 #include "gc/shenandoah/shenandoahCollectionSet.hpp"
  28 #include "gc/shenandoah/heuristics/shenandoahCompactHeuristics.hpp"
  29 #include "gc/shenandoah/shenandoahFreeSet.hpp"
  30 #include "gc/shenandoah/shenandoahHeapRegion.hpp"
  31 #include "logging/log.hpp"
  32 #include "logging/logTag.hpp"
  33 
  34 ShenandoahCompactHeuristics::ShenandoahCompactHeuristics() : ShenandoahHeuristics() {
  35   SHENANDOAH_ERGO_ENABLE_FLAG(ExplicitGCInvokesConcurrent);
  36   SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahImplicitGCInvokesConcurrent);
  37   SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahUncommit);
  38   SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahAlwaysClearSoftRefs);
  39   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahAllocationThreshold,  10);
  40   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahImmediateThreshold,   100);
  41   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahUncommitDelay,        1000);
  42   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahGuaranteedGCInterval, 30000);
  43   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahGarbageThreshold,     10);






  44 }
  45 
  46 bool ShenandoahCompactHeuristics::should_start_gc() const {
  47   ShenandoahHeap* heap = ShenandoahHeap::heap();
  48 
  49   size_t capacity = heap->max_capacity();
  50   size_t available = heap->free_set()->available();
  51 
  52   size_t threshold_bytes_allocated = capacity / 100 * ShenandoahAllocationThreshold;
  53   size_t min_threshold = capacity / 100 * ShenandoahMinFreeThreshold;
  54 
  55   if (available < min_threshold) {
  56     log_info(gc)("Trigger: Free (" SIZE_FORMAT "%s) is below minimum threshold (" SIZE_FORMAT "%s)",
  57                  byte_size_in_proper_unit(available),     proper_unit_for_byte_size(available),
  58                  byte_size_in_proper_unit(min_threshold), proper_unit_for_byte_size(min_threshold));
  59     return true;
  60   }
  61 
  62   size_t bytes_allocated = heap->bytes_allocated_since_gc_start();
  63   if (bytes_allocated > threshold_bytes_allocated) {


< prev index next >