src/hotspot/share/gc/shenandoah/heuristics/shenandoahCompactHeuristics.cpp
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 54833 76751d3faf7b
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
    47   SHENANDOAH_CHECK_FLAG_SET(ShenandoahKeepAliveBarrier);
    47   SHENANDOAH_CHECK_FLAG_SET(ShenandoahKeepAliveBarrier);
    48   SHENANDOAH_CHECK_FLAG_SET(ShenandoahCASBarrier);
    48   SHENANDOAH_CHECK_FLAG_SET(ShenandoahCASBarrier);
    49   SHENANDOAH_CHECK_FLAG_SET(ShenandoahCloneBarrier);
    49   SHENANDOAH_CHECK_FLAG_SET(ShenandoahCloneBarrier);
    50 }
    50 }
    51 
    51 
    52 bool ShenandoahCompactHeuristics::should_start_normal_gc() const {
    52 bool ShenandoahCompactHeuristics::should_start_gc() const {
    53   ShenandoahHeap* heap = ShenandoahHeap::heap();
    53   ShenandoahHeap* heap = ShenandoahHeap::heap();
    54 
    54 
    55   size_t capacity = heap->max_capacity();
    55   size_t capacity = heap->max_capacity();
    56   size_t available = heap->free_set()->available();
    56   size_t available = heap->free_set()->available();
    57 
    57 
    58   size_t threshold_bytes_allocated = capacity / 100 * ShenandoahAllocationThreshold;
    58   size_t threshold_bytes_allocated = capacity / 100 * ShenandoahAllocationThreshold;
    59   size_t min_threshold = capacity / 100 * ShenandoahMinFreeThreshold;
    59   size_t min_threshold = capacity / 100 * ShenandoahMinFreeThreshold;
    60 
    60 
    61   if (available < min_threshold) {
    61   if (available < min_threshold) {
    62     log_info(gc)("Trigger: Free (" SIZE_FORMAT "M) is below minimum threshold (" SIZE_FORMAT "M)",
    62     log_info(gc)("Trigger: Free (" SIZE_FORMAT "%s) is below minimum threshold (" SIZE_FORMAT "%s)",
    63                  available / M, min_threshold / M);
    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));
    64     return true;
    65     return true;
    65   }
    66   }
    66 
    67 
    67   if (available < threshold_bytes_allocated) {
    68   if (available < threshold_bytes_allocated) {
    68     log_info(gc)("Trigger: Free (" SIZE_FORMAT "M) is lower than allocated recently (" SIZE_FORMAT "M)",
    69     log_info(gc)("Trigger: Free (" SIZE_FORMAT "%s) is lower than allocated recently (" SIZE_FORMAT "%s)",
    69                  available / M, threshold_bytes_allocated / M);
    70                  byte_size_in_proper_unit(available),                 proper_unit_for_byte_size(available),
       
    71                  byte_size_in_proper_unit(threshold_bytes_allocated), proper_unit_for_byte_size(threshold_bytes_allocated));
    70     return true;
    72     return true;
    71   }
    73   }
    72 
    74 
    73   size_t bytes_allocated = heap->bytes_allocated_since_gc_start();
    75   size_t bytes_allocated = heap->bytes_allocated_since_gc_start();
    74   if (bytes_allocated > threshold_bytes_allocated) {
    76   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)",
    77     log_info(gc)("Trigger: Allocated since last cycle (" SIZE_FORMAT "%s) is larger than allocation threshold (" SIZE_FORMAT "%s)",
    76                  bytes_allocated / M, threshold_bytes_allocated / M);
    78                  byte_size_in_proper_unit(bytes_allocated),           proper_unit_for_byte_size(bytes_allocated),
       
    79                  byte_size_in_proper_unit(threshold_bytes_allocated), proper_unit_for_byte_size(threshold_bytes_allocated));
    77     return true;
    80     return true;
    78   }
    81   }
    79 
    82 
    80   return ShenandoahHeuristics::should_start_normal_gc();
    83   return ShenandoahHeuristics::should_start_gc();
    81 }
    84 }
    82 
    85 
    83 void ShenandoahCompactHeuristics::choose_collection_set_from_regiondata(ShenandoahCollectionSet* cset,
    86 void ShenandoahCompactHeuristics::choose_collection_set_from_regiondata(ShenandoahCollectionSet* cset,
    84                                                                         RegionData* data, size_t size,
    87                                                                         RegionData* data, size_t size,
    85                                                                         size_t actual_free) {
    88                                                                         size_t actual_free) {
    86   // Do not select too large CSet that would overflow the available free space
    89   // Do not select too large CSet that would overflow the available free space
    87   size_t max_cset = actual_free * 3 / 4;
    90   size_t max_cset = actual_free * 3 / 4;
    88 
    91 
    89   log_info(gc, ergo)("CSet Selection. Actual Free: " SIZE_FORMAT "M, Max CSet: " SIZE_FORMAT "M",
    92   log_info(gc, ergo)("CSet Selection. Actual Free: " SIZE_FORMAT "%s, Max CSet: " SIZE_FORMAT "%s",
    90                      actual_free / M, max_cset / M);
    93                      byte_size_in_proper_unit(actual_free), proper_unit_for_byte_size(actual_free),
       
    94                      byte_size_in_proper_unit(max_cset),    proper_unit_for_byte_size(max_cset));
    91 
    95 
    92   size_t threshold = ShenandoahHeapRegion::region_size_bytes() * ShenandoahGarbageThreshold / 100;
    96   size_t threshold = ShenandoahHeapRegion::region_size_bytes() * ShenandoahGarbageThreshold / 100;
    93 
    97 
    94   size_t live_cset = 0;
    98   size_t live_cset = 0;
    95   for (size_t idx = 0; idx < size; idx++) {
    99   for (size_t idx = 0; idx < size; idx++) {