RFR: Soft refs policy needs reliable heap usage data after the GC cycle

Aleksey Shipilev shade at redhat.com
Tue Sep 4 15:19:01 UTC 2018


Following up on fixes for soft refs policy handling in Shenandoah. Global soft refs policy expects
GC to report their last used/capacity after the GC, yet Shenandoah reports it only after the final
mark, which overestimates used heap. I guess that is a leftover from the time Shenandoah only did
CM-with-UR unconditionally.

This should be done at the end of GC instead. Done in GC epilog under heap lock to get coherent
used/capacity values:

diff -r 2ced7933815f src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp
--- a/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp       Tue Sep 04 12:08:47 2018 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp       Tue Sep 04 17:17:33 2018 +0200
@@ -212,10 +212,15 @@
       // Report current free set state at the end of cycle, whether
       // it is a normal completion, or the abort.
       {
         ShenandoahHeapLocker locker(heap->lock());
         heap->free_set()->log_status();
+
+        // Notify Universe about new heap usage. This has implications for
+        // global soft refs policy, and we better report it every time heap
+        // usage goes down.
+        Universe::update_heap_info_at_gc();
       }

       // Disable forced counters update, and update counters one more time
       // to capture the state at the end of GC session.
       handle_force_counters_update();
diff -r 2ced7933815f src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp        Tue Sep 04 12:08:47 2018 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp        Tue Sep 04 17:17:33 2018 +0200
@@ -1155,12 +1155,10 @@
       heuristics()->choose_collection_set(_collection_set);

       _free_set->rebuild();
     }

-    Universe::update_heap_info_at_gc();
-
     if (ShenandoahVerify) {
       verifier()->verify_before_evacuation();
     }
   }
 }

Testing: tier3_gc_shenandoah, adhoc benchmarks

-Aleksey



More information about the shenandoah-dev mailing list