RFR: Proper units for allocation failure messages

Aleksey Shipilev shade at redhat.com
Wed Jul 11 10:49:41 UTC 2018


This prints proper units for "Allocation Failure" messages, which avoids awkward "Failed to allocate
0K":


diff -r 446220b6e48c src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp
--- a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp       Wed Jul 11 10:23:03 2018 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp       Wed Jul 11 12:34:33 2018 +0200
@@ -463,7 +463,8 @@

   if (try_set_alloc_failure_gc()) {
     // Only report the first allocation failure
-    log_info(gc)("Failed to allocate " SIZE_FORMAT "K", words * HeapWordSize / K);
+    log_info(gc)("Failed to allocate " SIZE_FORMAT "%s",
+                 byte_size_in_proper_unit(words * HeapWordSize), proper_unit_for_byte_size(words *
HeapWordSize));

     // Now that alloc failure GC is scheduled, we can abort everything else
     heap->cancel_gc(GCCause::_allocation_failure);
@@ -484,7 +485,8 @@

   if (try_set_alloc_failure_gc()) {
     // Only report the first allocation failure
-    log_info(gc)("Failed to allocate " SIZE_FORMAT "K for evacuation", words * HeapWordSize / K);
+    log_info(gc)("Failed to allocate " SIZE_FORMAT "%s for evacuation",
+                 byte_size_in_proper_unit(words * HeapWordSize), proper_unit_for_byte_size(words *
HeapWordSize));
   }

   // Forcefully report allocation failure


Testing: tier1_gc_shenandoah, eyeballing gc logs

Thanks,
-Aleksey



More information about the shenandoah-dev mailing list