< prev index next >

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

Print this page




 110   } else {
 111     return 1;
 112   }
 113 }
 114 
 115 ShenandoahMetricsSnapshot::ShenandoahMetricsSnapshot() {
 116   _heap = ShenandoahHeap::heap();
 117 }
 118 
 119 void ShenandoahMetricsSnapshot::snap_before() {
 120   _used_before = _heap->used();
 121   _if_before = ShenandoahMetrics::internal_fragmentation();
 122   _ef_before = ShenandoahMetrics::external_fragmentation();
 123 }
 124 void ShenandoahMetricsSnapshot::snap_after() {
 125   _used_after = _heap->used();
 126   _if_after = ShenandoahMetrics::internal_fragmentation();
 127   _ef_after = ShenandoahMetrics::external_fragmentation();
 128 }
 129 
 130 bool ShenandoahMetricsSnapshot::is_good_progress() {
 131   // Under the critical threshold?






 132   size_t free_actual   = _heap->free_set()->available();
 133   size_t free_expected = _heap->max_capacity() / 100 * ShenandoahCriticalFreeThreshold;
 134   bool prog_free = free_actual >= free_expected;
 135   log_info(gc, ergo)("%s progress for free space: " SIZE_FORMAT "%s, need " SIZE_FORMAT "%s",
 136                      prog_free ? "Good" : "Bad",
 137                      byte_size_in_proper_unit(free_actual),   proper_unit_for_byte_size(free_actual),
 138                      byte_size_in_proper_unit(free_expected), proper_unit_for_byte_size(free_expected));
 139   if (!prog_free) {
 140     return false;
 141   }
 142 
 143   // Freed up enough?
 144   size_t progress_actual   = (_used_before > _used_after) ? _used_before - _used_after : 0;
 145   size_t progress_expected = ShenandoahHeapRegion::region_size_bytes();
 146   bool prog_used = progress_actual >= progress_expected;
 147   log_info(gc, ergo)("%s progress for used space: " SIZE_FORMAT "%s, need " SIZE_FORMAT "%s",
 148                      prog_used ? "Good" : "Bad",
 149                      byte_size_in_proper_unit(progress_actual),   proper_unit_for_byte_size(progress_actual),
 150                      byte_size_in_proper_unit(progress_expected), proper_unit_for_byte_size(progress_expected));
 151   if (prog_used) {
 152     return true;
 153   }


 154 
 155   // Internal fragmentation is down?
 156   double if_actual = _if_before - _if_after;
 157   double if_expected = 0.01; // 1% should be enough
 158   bool prog_if = if_actual >= if_expected;
 159   log_info(gc, ergo)("%s progress for internal fragmentation: %.1f%%, need %.1f%%",
 160                      prog_if ? "Good" : "Bad",
 161                      if_actual * 100, if_expected * 100);
 162   if (prog_if) {
 163     return true;
 164   }


 165 
 166   // External fragmentation is down?
 167   double ef_actual = _ef_before - _ef_after;
 168   double ef_expected = 0.01; // 1% should be enough
 169   bool prog_ef = ef_actual >= ef_expected;
 170   log_info(gc, ergo)("%s progress for external fragmentation: %.1f%%, need %.1f%%",
 171                      prog_ef ? "Good" : "Bad",
 172                      ef_actual * 100, ef_expected * 100);
 173   if (prog_ef) {
 174     return true;
 175   }


 176 
 177   // Nothing good had happened.
 178   return false;
 179 }


 110   } else {
 111     return 1;
 112   }
 113 }
 114 
 115 ShenandoahMetricsSnapshot::ShenandoahMetricsSnapshot() {
 116   _heap = ShenandoahHeap::heap();
 117 }
 118 
 119 void ShenandoahMetricsSnapshot::snap_before() {
 120   _used_before = _heap->used();
 121   _if_before = ShenandoahMetrics::internal_fragmentation();
 122   _ef_before = ShenandoahMetrics::external_fragmentation();
 123 }
 124 void ShenandoahMetricsSnapshot::snap_after() {
 125   _used_after = _heap->used();
 126   _if_after = ShenandoahMetrics::internal_fragmentation();
 127   _ef_after = ShenandoahMetrics::external_fragmentation();
 128 }
 129 
 130 void ShenandoahMetricsSnapshot::print() {
 131   log_info(gc, ergo)("Used: before: " SIZE_FORMAT "M, after: " SIZE_FORMAT "M", _used_before/M, _used_after/M);
 132   log_info(gc, ergo)("Internal frag: before: %.1f%%, after: %.1f%%", _if_before * 100, _if_after * 100);
 133   log_info(gc, ergo)("External frag: before: %.1f%%, after: %.1f%%", _ef_before * 100, _ef_after * 100);
 134 }
 135 
 136 bool ShenandoahMetricsSnapshot::is_good_progress(const char *label) {
 137   // Under the critical threshold? Declare failure.
 138   size_t free_actual   = _heap->free_set()->available();
 139   size_t free_expected = _heap->max_capacity() / 100 * ShenandoahCriticalFreeThreshold;
 140   if (free_actual < free_expected) {
 141     log_info(gc, ergo)("Not enough free space (" SIZE_FORMAT "M, need " SIZE_FORMAT "M) after %s",
 142                        free_actual / M, free_expected / M, label);



 143     return false;
 144   }
 145 
 146   // Freed up enough? Good! Declare victory.
 147   size_t progress_actual   = (_used_before > _used_after) ? _used_before - _used_after : 0;
 148   size_t progress_expected = ShenandoahHeapRegion::region_size_bytes();
 149   if (progress_actual >= progress_expected) {





 150     return true;
 151   }
 152   log_info(gc,ergo)("Not enough progress (" SIZE_FORMAT "M, need " SIZE_FORMAT "M) after %s",
 153                     progress_actual / M, progress_expected / M, label);
 154 
 155   // Internal fragmentation is down? Good! Declare victory.
 156   double if_actual = _if_before - _if_after;
 157   double if_expected = 0.01; // 1% should be enough
 158   if (if_actual > if_expected) {




 159     return true;
 160   }
 161   log_info(gc,ergo)("Not enough internal fragmentation improvement (%.1f%%, need %.1f%%) after %s",
 162                     if_actual * 100, if_expected * 100, label);
 163 
 164   // External fragmentation is down? Good! Declare victory.
 165   double ef_actual = _ef_before - _ef_after;
 166   double ef_expected = 0.01; // 1% should be enough
 167   if (ef_actual > ef_expected) {




 168     return true;
 169   }
 170   log_info(gc,ergo)("Not enough external fragmentation improvement (%.1f%%, need %.1f%%) after %s",
 171                     if_actual * 100, if_expected * 100, label);
 172 
 173   // Nothing good had happened.
 174   return false;
 175 }
< prev index next >