8225046: Shenandoah metrics logs refactoring
authorshade
Mon, 03 Jun 2019 14:50:59 +0200
changeset 55152 6c205bbdafd2
parent 55151 9691a169f1dd
child 55153 47d928ba8733
8225046: Shenandoah metrics logs refactoring Reviewed-by: rkennke
src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
src/hotspot/share/gc/shenandoah/shenandoahMetrics.cpp
src/hotspot/share/gc/shenandoah/shenandoahMetrics.hpp
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp	Tue May 21 15:46:09 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp	Mon Jun 03 14:50:59 2019 +0200
@@ -1604,9 +1604,8 @@
   }
 
   metrics.snap_after();
-  metrics.print();
-
-  if (metrics.is_good_progress("Full GC")) {
+
+  if (metrics.is_good_progress()) {
     _progress_last_gc.set();
   } else {
     // Nothing to do. Tell the allocation path that we have failed to make
@@ -1739,11 +1738,10 @@
   }
 
   metrics.snap_after();
-  metrics.print();
 
   // Check for futility and fail. There is no reason to do several back-to-back Degenerated cycles,
   // because that probably means the heap is overloaded and/or fragmented.
-  if (!metrics.is_good_progress("Degenerated GC")) {
+  if (!metrics.is_good_progress()) {
     _progress_last_gc.unset();
     cancel_gc(GCCause::_shenandoah_upgrade_to_full_gc);
     op_degenerated_futile();
--- a/src/hotspot/share/gc/shenandoah/shenandoahMetrics.cpp	Tue May 21 15:46:09 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahMetrics.cpp	Mon Jun 03 14:50:59 2019 +0200
@@ -127,48 +127,52 @@
   _ef_after = ShenandoahMetrics::external_fragmentation();
 }
 
-void ShenandoahMetricsSnapshot::print() {
-  log_info(gc, ergo)("Used: before: " SIZE_FORMAT "M, after: " SIZE_FORMAT "M", _used_before/M, _used_after/M);
-  log_info(gc, ergo)("Internal frag: before: %.1f%%, after: %.1f%%", _if_before * 100, _if_after * 100);
-  log_info(gc, ergo)("External frag: before: %.1f%%, after: %.1f%%", _ef_before * 100, _ef_after * 100);
-}
-
-bool ShenandoahMetricsSnapshot::is_good_progress(const char *label) {
-  // Under the critical threshold? Declare failure.
+bool ShenandoahMetricsSnapshot::is_good_progress() {
+  // Under the critical threshold?
   size_t free_actual   = _heap->free_set()->available();
   size_t free_expected = _heap->max_capacity() / 100 * ShenandoahCriticalFreeThreshold;
-  if (free_actual < free_expected) {
-    log_info(gc, ergo)("Not enough free space (" SIZE_FORMAT "M, need " SIZE_FORMAT "M) after %s",
-                       free_actual / M, free_expected / M, label);
+  bool prog_free = free_actual >= free_expected;
+  log_info(gc, ergo)("%s progress for free space: " SIZE_FORMAT "%s, need " SIZE_FORMAT "%s",
+                     prog_free ? "Good" : "Bad",
+                     byte_size_in_proper_unit(free_actual),   proper_unit_for_byte_size(free_actual),
+                     byte_size_in_proper_unit(free_expected), proper_unit_for_byte_size(free_expected));
+  if (!prog_free) {
     return false;
   }
 
-  // Freed up enough? Good! Declare victory.
+  // Freed up enough?
   size_t progress_actual   = (_used_before > _used_after) ? _used_before - _used_after : 0;
   size_t progress_expected = ShenandoahHeapRegion::region_size_bytes();
-  if (progress_actual >= progress_expected) {
+  bool prog_used = progress_actual >= progress_expected;
+  log_info(gc, ergo)("%s progress for used space: " SIZE_FORMAT "%s, need " SIZE_FORMAT "%s",
+                     prog_used ? "Good" : "Bad",
+                     byte_size_in_proper_unit(progress_actual),   proper_unit_for_byte_size(progress_actual),
+                     byte_size_in_proper_unit(progress_expected), proper_unit_for_byte_size(progress_expected));
+  if (prog_used) {
     return true;
   }
-  log_info(gc,ergo)("Not enough progress (" SIZE_FORMAT "M, need " SIZE_FORMAT "M) after %s",
-                    progress_actual / M, progress_expected / M, label);
 
-  // Internal fragmentation is down? Good! Declare victory.
+  // Internal fragmentation is down?
   double if_actual = _if_before - _if_after;
   double if_expected = 0.01; // 1% should be enough
-  if (if_actual > if_expected) {
+  bool prog_if = if_actual >= if_expected;
+  log_info(gc, ergo)("%s progress for internal fragmentation: %.1f%%, need %.1f%%",
+                     prog_if ? "Good" : "Bad",
+                     if_actual * 100, if_expected * 100);
+  if (prog_if) {
     return true;
   }
-  log_info(gc,ergo)("Not enough internal fragmentation improvement (%.1f%%, need %.1f%%) after %s",
-                    if_actual * 100, if_expected * 100, label);
 
-  // External fragmentation is down? Good! Declare victory.
+  // External fragmentation is down?
   double ef_actual = _ef_before - _ef_after;
   double ef_expected = 0.01; // 1% should be enough
-  if (ef_actual > ef_expected) {
+  bool prog_ef = ef_actual >= ef_expected;
+  log_info(gc, ergo)("%s progress for external fragmentation: %.1f%%, need %.1f%%",
+                     prog_ef ? "Good" : "Bad",
+                     ef_actual * 100, ef_expected * 100);
+  if (prog_ef) {
     return true;
   }
-  log_info(gc,ergo)("Not enough external fragmentation improvement (%.1f%%, need %.1f%%) after %s",
-                    if_actual * 100, if_expected * 100, label);
 
   // Nothing good had happened.
   return false;
--- a/src/hotspot/share/gc/shenandoah/shenandoahMetrics.hpp	Tue May 21 15:46:09 2019 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahMetrics.hpp	Mon Jun 03 14:50:59 2019 +0200
@@ -47,9 +47,8 @@
 
   void snap_before();
   void snap_after();
-  void print();
 
-  bool is_good_progress(const char *label);
+  bool is_good_progress();
 };
 
 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHMETRICS_HPP