< prev index next >

src/share/vm/gc_implementation/shenandoah/heuristics/shenandoahCompactHeuristics.cpp

Print this page
rev 11461 : [backport] 8226757: Shenandoah: Make traversal and passive modes explicit
rev 11463 : Backport Traversal GC


  26 #include "gc_implementation/shenandoah/shenandoahCollectionSet.hpp"
  27 #include "gc_implementation/shenandoah/heuristics/shenandoahCompactHeuristics.hpp"
  28 #include "gc_implementation/shenandoah/shenandoahFreeSet.hpp"
  29 #include "gc_implementation/shenandoah/shenandoahHeapRegion.hpp"
  30 #include "gc_implementation/shenandoah/shenandoahLogging.hpp"
  31 
  32 ShenandoahCompactHeuristics::ShenandoahCompactHeuristics() : ShenandoahHeuristics() {
  33   SHENANDOAH_ERGO_ENABLE_FLAG(ExplicitGCInvokesConcurrent);
  34   SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahImplicitGCInvokesConcurrent);
  35   SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahUncommit);
  36   SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahAlwaysClearSoftRefs);
  37   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahAllocationThreshold,  10);
  38   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahImmediateThreshold,   100);
  39   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahUncommitDelay,        1000);
  40   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahGuaranteedGCInterval, 30000);
  41   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahGarbageThreshold,     10);
  42 
  43   // Final configuration checks
  44   SHENANDOAH_CHECK_FLAG_SET(ShenandoahLoadRefBarrier);
  45   SHENANDOAH_CHECK_FLAG_SET(ShenandoahSATBBarrier);

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




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


< prev index next >