changeset 9422:cc1666a28b88

8138684: G1 decision about taking regions into the collection set is too aggressive Summary: Factor in expected waste and uncertainty of our guess in the decision whether to take another region into the collection set. Reviewed-by: mgerdin, jmasa
author tschatzl
date Fri, 13 Nov 2015 09:12:06 +0100
parents 9089740e9f30
children 636e286dd5da 4d465c7793ec
files src/share/vm/gc/g1/g1CollectorPolicy.cpp
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/gc/g1/g1CollectorPolicy.cpp	Tue Nov 03 13:03:04 2015 -0800
+++ b/src/share/vm/gc/g1/g1CollectorPolicy.cpp	Fri Nov 13 09:12:06 2015 +0100
@@ -467,8 +467,19 @@
   }
 
   size_t free_bytes = (base_free_regions - young_length) * HeapRegion::GrainBytes;
-  if ((2.0 /* magic */ * _predictor.sigma()) * bytes_to_copy > free_bytes) {
-    // end condition 3: out-of-space (conservatively!)
+
+  // When copying, we will likely need more bytes free than is live in the region.
+  // Add some safety margin to factor in the confidence of our guess, and the
+  // natural expected waste.
+  // (100.0 / G1ConfidencePercent) is a scale factor that expresses the uncertainty
+  // of the calculation: the lower the confidence, the more headroom.
+  // (100 + TargetPLABWastePct) represents the increase in expected bytes during
+  // copying due to anticipated waste in the PLABs.
+  double safety_factor = (100.0 / G1ConfidencePercent) * (100 + TargetPLABWastePct) / 100.0;
+  size_t expected_bytes_to_copy = safety_factor * bytes_to_copy;
+
+  if (expected_bytes_to_copy > free_bytes) {
+    // end condition 3: out-of-space
     return false;
   }