< prev index next >

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

Print this page




  35   SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahImplicitGCInvokesConcurrent);
  36   SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahUncommit);
  37   SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahAlwaysClearSoftRefs);
  38   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahAllocationThreshold,  10);
  39   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahImmediateThreshold,   100);
  40   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahUncommitDelay,        1000);
  41   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahGuaranteedGCInterval, 30000);
  42   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahGarbageThreshold,     10);
  43 
  44   // Final configuration checks
  45   SHENANDOAH_CHECK_FLAG_SET(ShenandoahLoadRefBarrier);
  46   SHENANDOAH_CHECK_FLAG_SET(ShenandoahSATBBarrier);
  47   SHENANDOAH_CHECK_FLAG_SET(ShenandoahKeepAliveBarrier);
  48   SHENANDOAH_CHECK_FLAG_SET(ShenandoahCASBarrier);
  49   SHENANDOAH_CHECK_FLAG_SET(ShenandoahCloneBarrier);
  50 }
  51 
  52 bool ShenandoahCompactHeuristics::should_start_normal_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 "M) is below minimum threshold (" SIZE_FORMAT "M)",
  63                  available / M, min_threshold / M);
  64     return true;
  65   }
  66 
  67   if (available < threshold_bytes_allocated) {
  68     log_info(gc)("Trigger: Free (" SIZE_FORMAT "M) is lower than allocated recently (" SIZE_FORMAT "M)",
  69                  available / M, threshold_bytes_allocated / M);
  70     return true;
  71   }
  72 
  73   size_t bytes_allocated = heap->bytes_allocated_since_gc_start();
  74   if (bytes_allocated > threshold_bytes_allocated) {
  75     log_info(gc)("Trigger: Allocated since last cycle (" SIZE_FORMAT "M) is larger than allocation threshold (" SIZE_FORMAT "M)",
  76                  bytes_allocated / M, threshold_bytes_allocated / M);
  77     return true;
  78   }
  79 




  35   SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahImplicitGCInvokesConcurrent);
  36   SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahUncommit);
  37   SHENANDOAH_ERGO_ENABLE_FLAG(ShenandoahAlwaysClearSoftRefs);
  38   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahAllocationThreshold,  10);
  39   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahImmediateThreshold,   100);
  40   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahUncommitDelay,        1000);
  41   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahGuaranteedGCInterval, 30000);
  42   SHENANDOAH_ERGO_OVERRIDE_DEFAULT(ShenandoahGarbageThreshold,     10);
  43 
  44   // Final configuration checks
  45   SHENANDOAH_CHECK_FLAG_SET(ShenandoahLoadRefBarrier);
  46   SHENANDOAH_CHECK_FLAG_SET(ShenandoahSATBBarrier);
  47   SHENANDOAH_CHECK_FLAG_SET(ShenandoahKeepAliveBarrier);
  48   SHENANDOAH_CHECK_FLAG_SET(ShenandoahCASBarrier);
  49   SHENANDOAH_CHECK_FLAG_SET(ShenandoahCloneBarrier);
  50 }
  51 
  52 bool ShenandoahCompactHeuristics::should_start_normal_gc() const {
  53   ShenandoahHeap* heap = ShenandoahHeap::heap();
  54 

  55   size_t available = heap->free_set()->available();
  56   size_t threshold_bytes_allocated = heap->capacity() * ShenandoahAllocationThreshold / 100;
  57   size_t min_threshold = ShenandoahMinFreeThreshold * heap->capacity() / 100;

  58 
  59   if (available < min_threshold) {
  60     log_info(gc)("Trigger: Free (" SIZE_FORMAT "M) is below minimum threshold (" SIZE_FORMAT "M)",
  61                  available / M, min_threshold / M);
  62     return true;
  63   }
  64 
  65   if (available < threshold_bytes_allocated) {
  66     log_info(gc)("Trigger: Free (" SIZE_FORMAT "M) is lower than allocated recently (" SIZE_FORMAT "M)",
  67                  available / M, threshold_bytes_allocated / M);
  68     return true;
  69   }
  70 
  71   size_t bytes_allocated = heap->bytes_allocated_since_gc_start();
  72   if (bytes_allocated > threshold_bytes_allocated) {
  73     log_info(gc)("Trigger: Allocated since last cycle (" SIZE_FORMAT "M) is larger than allocation threshold (" SIZE_FORMAT "M)",
  74                  bytes_allocated / M, threshold_bytes_allocated / M);
  75     return true;
  76   }
  77 


< prev index next >